Nim
This one was pretty simple, just parse the numbers into sets and check the size of the intersection. Part 2 just made the scoring mechanism a little more complicated.
This one was pretty simple, just parse the numbers into sets and check the size of the intersection. Part 2 just made the scoring mechanism a little more complicated.
My solution for day 1 part 1 was simple and to the point. The other ones are getting increasingly less so. You're right that sometimes it's best not to get too fancy, but I think soon I may have to break out such advanced programming techniques as "functions" and maybe "objects", instead of writing increasingly convoluted piles of nested loops. xD
I actually just learned about scanf while writing this. Only ended up using it in the one spot, since split worked well enough for the other bits. I really wanted to be able to use python-style unpacking, but in nim it only works for tuples. At least without writing macros, which I still haven't been able to wrap my head around.
I'm not doing anything too fancy here, just the first stuff that comes to mind and gets the job done. The filterIt template was pretty handy for part 1, though. I assume at some point in these puzzles I'll have to actually write some types and procedures instead of just using nested loops for everything.
I think it's a pretty cool language overall. I've only used it for one project so far, so there's a bunch that I still don't know. Haven't been able to wrap my head around how macros work, for example, though I've sort of figured out how to write really basic templates.
Another nim person! Have you joined the community? There are dozens of us!
Here's mine (no code blocks because kbin):
Oh hey, a fellow nim person. Have you joined the community?
Here's mine. Kbin doesn't even support code blocks, so using topaz:
Oh wow, I guess it doesn't take too much. I copied your survey post over to r/nim with a "cross-posted from [email protected]" link, and also invited the author of Enu to post here. I'll keep at it.
Yep. ^_^
Alright, not a bad idea.
I imagine they'd also want to have something you can click that shows how many votes were local, how many were from other instances, how many were blocked, etc.
Actually, that would be really cool and worth doing regardless. Have a voting statistics view for each post where upvotes and downvotes are broken down per instance, and maybe by other criteria too. @ernest
I'm rather spoiled by python, so I feel like it could be more elegant. xD
But yeah, I do like how this one turned out, and nim runs a whole lot faster than python does. I really like nim's "method call syntax". Instead of having methods associated with an individual type, you can just call any procedure as
x.f(remaining_args)
to callf
withx
as its first argument. Makes it easy to chain procedures. Since nim is strongly typed, it'll know which procedure you mean to use by the signature.