Python Forum
Advent of Code 2019 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: Advent of Code 2019 (/thread-22857.html)



Advent of Code 2019 - ThomasL - Nov-30-2019

Hi everybody! In case you did not know about Advent of Code yet:

Quote:Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as a speed contest, interview prep, company training, university coursework, practice problems, or to challenge each other.

You don't need a computer science background to participate - just a little programming knowledge and some problem solving skills will get you pretty far. Nor do you need a fancy computer; every problem has a solution that completes in at most 15 seconds on ten-year-old hardware.

The first puzzles will unlock on December 1st at midnight Eastern Time, which is very soon.

Looking forward to exchange thoughts and small hints ( NO FULL SOLUTIONS ).
If YOU think you MUST show us your code, otherwise you would die, PLEASE use the [spoiler ][/spoiler ] tags!


RE: Advent of Code 2019 - Gribouillis - Dec-01-2019

What's the point of solving the puzzles if you don't share your solutions?


RE: Advent of Code 2019 - perfringo - Dec-01-2019

I would say that first day tasks were very basic.

It's good to remember that no need for .strip() if converting single integer on row:

>>> int('5\n')
5



RE: Advent of Code 2019 - ThomasL - Dec-01-2019

(Dec-01-2019, 04:08 AM)Gribouillis Wrote: What's the point of solving the puzzles if you don't share your solutions?
Sharing is fine but i don´t want to be immediately spoilered opening this thread.
So everybody is invited to share their code but please use spoiler tags. :-)


RE: Advent of Code 2019 - perfringo - Dec-02-2019

My solutions for day # 1

I tried to scrape data directly from input page (https://adventofcode.com/2019/day/1/input) however I was getting 400 so I just copied data into text file.

Puzzle # 1:
'sum calculation result for every row in file'


Puzzle # 2 (used Python 3.8 and walrus operator)
'sum calculation results which are greater than zero for every row in file'




RE: Advent of Code 2019 - ThomasL - Dec-02-2019

I did puzzle one same way as perfringo.

For puzzle 2 i used a recursive approach as i´m still on python 3.7

My solutions for day 1:




RE: Advent of Code 2019 - snippsat - Dec-02-2019

(Dec-02-2019, 12:51 PM)perfringo Wrote: I tried to scrape data directly from input page (https://adventofcode.com/2019/day/1/input) however I was getting 400 so I just copied data into text file.
There is a way,could be a puzzle this to Wink
When logged in the session cookie will be same for all days input.
Find session cookie in browser(inspect header).
Example:



RE: Advent of Code 2019 - perfringo - Dec-02-2019

(Dec-02-2019, 01:17 PM)snippsat Wrote: There is a way,could be a puzzle this to Wink

Thank you!

Day #2 puzzles I did in the copy-paste style but next days will access data directly.

Puzzle #1:
'for every slice of four check for opcode and break or apply calculation'


Puzzle #2:
'find permutation pair producing target output and return calculated value'




RE: Advent of Code 2019 - perfringo - Dec-04-2019

Day #3

I was in real hurry with this one. So I decided to approach this 'systematically' in top-down style. I wanted to do some generator chaining but in order to get ready before my time was up I didn't follow this initial thought. Also - I did vectors decades ago, so I let shapely and numpy to do heavy lifting. This is brute-force and probably there is some math which allows to reach same result with less work.

Puzzel # 1:
'find intersection point with smallest Manhattan distance from start (0,0)'
For that:
  • read data from webpage
  • calculate relative moves
  • calculate path using relative moves
  • convert into shapely LineString
  • find all intersections
  • find smallest Manhattan distance from intersections
  • output smallest Manhattan distance


Puzzle # 2:
Intersection points were already found. So:
'Find smallest distance to intersection point' (function 'shortest_distance' in code above)


RE: Advent of Code 2019 - ndc85430 - Dec-15-2019

I've been doing the problems in Clojure, but broadly my solution for day 3 is in the same vein as described above. The solution for day 4 was pretty short, too. Clojure is a functional language, so my solutions have lots of recursion and higher order functions (map and reduce have featured, for example).