Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think Ruby is the ideal language for AoC:

* The expressive syntax helps keep the solutions short.

* It has extensive standard library with tons of handy methods for AoC style problems: Enumerable#each_cons, Enumerable#each_slice, Array#transpose, Array#permutation, ...

* The bundled "prime" gem (for generating primes, checking primality, and prime factorization) comes in handy for at least a few of problems each year.

* The tools for parsing inputs and string manipulation are a bit more ergonomic than what you get even in Python: first class regular expression syntax, String#scan, String#[], Regexp::union, ...

* You can easily build your solution step-by-step by chaining method calls. I would typically start with `p File.readlines("input.txt")` and keep executing the script after adding each new method call so I can inspect the intermediate results.





Haven't used prime stuff, since not so versed in algorithms I guess, but other than that totally agree. So far have enjoyed it the most. Though I remember doing those really elongated Go solutions consisting of long for loops over and over... When they were ready and ran, they were very fast even with brute force solutions.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: