Created
August 23, 2013 03:19
-
-
Save chron/6315218 to your computer and use it in GitHub Desktop.
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
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
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