Skip to content

Instantly share code, notes, and snippets.

@chron

chron/pie-golf.rb

Created Aug 23, 2013
Embed
What would you like to do?
Trying to cut down the size of Jan Dvorak's answer to this golf.se question: http://codegolf.stackexchange.com/questions/12356/manage-a-pie-shop
h=Hash.new 0
loop{$><<'> '
a,b,c=gets.split
puts({list:->{h.map{|x|?|+" %%%ds |"%h.flatten.map{|e|e.to_s.size}.max*2%x}},count:->{h[b]!=0?h[b]:"There is no #{b} pie!"},buy:->{h[c]+=b.to_i},sell:->{h[c]-=b.to_i},exit:->{abort"The pie store has closed!"}}[a.intern][])rescue puts"That's not a valid command."}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.