diff --git a/solutions/lastname_firstname/exercise_1_questions.markdown b/solutions/lastname_firstname/exercise_1_questions.markdown deleted file mode 100644 index a81069a..0000000 --- a/solutions/lastname_firstname/exercise_1_questions.markdown +++ /dev/null @@ -1,7 +0,0 @@ -## Problem 1 - -* What does 'all unique characters' mean? -* Why would `uniq` have been helpful? -* ... - -## Problem 2 \ No newline at end of file diff --git a/solutions/lastname_firstname/exercise_1_solutions.rb b/solutions/lastname_firstname/exercise_1_solutions.rb deleted file mode 100644 index 463a5ee..0000000 --- a/solutions/lastname_firstname/exercise_1_solutions.rb +++ /dev/null @@ -1,2 +0,0 @@ -# Problem 1 - diff --git a/solutions/lastname_firstname/exercise_1_test.rb b/solutions/lastname_firstname/exercise_1_test.rb deleted file mode 100644 index e69de29..0000000 diff --git a/solutions/le_rolen/exercise_1_questions.markdown b/solutions/le_rolen/exercise_1_questions.markdown new file mode 100644 index 0000000..b91dcc6 --- /dev/null +++ b/solutions/le_rolen/exercise_1_questions.markdown @@ -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) diff --git a/solutions/le_rolen/exercise_1_solutions.rb b/solutions/le_rolen/exercise_1_solutions.rb new file mode 100644 index 0000000..e163e20 --- /dev/null +++ b/solutions/le_rolen/exercise_1_solutions.rb @@ -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 + diff --git a/solutions/le_rolen/exercise_1_test.rb b/solutions/le_rolen/exercise_1_test.rb new file mode 100644 index 0000000..a4a2cef --- /dev/null +++ b/solutions/le_rolen/exercise_1_test.rb @@ -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