Author Topic: Advent of Code  (Read 111701 times)

Re: Advent of Code
« Reply #400 on: 03 December, 2017, 06:47:56 pm »
That's the thing with a lot of these - if you short-circuit part 1, you find part 2 needs the data from part 1.

Or if you don't short-circuit part 1 you find that part 2 involves computing something so big that it would take the naive algorithm years to finish so you do need to short-circuit it.

Most of the time (having just gone back and done the whole of 2016 and 2015 over the last few days) whatever I do in part (a) is usually the wrong one. I guess this is no coincidence.

The second part I used a dynamic programming approach and promptly filled it so full of bugs it took a long time to wrangle out. Was there a more elegant way that I somehow missed?

2017.3.b spoiler:-

(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."

Re: Advent of Code
« Reply #401 on: 03 December, 2017, 07:08:48 pm »
That's the thing with a lot of these - if you short-circuit part 1, you find part 2 needs the data from part 1.

Or if you don't short-circuit part 1 you find that part 2 involves computing something so big that it would take the naive algorithm years to finish so you do need to short-circuit it.

Most of the time (having just gone back and done the whole of 2016 and 2015 over the last few days) whatever I do in part (a) is usually the wrong one. I guess this is no coincidence.

Yes, that's what makes these so much fun. I can solve it this way... or that way... which way is going to help in part 2?
Quote from: tiermat
that's not science, it's semantics.

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #402 on: 03 December, 2017, 08:55:04 pm »
I suppose I just had a function that mapped the 2D onto the 1D array and went from there. I went back and checked and despite the dynamic programming, I still calculated every value.

"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 #403 on: 03 December, 2017, 09:35:08 pm »
Didn't get to doing today's until this evening owing to family visiting plus putting up the Christmas decorations.

(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

Re: Advent of Code
« Reply #404 on: 03 December, 2017, 11:13:57 pm »
(click to show/hide)
I used the same method.

(click to show/hide)

I did part one without programming, just a text editor for notes and a calculator.

BTW, I'm mtrak
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

Re: Advent of Code
« Reply #405 on: 04 December, 2017, 08:40:06 am »
Was hoping for a meaty one today but no.

Still, I've got some of the older ones to revisit and make work more efficiently.
"Yes please" said Squirrel "biscuits are our favourite things."

Re: Advent of Code
« Reply #406 on: 04 December, 2017, 10:23:15 am »
I'm impressed you rattled though the 2015 and 2016 ones so quickly. I seem to recall the Isotope lifts problem, the Wizard Spells game and Medicine for Rudolph problems taking quite some effort.

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #407 on: 04 December, 2017, 10:54:46 am »
Today's was very much a start of week 1 problem.
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #408 on: 04 December, 2017, 11:05:33 am »
isotope lift
(click to show/hide)

wizard spells I spent a fair while on as I had an annoying bug (one of my effects lasted for the wrong number of turns) - when I finally sorted that I had also missed the fact that you had to cast an effect on every turn, and my code allowed nothing to be done on a turn (with my input you got a lower score if you did nothing on the last turn as the poison spell was still in effect)

Another reminder to READ THE DESCRIPTION PROPERLY!

medicine for rudolph : maybe I was lucky...
(click to show/hide)

This kind of challenge (as in AoC) is exactly my kind of thing though. I've been coding as a job for 20+ years and have degrees in both Comp Sci and Maths, I've also done many of the Valladolid Online Judge (https://uva.onlinejudge.org/) programming challenges too so many of the concepts I've covered before.
"Yes please" said Squirrel "biscuits are our favourite things."

Re: Advent of Code
« Reply #409 on: 04 December, 2017, 11:20:04 am »
Medicine for Rudolph (Day 19, 2015)

(click to show/hide)

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #410 on: 04 December, 2017, 11:58:23 am »
Today's was very much a start of week 1 problem.
(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 #411 on: 04 December, 2017, 11:07:28 pm »
My pandas fu is not that developed.
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #412 on: 05 December, 2017, 06:38:14 am »
Day 5 seemed quite straightforward.

(click to show/hide)
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

Re: Advent of Code
« Reply #413 on: 05 December, 2017, 07:51:57 am »
At this point the private leaderboard is more about who gets up earliest than anything else. (7.30am is the earliest I'll ever be in front of a computer.)

(Not grumbling, the trickier problems will come...)
"Yes please" said Squirrel "biscuits are our favourite things."

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #414 on: 05 December, 2017, 10:54:01 am »
Indeed. I appear to be 4th up in the morning.

I was idly thinking on whether there was a trivial way to determine the result from the values in the steps. I am led to believe it is pretty close to an ideal turing machine and therefore you only know if it will stop when it does, so there is no way to know the number of interations from the instructions without playing them out.
"By creating we think. By living we learn" - Patrick Geddes

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #415 on: 06 December, 2017, 07:35:37 am »
For day 6, the brute force is obvious, but I was wondering whether there is a more elegant way to do it.
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #416 on: 06 December, 2017, 08:07:03 am »
Day 6:

(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #417 on: 06 December, 2017, 11:06:02 am »
Day 6:
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #418 on: 06 December, 2017, 04:16:30 pm »
Day 6
The debugging output for my code had basically solved part 2 by the time that I had solved part 1
(click to show/hide)
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #419 on: 06 December, 2017, 05:00:15 pm »
Day 6
The debugging output for my code had basically solved part 2 by the time that I had solved part 1
(click to show/hide)
very similar
(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 #420 on: 06 December, 2017, 05:10:38 pm »
Day 6
The debugging output for my code had basically solved part 2 by the time that I had solved part 1
(click to show/hide)
very similar
(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

Re: Advent of Code
« Reply #421 on: 06 December, 2017, 08:16:45 pm »
Day 6
The debugging output for my code had basically solved part 2 by the time that I had solved part 1
(click to show/hide)
very similar
(click to show/hide)

(click to show/hide)
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #422 on: 07 December, 2017, 07:54:45 am »
That was a bit more satisfying.. Note: read the text more carefully.
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #423 on: 07 December, 2017, 10:03:30 am »
Indeed, that's a bit better.

It's the first one (of 2017) where I've had to write psuedo-code first and then flesh it out, rather than knowing what to do straight from the start.
"Yes please" said Squirrel "biscuits are our favourite things."

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #424 on: 07 December, 2017, 10:37:36 am »
The pattern and approach was quite straightforward. Better if I read the instructions for part 2 and deliver what was asked. No need for pseudo code.
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes