Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions solutions/lastname_firstname/exercise_1_questions.markdown

This file was deleted.

2 changes: 0 additions & 2 deletions solutions/lastname_firstname/exercise_1_solutions.rb

This file was deleted.

Empty file.
23 changes: 23 additions & 0 deletions solutions/le_rolen/exercise_1_questions.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Problem 1
What do I want?
How do I get there?
Am I commanding or querying? Am I CRUDing or validating?
What do I need to manipulate to get the answer i want?

1. What is my desired data structure?

1. What is my current data sturcture?
3. Is the desired data structure a command or a queary?
- Command
How do I change the data to what I want?
- Query
How do I validate my query?
## Problem 2

## Problem 3
What do I want?
What is the simplest input/output to validate this?
How do I break this down to simplest datum
What tools do I have available
Why is it breaking?
(I should write tests)
31 changes: 31 additions & 0 deletions solutions/le_rolen/exercise_1_solutions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Problem 1
#
class StringParser
attr_reader :word
def initialize(word)
@word = word
end

def unique?
!repeating_character?
end

def repeating_character?
word.chars.any? { |letter| word.scan(/#{letter}/).count > 1 }
end

def reverse
letters = word.chars
new_word = ""
new_word += letters.pop until letters.none?
new_word
end

def uniq
word.chars.each_with_object([]) do |letter, uniqs|
next if uniqs.include? letter
uniqs << letter
end.join
end
end

27 changes: 27 additions & 0 deletions solutions/le_rolen/exercise_1_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
gem 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'exercise_1_solutions'

class StringsTest < Minitest::Test
def test_determines_a_string_has_unique_characters
unique = "string"
assert_equal true, StringParser.new(unique).unique?
blah = "sstring"
refute_equal true, StringParser.new(blah).unique?
end

def test_reverse_a_string
reverse = "reverse"
assert_equal "esrever", StringParser.new(reverse).reverse
end

def test_can_find_uniques
a = "abcd"
aa = "aabcd"
aaa = "abbcda"
assert_equal a, StringParser.new(a).uniq
assert_equal a, StringParser.new(aa).uniq
assert_equal a, StringParser.new(aaa).uniq
end
end