Skip to content

Instantly share code, notes, and snippets.

@mjhea0
Last active December 16, 2015 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjhea0/5456627 to your computer and use it in GitHub Desktop.
Save mjhea0/5456627 to your computer and use it in GitHub Desktop.
find your missing socks / for polina / http://screencast.com/t/EckaqSCJco
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