Skip to content

Instantly share code, notes, and snippets.

@yancya
Last active December 21, 2015 16:09
Show Gist options
  • Save yancya/6331917 to your computer and use it in GitHub Desktop.
Save yancya/6331917 to your computer and use it in GitHub Desktop.
シェル芸の課題、やっとできた Ruby でだけど... 課題: https://twitter.com/usptomo/status/371095051826245632
echo 56 2 8 9 | ruby -e 'nums = ARGF.read; loop{exp = nums.split(" ").shuffle.inject(""){|exp, num| [num, exp].join(%w{+ - * /}.sample)}.gsub(/.$/, ""); if eval(exp) == 100; puts exp; break; end}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment