I spent some time on this coding problem using hashes and for in (new to me) loops this morning. The solution works but do you have something cleaner / more efficient?
#100DaysOfCode
I spent some time on this coding problem using hashes and for in (new to me) loops this morning. The solution works but do you have something cleaner / more efficient?
#100DaysOfCode
| # Load the dictionary, store it in an array, shuffle it | |
| dictionary = File.open('dictionary.txt') | |
| dictionary_array = dictionary.readlines | |
| dictionary_array.shuffle! | |
| # Intro text, wait for user to type 'start' | |
| puts "\n<<< Terminal Hangman >>>\n\n" | |
| puts "Type \"start\" to begin a new game\n" | |
| turn = 0 | |
| rematch = nil |
| def fizz_buzz_1(max) | |
| arr = [] | |
| (1..max).each do |n| | |
| if ((n % 3 == 0) && (n % 5 == 0)) | |
| arr << "FizzBuzz" | |
| elsif (n % 3 == 0) | |
| arr << "Fizz" | |
| elsif (n % 5 == 0) | |
| arr << "Buzz" | |
| else |