Last active
March 13, 2016 21:15
-
-
Save gvaughn/fb89c65e01207f1d281d to your computer and use it in GitHub Desktop.
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
p=fn 0,_->;i,p->spawn fn->w=" on the wall.";b=&" #{&1} bottle#{&1==1&&""||"s"} of Elixir" | |
IO.puts [inspect(self),b.(i),w,b.(i),".\n",i==1&&"Go get some more,"<>b.(99)||"Take one down pass it around,"<>b.(i-1),w,10] | |
p.(i-1,p)end end;p.(99,p);:timer.sleep 999 |
Nice solution! Here are a few ideas for improvement:
- You can replace
".\n"
with a plain newline (1 char less) - Maybe you did it on purpose, but the semicolons are not really necessary. You could just replace them with plain newlines as well to make it (imho) a little bit more readable. But again, maybe that's not the point ;-)
- You can replace
i==1
withi<2
ori>1
and flip the branches (two occurrences, so 2 chars less) - You can replace
sleep 999
withsleep ?ϧ
(1 char less) I learned this technique from @henrik's solution to the last elixir golf. Basically you can find the appropriate unicode character by runningto_string [999]
in iex.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: the sleep call at the end feels like cheating. I had a prior solution in which the main process received the verse string from each spawned process and then printed it itself. That was well over 300 chars though.