emson / elixirgolf

Elixir Golf web site
MIT License
3 stars 1 forks source link

99 Bottles of Elixir... #6

Open emson opened 8 years ago

emson commented 8 years ago

We’re back! The slow start for 2016 has been because I’ve been completing an Elixir online video course. The course is called Elixir for Beginners http://www.elixirforbeginners.com and at the moment it’s hosted on Udemy: https://www.udemy.com/elixir-for-beginners/.

For example the program will work something like this:

$> elixir bottles.exs
#PID<0.50.0> 99 bottles of Elixir on the wall, 99 bottles of Elixir.
Take one down and pass it around, 98 bottles of Elixir on the wall.

#PID<0.51.0> 98 bottles of Elixir on the wall, 98 bottles of Elixir.
Take one down and pass it around, 97 bottles of Elixir on the wall.

....

#PID<0.147.0> 2 bottles of Elixir on the wall, 2 bottles of Elixir.
Take one down and pass it around, 1 bottle of Elixir on the wall.

#PID<0.148.0> 1 bottle of Elixir on the wall, 1 bottle of Elixir.
Go code some more, 99 bottles of Elixir on the wall.

Finally...

  1. Please add your solutions as comments to this Github issue
  2. Remember to add your Twitter handle (I will link to it if you get a mention)
    Many thanks, Ben
    When the puzzle is over I'll write them up on http://elixirgolf.com and link back to your Twitter handle
henrik commented 8 years ago

My 238 char solution is in this Gist, will keep updating it: https://gist.github.com/henrik/a21fc19cb1f8fca445e5

You can see the progress down from the initial 256 chars.

I'll assume we don't need to explicitly call the function spawn as long as a process is spawned.

Twitter: @henrik

emson commented 8 years ago

Correct you don't need to use the spawn function as long as a process is spawned so Task can be used too.

gvaughn commented 8 years ago

Well, I see that not only am I slow, but I'm using too many chars too: 258. https://gist.github.com/gvaughn/fb89c65e01207f1d281d

Task is clever! I did it with raw spawn in a recursive anonymous fn. Maybe I'll get the obfuscated bonus prize :-)

Twitter: @gregvaughn