Last active
December 16, 2015 15:29
-
-
Save mjhea0/5456627 to your computer and use it in GitHub Desktop.
find your missing socks / for polina / http://screencast.com/t/EckaqSCJco
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
system("clear") | |
socks = Hash.new | |
puts | |
puts "To find your missing sock(s) -" | |
puts " (1) Enter all of your sock colors/patterns." | |
puts " (2) Type \"quit\" when done." | |
puts " (3) Look at the results." | |
puts | |
puts | |
print "Please enter the color/pattern of your first sock: " | |
color = gets.chomp | |
while color != "quit" | |
if color == "quit" then | |
break | |
else | |
if socks.has_key?(color) | |
socks[color] += 1 | |
else | |
socks[color] = 1 | |
end | |
print "Please enter the color/pattern of another sock: " | |
color = gets.chomp | |
end | |
end | |
system("clear") | |
puts | |
puts "Your Sock Drawer" | |
puts "----------------" | |
socks.each {|k,v| puts "#{k} => #{v}" } | |
puts | |
puts "Your Missing Socks" | |
puts "------------------" | |
socks.each {|k,v| puts k if v % 2 != 0 } | |
puts | |
puts | |
puts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment