Arc Forumnew | comments | leaders | submitlogin
Advent 2019, day 3, problem 1: Arc vs Python
2 points by akkartik 1837 days ago | 5 comments
Spoiler alert!

Problems: https://adventofcode.com/2019

Solutions to day 3, problem 1: https://gist.github.com/akkartik/94b8ab6526b312c836c3d6d281f23504

Without spoiling anything, I think Python wins here. Mostly thanks to generator expressions and native support for sets. It's equally concise, and I won't dwell on how much faster it is.

One problem with Python: I did the whole thing using lists for co-ordinates and then realized at the end that lists aren't hashable so can't be in sets. So I had to go back and turn all my co-ordinates into tuples.

Couple of minor things on the pro-Arc side of the ledger: `repeat` is lovely, and being expression-oriented gives us the tertiary operator for free in `mag`.

But maybe my Arc is rusty. Have I forgotten any cool functions in our library?



2 points by zck 1836 days ago | link

My solution using Clojure:

https://gist.github.com/zck/7d563d3ee1b7baf5bf67558aece6c861

As with your Python solution, set operations were nice. `(set/intersection w1positions w2positions)` helped.

-----

2 points by jsgrahamus 1828 days ago | link

Would love to see some output. Thanks, Akkartik!

-----

2 points by jsgrahamus 1828 days ago | link

Also, where do we find 3.in?

-----

1 point by akkartik 1828 days ago | link

The input is on the problem page. Scroll to the bottom of https://adventofcode.com/2019/day/3 to 'get your puzzle input'. You should be able to get the output by running the commands I gave. It's just a numeric answer so not super interesting.

-----

2 points by zck 1827 days ago | link

Also notably, the input is different for each user, as is each answer.

So the code should be the same, but you can't use my input to get an answer you can check on their website.

-----