99 Bottles of Elixir... #6

Open
emson opened this Issue Mar 1, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@emson
Owner

emson commented Mar 1, 2016

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/.

  • Write code that will output all 99 verses of the song "99 bottles of..." https://en.wikipedia.org/wiki/99_Bottles_of_Beer
  • spawn a new process for each verse, and that verse must be output to the console (the primary process).
  • Each verse will sequentially decrease the number of bottles on the wall, this sequence is important and must not jump up or down.

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

This comment has been minimized.

Show comment
Hide comment
@henrik

henrik Mar 4, 2016

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

henrik commented Mar 4, 2016

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

This comment has been minimized.

Show comment
Hide comment
@emson

emson Mar 4, 2016

Owner

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

Owner

emson commented Mar 4, 2016

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

@gvaughn

This comment has been minimized.

Show comment
Hide comment
@gvaughn

gvaughn Mar 5, 2016

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

gvaughn commented Mar 5, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment