Last active
December 21, 2015 16:09
-
-
Save yancya/6331917 to your computer and use it in GitHub Desktop.
シェル芸の課題、やっとできた Ruby でだけど...
課題: https://twitter.com/usptomo/status/371095051826245632
This file contains hidden or 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
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