Author Topic: Advent of Code  (Read 112364 times)

Ben T

Re: Advent of Code
« Reply #375 on: 24 December, 2016, 05:40:46 pm »
Less than a second including calc of leg lengths?? If so mine must be inefficient then as that takes about 5 seconds per leg. Only reason could be that it is plodding along one square at a time rather than going as far as possible with each movement. But optimizing probably unnecessary...

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #376 on: 24 December, 2016, 09:13:09 pm »
(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 #377 on: 25 December, 2016, 12:22:19 pm »
Today's is quite fun.

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

Ben T

Re: Advent of Code
« Reply #378 on: 25 December, 2016, 01:22:42 pm »
(click to show/hide)

or slightly more terse but less calculation:
(click to show/hide)

Re: Advent of Code
« Reply #379 on: 26 December, 2016, 09:49:35 pm »
day 19 part 1:
(click to show/hide)

I know I'm a bit behind the times (computer downtime). I liked this one too, it's clear there's an analytic solution - every second elf loses his presents. But the problem as presented looks like a queue, so I coded it in that spirit:
(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 #380 on: 26 December, 2016, 09:51:47 pm »
Very neat.
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #381 on: 26 December, 2016, 10:30:58 pm »
Thank you.  :)

Perl's lists/arrays are optimised for use as queues, so repeated push/pop/shift/unshift does not create a massive realloc fest. Unfortunately, removing an element from the middle is something else entirely, so part 2 in the same vein

(click to show/hide)

takes rather a long time...
Quote from: tiermat
that's not science, it's semantics.

Ben T

Re: Advent of Code
« Reply #382 on: 29 December, 2016, 03:51:17 pm »
Withdrawal symptoms?
I've found this website https://projecteuler.net which offers a multitude of problems some of which appear to solvable by programming.
Some are quite interesting, e.g. this one https://projecteuler.net/problem=575 which I've managed to solve.
A lot seem very maths-heavy e.g. about sets of prime  numbers and the like, but they do appear to be simple from a brute force point of view but then you are asked from a number very high in the sequence, so either mathematical knowledge and/or heavy optimization or realizing some vast simplification is required.

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #383 on: 30 November, 2017, 12:46:51 pm »
2017 AoC in about 16 hours time! :)
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 #384 on: 30 November, 2017, 01:17:00 pm »
ooh, signed up

(And going back and doing 2016 as practice...)
"Yes please" said Squirrel "biscuits are our favourite things."

Re: Advent of Code
« Reply #385 on: 30 November, 2017, 07:51:42 pm »
2017 AoC in about 16 hours time! :)
Arrgghhh!

December productivity will be at it's usual post 2015 levels.
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #386 on: 01 December, 2017, 12:03:08 am »
That's the marking taking a back seat then.

Is there a YACF league?
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #387 on: 01 December, 2017, 06:27:38 am »
From previous years, the YACF leaderboard code is 48462-ea506236

Re: Advent of Code
« Reply #388 on: 01 December, 2017, 10:55:06 am »
Enjoyed that, once I'd remembered to read the question properly.

Am using PHP just because that's what I happen to use daily.

D.
Somewhat of a professional tea drinker.


Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #389 on: 01 December, 2017, 01:03:09 pm »
I'm using Python again,  trying to use Pandas/numpy wherever possible.

(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 #390 on: 01 December, 2017, 03:03:31 pm »
Done today's using VBA. Tomorrow I'll try python.
Clever enough to know I'm not clever enough.

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #391 on: 01 December, 2017, 05:41:21 pm »
I'm using Python again,  trying to use Pandas/numpy wherever possible.

(click to show/hide)
Interesting - I'd not seen that.
The second part is a special case
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #392 on: 01 December, 2017, 06:49:45 pm »
Ah yes, well spotted. A language that supports negative array indices is hinted by part one, and helps for part 2.

58 keystrokes. Anyone manage fewer?
Quote from: tiermat
that's not science, it's semantics.

Re: Advent of Code
« Reply #393 on: 01 December, 2017, 08:18:00 pm »
ooh, signed up

(And going back and doing 2016 as practice...)

2016 done, will move on to 2015 too.

Doing all of mine in Perl as that's what I use for quick hacks and prototypes.
"Yes please" said Squirrel "biscuits are our favourite things."

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #394 on: 01 December, 2017, 09:09:44 pm »
Ah yes, well spotted. A language that supports negative array indices is hinted by part one, and helps for part 2.

58 keystrokes. Anyone manage fewer?
I presume that is CTRL-C/CTRL-V to copy and paste the original data? And is that one part or both parts.
81 characters, but some are spaces.
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #395 on: 01 December, 2017, 09:42:12 pm »
ok, I didn't include the data or printing out the answer. Fully working solution is 64 characters for part 1 and 67 characters for part 2

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

Re: Advent of Code
« Reply #396 on: 02 December, 2017, 12:17:57 am »
2016 done, will move on to 2015 too.

Doing all of mine in Perl as that's what I use for quick hacks and prototypes.

Ugh, enough for now, done up to (and including day 16 of 2015).
"Yes please" said Squirrel "biscuits are our favourite things."

Re: Advent of Code
« Reply #397 on: 03 December, 2017, 11:40:50 am »
It's started to get more interesting today. Only day 3, is this year going to be a tough one?

Out of interest, who are Phong and mTrak? I'm iakobski.
Quote from: tiermat
that's not science, it's semantics.

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #398 on: 03 December, 2017, 04:14:09 pm »
That was painful. The first part was elementary maths - no code needed.
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?

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

Re: Advent of Code
« Reply #399 on: 03 December, 2017, 05:31:23 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.

I built the whole grid in part 1, even though it was obvious there would be a clever way round that, so adding on a value to each point was trivial.

However my first attempt using recursion succeeded only in turning my laptop into a lap-heater, who knew that recursing several of hundreds deep on each point was not the best use of cpu cycles  :facepalm:
Quote from: tiermat
that's not science, it's semantics.