Author Topic: Advent of Code  (Read 112388 times)

Re: Advent of Code
« Reply #650 on: 07 December, 2018, 08:52:08 am »
Day 7: That was ok. Dependencies and scheduling.

What's scary, apart from the two syntax errors (missing parens), is both parts produced the correct answer first time without needing any tweaks.
"Yes please" said Squirrel "biscuits are our favourite things."

Ben T

Re: Advent of Code
« Reply #651 on: 07 December, 2018, 12:30:09 pm »
Done day 7 in Java but I might do it again in .NET with an actual thread to represent each worker.
https://github.com/bjtaylor1/AoC2018/blob/master/Day07/src/main/java/com/bjt/App.java

Re: Advent of Code
« Reply #652 on: 07 December, 2018, 01:17:11 pm »
Day 7: That was ok. Dependencies and scheduling.

What's scary, apart from the two syntax errors (missing parens), is both parts produced the correct answer first time without needing any tweaks.

Bah. I got the code correct but typed in the wrong starting parameters for part 2 then spent ages implementing a "fix" to the logic :(
Quote from: tiermat
that's not science, it's semantics.

Re: Advent of Code
« Reply #653 on: 08 December, 2018, 08:45:30 am »
Day 8. The first part didn't take me too long. For the second part, the example given didn't find a lot of the mistakes in my code.
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

Re: Advent of Code
« Reply #654 on: 08 December, 2018, 10:08:00 am »
Both bits of day 8 simple, made considerably easier by the fact that perl arrays automatically return a blank entry (interpreted as 0 in an integer context) for uninitialized elements, no need for any kind of bounds checking.

Was hoping for something a bit meatier at the weekend. We'll see tomorrow...
"Yes please" said Squirrel "biscuits are our favourite things."

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #655 on: 08 December, 2018, 10:41:33 am »
Day 8. The first part didn't take me too long. For the second part, the example given didn't find a lot of the mistakes in my code.
This - took a wee while for the code to run.
(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 #656 on: 08 December, 2018, 10:45:05 am »
And day 8 - the first really fun one. Ran extremely rapidly, so much so that I thought I had an error :)

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

Re: Advent of Code
« Reply #657 on: 08 December, 2018, 11:03:14 am »
(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 #658 on: 08 December, 2018, 12:17:46 pm »
(click to show/hide)
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #659 on: 08 December, 2018, 12:49:16 pm »
(click to show/hide)

The hardest part of that was understanding the instructions. My version was similar to yours with added fluff.

(click to show/hide)
Quote from: tiermat
that's not science, it's semantics.

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #660 on: 08 December, 2018, 11:19:47 pm »
OK, here is my python version for day 8 - not so different.
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #661 on: 09 December, 2018, 10:22:33 am »
Aha. Day 9 starts to make it really interesting.

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

Re: Advent of Code
« Reply #662 on: 09 December, 2018, 10:23:35 am »
(click to show/hide)

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

Re: Advent of Code
« Reply #663 on: 09 December, 2018, 11:29:32 am »
Part 1.

Frustrating out-by-one error gave the correct answer for all but one of the examples. Implementing the instructions as written, array-splicing all the way, ran in sub-second.

Part 2.

No idea. Times ten ran in about a minute. Times 100 - forget it. Can't see the pattern or formula.
Quote from: tiermat
that's not science, it's semantics.

Re: Advent of Code
« Reply #664 on: 09 December, 2018, 01:05:55 pm »
(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."

Re: Advent of Code
« Reply #665 on: 09 December, 2018, 05:29:28 pm »
Part 1.

Frustrating out-by-one error gave the correct answer for all but one of the examples. Implementing the instructions as written, array-splicing all the way, ran in sub-second.

Part 2.

No idea. Times ten ran in about a minute. Times 100 - forget it. Can't see the pattern or formula.

As above.

Put a progress counter on and realised that 100 times would take hours and hours.

Had to go out and do real stuff and it was done by the time I came home.

I also tried to code a time-saving routine but I didn't get that to work before I had to go out.

edit:- corrected my time-saving routine and it ran in about 20 minutes. It is still O(n2).
(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 #666 on: 09 December, 2018, 09:24:04 pm »
(click to show/hide)
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Ben T

Re: Advent of Code
« Reply #667 on: 09 December, 2018, 11:14:19 pm »
(click to show/hide)

similar to mine but C++ is far easier than plain C...
https://github.com/bjtaylor1/AoC2018/blob/master/Day09/Day09.cpp
 (link contains spoiler)

runs in a fraction of a second for my x100 input.

Re: Advent of Code
« Reply #668 on: 10 December, 2018, 08:46:58 am »
I found day 10 straightforward.

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

Ben T

Re: Advent of Code
« Reply #669 on: 10 December, 2018, 09:56:10 am »
I found day 10 straightforward.

(click to show/hide)

(click to show/hide)

Re: Advent of Code
« Reply #670 on: 10 December, 2018, 10:37:09 am »
(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."

Ben T

Re: Advent of Code
« Reply #671 on: 10 December, 2018, 11:12:12 am »
(click to show/hide)


Re: Advent of Code
« Reply #672 on: 10 December, 2018, 11:38:34 am »
(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."

Re: Advent of Code
« Reply #673 on: 10 December, 2018, 11:54:13 am »
(click to show/hide)
"Yes please" said Squirrel "biscuits are our favourite things."

Ben T

Re: Advent of Code
« Reply #674 on: 10 December, 2018, 11:55:47 am »
(click to show/hide)

(click to show/hide)