diff --git a/pattern_generator/lib/pattern_generator.rb b/pattern_generator/lib/pattern_generator.rb new file mode 100644 index 0000000..60f6110 --- /dev/null +++ b/pattern_generator/lib/pattern_generator.rb @@ -0,0 +1,39 @@ +require 'pry' +class PatternGenerator + + attr_reader :letters, :numbers, :all + + def initialize + @letters = ("A".."H").to_a + ("J".."N").to_a + ("P".."Z").to_a + @numbers = ("2".."9").to_a + @all = [] + end + + def create_all_options + first = @letters + second = @letters + third = @numbers + fourth = @letters + fifth = @numbers + + first.each do |one| + second.each do |two| + third.each do |three| + fourth.each do |four| + fifth.each do |five| + @all << [one,two,three,four,five].join + end + end + end + end + end + @all.count + end + + def get_a_random_one + @all = @all.shuffle + @all.pop + end + + +end diff --git a/pattern_generator/test/pattern_generator_test.rb b/pattern_generator/test/pattern_generator_test.rb new file mode 100644 index 0000000..132154b --- /dev/null +++ b/pattern_generator/test/pattern_generator_test.rb @@ -0,0 +1,36 @@ +require 'minitest/autorun' +require 'minitest/pride' +require './lib/pattern_generator' +require 'pry' + +class PatternGeneratorTest < Minitest::Test + def test_it_exists + assert(PatternGenerator.new).is_a? PatternGenerator + end + + def test_it_initalizes_with_numbers + pattern_generator = PatternGenerator.new + assert_equal ["2", "3", "4", "5", "6", "7", "8", "9"], pattern_generator.numbers + end + + def test_it_initalizes_with_letters + expected = ["A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] + pattern_generator = PatternGenerator.new + assert_equal expected, pattern_generator.letters + end + + def test_it_can_create_all_options + expected = 884736 + pattern_generator = PatternGenerator.new + assert_equal expected, pattern_generator.create_all_options + end + + def test_it_returns_a_random_one_that_will_not_be_still_avaible + pattern_generator = PatternGenerator.new + pattern_generator.create_all_options + random = pattern_generator.get_a_random_one + refute pattern_generator.all.include?(random) + end + + +end