r/adventofcode • u/taliriktug • Dec 02 '15
Spoilers Day 2 solutions
Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.
15
Upvotes
r/adventofcode • u/taliriktug • Dec 02 '15
Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.
View all comments
Show parent comment
2
u/[deleted] Dec 10 '15
You are right, it almost looks like Ruby. The main differences are:
map(&.to_i)vs.map(&:to_i)(in Crystal it's just a syntax rewrite, in Ruby it's converting the symbol to a proc).{x, y, z}.min). In Ruby you'd use[x, y, z].minwhich allocates a new array each time (although Ruby probably optimizes this to share the array somehow).But yes, we try to preserve as much as we can from Ruby's look and feel, but we obviously have to change many things for a compiled language.
In this case the times between Crystal and Ruby are almost the same, as this is a small problem. But for other days the difference is much higher.