Author Topic: Advent of Code  (Read 111783 times)

red marley

Re: Advent of Code
« Reply #100 on: 14 December, 2015, 11:14:57 pm »
Finally found an answer to Day 12b (JSON parsing)

(click to show/hide)

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #101 on: 14 December, 2015, 11:23:47 pm »
processing.org seems to fit the bill

Thanks jo.

Will play after my trip to Germany.


(Thanks also Pancho for the perl suggestion.)
An alternative is the python Anaconda distribution and the Spyder IDE (which is what I have done most of mine in.)
"By creating we think. By living we learn" - Patrick Geddes

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #102 on: 14 December, 2015, 11:27:17 pm »
Finally found an answer to Day 12b (JSON parsing)

(click to show/hide)
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #103 on: 14 December, 2015, 11:31:31 pm »
Day 7

(click to show/hide)
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #104 on: 15 December, 2015, 12:12:05 am »
yay! finally up to date (well, at least until the next puzzle is released at 5 a.m  ;D).
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

Audax Club Mid-Essex Fire Safety Officer
http://acme.bike

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #105 on: 15 December, 2015, 12:22:53 am »
Finally found an answer to Day 12b (JSON parsing)

(click to show/hide)
(click to show/hide)

(click to show/hide)
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

Audax Club Mid-Essex Fire Safety Officer
http://acme.bike

red marley

Re: Advent of Code
« Reply #106 on: 15 December, 2015, 02:36:29 am »
Have just completed days 13 and 14, which seemed a bit easier than some of the earlier ones.

Day 13 (Table planning)

(click to show/hide)

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #107 on: 15 December, 2015, 01:16:08 pm »
Have just completed days 13 and 14, which seemed a bit easier than some of the earlier ones.

Day 13 (Table planning)

(click to show/hide)

I had a search for a more elegant way than my brute force approach but couldn't find a suitable one. My matrix math is not up to it and your graph theory is probably far better than mine.
"By creating we think. By living we learn" - Patrick Geddes

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #108 on: 15 December, 2015, 05:30:16 pm »
Really not happy with my solution to day 15.
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

red marley

Re: Advent of Code
« Reply #109 on: 15 December, 2015, 05:57:44 pm »
Day 15:

(click to show/hide)

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #110 on: 15 December, 2015, 06:06:48 pm »
You are correct - I was doing it in a bit of a rush between invigilation and marking.. Only 300 more scripts to go before then end of term.
"By creating we think. By living we learn" - Patrick Geddes

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #111 on: 15 December, 2015, 09:13:00 pm »
(click to show/hide)
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

Audax Club Mid-Essex Fire Safety Officer
http://acme.bike

Pingu

  • Put away those fiery biscuits!
  • Mrs Pingu's domestique
    • the Igloo
Re: Advent of Code
« Reply #112 on: 15 December, 2015, 09:39:50 pm »
Day 9a done eventually followed by 9b two minutes later.

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #113 on: 15 December, 2015, 09:55:59 pm »
(click to show/hide)

(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Pingu

  • Put away those fiery biscuits!
  • Mrs Pingu's domestique
    • the Igloo
Re: Advent of Code
« Reply #114 on: 15 December, 2015, 10:28:35 pm »
Day 10 done. What a contrast with day 9.

red marley

Re: Advent of Code
« Reply #115 on: 16 December, 2015, 08:40:07 am »
Day 16

(click to show/hide)

According to Eric Wastl (the Advent of Code author), today was the last of the "easy" ones.

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #116 on: 16 December, 2015, 10:41:53 am »
Day 16

(click to show/hide)

According to Eric Wastl (the Advent of Code author), today was the last of the "easy" ones.

(click to show/hide)
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

Audax Club Mid-Essex Fire Safety Officer
http://acme.bike

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #117 on: 16 December, 2015, 09:33:34 pm »
(click to show/hide)
Today was very easy. I dread tomorrow.
"By creating we think. By living we learn" - Patrick Geddes

red marley

Re: Advent of Code
« Reply #118 on: 16 December, 2015, 10:05:37 pm »
David, that's a more elegant approach than mine. My instinct tends towards 'grab all the data and structure it, then start processing'. I think this comes from my usual need to visualise data. But it makes much more sense in this context to follow your approach.

As with almost all of the puzzles so far, in practice the data volumes involved mean that inefficient storage or processing hungry algorithms can be tolerated. I suspect this will change from the 17th onwards.

I am trying to resist the temptation to come up with a speedy answer early in the morning to get posted on the leader board (mostly because I am not speedy enough). But I do wonder whether anyone is going to be spending an antisocial Christmas morning coding in order to make it to the head of the final leader board (I certainly won't be).

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #119 on: 16 December, 2015, 10:10:19 pm »
Only if you can get up early enough :)

Your line of work is based around visualising all the data - a lot of mine is stream parsing and quality filtering. I took the view that filtering out what I didn't want and seeing what was left would be the easier option.

Anyhow, tomorrow will be a toss up between marking stats reports, planning next semester's course (don't ask why it is so late) and doing the Advent of Code.

Being less than elegant I hard-coded the parse rules.

(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #120 on: 17 December, 2015, 08:07:35 am »
Day 17 required some thought but very few lines of code.
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #121 on: 17 December, 2015, 09:56:39 am »
Day 17 required some thought but very few lines of code.
(click to show/hide)

(click to show/hide)
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

Audax Club Mid-Essex Fire Safety Officer
http://acme.bike

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #122 on: 17 December, 2015, 11:20:14 am »
That was one option. I just happen to like recursion. It took a few seconds to ru, if that. (longer to write than to run).
"By creating we think. By living we learn" - Patrick Geddes

Feanor

  • It's mostly downhill from here.
Re: Advent of Code
« Reply #123 on: 17 December, 2015, 11:32:34 am »
Elegant as it is, you need to be careful with recursion because every time you re-enter a subroutine, the previous context is pushed onto the stack.

The stack will build and build as you recurse down, and only when (if!) you reach the bottom of the rabbit-hole and start returning do you begin to pop stuff off the stack.

So unless you know there's a limit on how deeply you will be recursing, you run a risk of stack overflow.
It's a fairly small risk with modern OSes, as the stack allocation is usually quite generous, but it is a limit to be aware of.

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #124 on: 17 December, 2015, 11:49:56 am »
In this case the recursion limit is the tree depth which is the length of the list. So not a problem. If it was an optimisation I'd have some convergence criteria.
"By creating we think. By living we learn" - Patrick Geddes