DEV Community

Discussion on: Help me decide a language for Advent of Code

 
rhymes profile image
rhymes

I've posted my broken solution in Elixir but it's not working: github.com/rhymes/aoc2018/blob/mas...

Keep in mind I haven't even read the tutorial yet :D

Basically it's supposed to iterate on infinite stream of numbers, add one to the previous and if the sum is already known (hence the set), quit

Thread Thread
 
exadra37 profile image
Paulo Renato • Edited

Try to follow the advent of code in Elixir forum elixirforum.com/t/advent-of-code-2..., they are sharing their solutions there. The solution from member Sneako seems a good one, check it elixirforum.com/t/advent-of-code-2....

They are very nice people and will help you in your journey.

I am not doing the advent of code... unfortunately I don't have spare time to dedicate to it.

TIP: while if else exists in Elixir is barely used by a functional programmer. Instead try to use pattern matching in the function heads. See here an example dev.to/flatironschool/pattern-matc...

Thread Thread
 
rhymes profile image
rhymes

they are sharing their solutions there. The solution from member Sneako seems a good one, check it

yeah, I ended with a similar solution github.com/rhymes/aoc2018/blob/mas... - though you can see how more imperative is my code

They are very nice people and will help you in your journey.

Nice to know! I still haven't completely ruled out Clojure :D

I am not doing the advent of code... unfortunately I don't have spare time to dedicate to it.

It's perfectly fine, it's my first time ever!

TIP: while if else exists in Elixir is barely used by a functional programmer. Instead try to use pattern matching in the function heads.

Thanks for the tip. I'll surely read it. I tried to use pattern matching with MapSet.member? as a guard but it wasn't allowed, so I switched to a recursion first and then the if + reduce_while version.

I hope I'll have time to study the language a little better, not just try to butt my head on the wall until I get a decent solution :D

Thread Thread
 
exadra37 profile image
Paulo Renato • Edited

Nice you have been able to figure it out.

Not everything can go in guard clauses. Try to read about them.

I am seeing some doing the advent of code in 2 languages at same time. So why not Elixir and Clojure for solving each day challenge?

No matter what language you want to use for the advent of code would have been good that you had time to prepare for it before, like going through the basics of it.

What worked better for me to left the imperative thinking and adopt the functional programming way was this video course and this book. They are paid but totally worth every cent I paid for them. The author spent a lot of time ensuring that we understand the functional programming paradigm. By the end we have built something useful that we can use in our day to day as developers.

Thread Thread
 
rhymes profile image
rhymes

Thank you :-) You're right, I should have gone through at least the tutorial before, but I totally forgot about it :D