Yet Another Cycling Forum

General Category => The Knowledge => Ctrl-Alt-Del => Topic started by: Afasoas on December 10, 2015, 08:09:29 pm

Title: Advent of Code
Post by: Afasoas on December 10, 2015, 08:09:29 pm
10 days late discovering this, but what a little gem it is.
A Christmas themed two-part puzzle to be solved in code for each day of advent.

http://adventofcode.com/

I've had a crack at day 1 and 2 in PowerShell.
https://github.com/biscuitNinja/AdventOfCode

You can do it in any language of your choice.
Title: Re: Advent of Code
Post by: Ben T on December 10, 2015, 09:57:02 pm

made a bit of a meal of that  ;)
https://github.com/bjtaylor1/AdventOfCode/blob/master/Day1.ps1
Title: Re: Advent of Code
Post by: David Martin on December 10, 2015, 10:25:14 pm
Done days 1-3 so far. Straightforward if you read the instructions. I misread day 3 as 'more than 1 present'.

Title: Re: Advent of Code
Post by: David Martin on December 10, 2015, 10:53:26 pm
4b is nasty. It is taking a while to bruteforce.
Title: Re: Advent of Code
Post by: Afasoas on December 10, 2015, 10:58:04 pm
Ben T, if we were Golfing (https://en.wikipedia.org/wiki/Code_golf) you'd have beaten me on day 1 :)
I've just seen a version of Day 3 done as a one liner in PERL.

Day 4 looks interesting ... "AdventCoins"
Title: Re: Advent of Code
Post by: David Martin on December 11, 2015, 12:10:36 am
What was the one liner? I'm fairly sure I can see how to do it but it is probably somewhat obfuscated.

4b is still running. Maybe I was unlucky.
Title: Re: Advent of Code
Post by: Afasoas on December 11, 2015, 07:27:36 am
What was the one liner? I'm fairly sure I can see how to do it but it is probably somewhat obfuscated.

https://www.reddit.com/r/adventofcode/comments/3v8roh/day_3_solutions/cxmc1h2

4b is still running. Maybe I was unlucky.

Still crunching away with this too. It's only using 15% CPU .. I'm wondering if a parallel foreach might have been better...
Title: Re: Advent of Code
Post by: David Martin on December 11, 2015, 08:50:30 am
What was the one liner? I'm fairly sure I can see how to do it but it is probably somewhat obfuscated.

https://www.reddit.com/r/adventofcode/comments/3v8roh/day_3_solutions/cxmc1h2

That's not really a one-liner. It's about as much as I wrote in Python.

Ready to have a crack at 7, the rest have been straightforward.
Title: Re: Advent of Code
Post by: Ben T on December 11, 2015, 09:06:14 am
4b is nasty. It is taking a while to bruteforce.
Do you know for a fact that bruteforce is the only way?
Title: Re: Advent of Code
Post by: David Martin on December 11, 2015, 10:18:21 am
It takes a very long time if you have a silly bug in your code :embarassed: Done.
Title: Re: Advent of Code
Post by: Pingu on December 11, 2015, 10:56:52 am
Did 1a & 1b with javascript  :P
Title: Re: Advent of Code
Post by: Ben T on December 11, 2015, 11:38:09 am
It appears day 3 can be solved  by munging a 2D space into a 1D one using prime numbers :)
https://github.com/bjtaylor1/AdventOfCode/blob/master/Day3.ps1
Title: Re: Advent of Code
Post by: red marley on December 11, 2015, 11:55:24 am
For those of us who have come to this late (and thanks Afasoas for point to it), can specific approaches to the solutions be put in spoiler tags please?
Title: Re: Advent of Code
Post by: David Martin on December 11, 2015, 12:15:58 pm
It appears day 3 can be solved  by munging a 2D space into a 1D one using prime numbers :)
https://github.com/bjtaylor1/AdventOfCode/blob/master/Day3.ps1

(click to show/hide)
Title: Re: Advent of Code
Post by: Mr Larrington on December 11, 2015, 12:28:48 pm
I no longer have access to a VMS Fortran compiler so that's me stuffed ;D
Title: Re: Advent of Code
Post by: Pancho on December 11, 2015, 12:31:40 pm
Quick - recommend me a programming language (and tools) that an old duffer can use!

A few years back (on another computer) I think I installed python (IIRC - could have been something else) and actually managed to get it to interact with Openstreetmap to draw a map with a particular bus route. IIRC, it was surprisingly easy.

Firstly, a really stupid question - how can I tell if I've already got python installed (Ubuntu is the operating sys and I've found "Terminal" gives me a Ye Olde terminal)?

VMT
Title: Re: Advent of Code
Post by: Ben T on December 11, 2015, 12:42:08 pm
It appears day 3 can be solved  by munging a 2D space into a 1D one using prime numbers :)
https://github.com/bjtaylor1/AdventOfCode/blob/master/Day3.ps1

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Afasoas on December 11, 2015, 12:44:26 pm
If you're using Windows, PowerShell is readily available. You could use Python, perl, ruby - the problem is choosing a language.
If you want an IDE you could try Microsoft's Code and then relevant plugin's for your language of choice.

The second link in the OP are my feeble attempts thus far.

Title: Re: Advent of Code
Post by: Pancho on December 11, 2015, 12:56:54 pm
Quick - recommend me a programming language (and tools) that an old duffer can use!

A few years back (on another computer) I think I installed python (IIRC - could have been something else) and actually managed to get it to interact with Openstreetmap to draw a map with a particular bus route. IIRC, it was surprisingly easy.

Firstly, a really stupid question - how can I tell if I've already got python installed (Ubuntu is the operating sys and I've found "Terminal" gives me a Ye Olde terminal)?

VMT

Maybe it wasn't python. Maybe it was perl - I've found I've managed to get a perl manual up on this machine so I prob have it installed already!

Think I'll have a coffee and then set about learning how compiling and running works these days. Then I'll try and learn perl. Then I'll try and do December 1st.
Title: Re: Advent of Code
Post by: Afasoas on December 11, 2015, 01:04:01 pm
Just running "python -V" will give you the version number.

Code: [Select]
user@cinelli ~ $ python -V
Python 2.7.6
Title: Re: Advent of Code
Post by: David Martin on December 11, 2015, 01:35:12 pm

(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 11, 2015, 01:37:42 pm
Dec 1st is extremely simple and should be achievable after lesson 1 of a python course (if they start with string manipulation)
1b could be optimised if you think about how far away you are from where you want to be.
Title: Re: Advent of Code
Post by: red marley on December 11, 2015, 02:56:45 pm
I like the fact that the second part of each day is not revealed until submitting an answer to the first. That way we are encouraged to think about solutions that might be a little more generalisable.

However for Day 3...
(click to show/hide)
Title: Re: Advent of Code
Post by: Pancho on December 11, 2015, 03:25:03 pm
Well, I haven't even figured out how to bring a file in a character at a time yet!
Title: Re: Advent of Code
Post by: Ben T on December 11, 2015, 03:27:09 pm
I like the fact that the second part of each day is not revealed until submitting an answer to the first. That way we are encouraged to think about solutions that might be a little more generalisable.

However for Day 3...
(click to show/hide)
Rule of agile: do as little work as possible. ;)

I didn't even know an extra  bit appeared.... but hardly any modification required however: https://github.com/bjtaylor1/AdventOfCode/blob/master/Day3b.ps1

Title: Re: Advent of Code
Post by: Ben T on December 11, 2015, 03:34:28 pm

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

I agree ;) , but, is there not a condition you could place on the primes  to guarantee it?
My initial 'hunch' was that that condition would be
p1>n AND p2 > n
I have absolutely no idea how to prove that however.
Thinking about it however
would
p1 > p2  x n AND p2 > n
not guarantee it?
Again, no idea how to prove, just a hunch

Can you disprove it?
so if, say,  n = 10, I would choose primes 11 and 113...
i.e. 11 > 10 and 113 > 10* 11.
what moves (values of m1 and m2) would cause a hash collision i.e. such that
m1 * p1 = m2 * p2
where
m1 <= 10
m2 <= 10
p1 = 11
p2 = 113
?
How to prove there are no such values of m1 and m2?
If  I place  that condition do they even need to be prime?
Title: Re: Advent of Code
Post by: Afasoas on December 11, 2015, 03:42:41 pm
Well, I haven't even figured out how to bring a file in a character at a time yet!
http://code.activestate.com/recipes/65118-processing-a-string-one-character-at-a-time/
Title: Re: Advent of Code
Post by: Pancho on December 11, 2015, 04:48:09 pm
YES!!! YES!!! YES!!!

I've done Day 1! Learned about command line again. Learned about Linux commands. Found "perl", got it running. Tried, tried, and tried again.

And got this (the most shockingly skanky code ever written - but it works!):

(click to show/hide)
Title: Re: Advent of Code
Post by: Pancho on December 11, 2015, 04:50:08 pm
Whoops.

It seems I've only done Part 1 of Day 1. Back to the grindstone.
Title: Re: Advent of Code
Post by: David Martin on December 11, 2015, 05:09:14 pm
Invigilating a 3 hour exam allowed the time to get through days 7, 8 and 9.

7 was the hardest, 8 was tricky, 9 easy to bruteforce.

To solve 7:
(click to show/hide)

I may steal some of these for interview questions.
Title: Re: Advent of Code
Post by: Pingu on December 11, 2015, 06:48:03 pm
Day 2 done in a spreadsheet  :demon:
Title: Re: Advent of Code
Post by: JonBuoy on December 11, 2015, 07:11:18 pm
Part 1 of Day 1 done in a word processor   :demon:
Title: Re: Advent of Code
Post by: Pingu on December 11, 2015, 07:22:24 pm
Day 3 done (javascript).
Title: Re: Advent of Code
Post by: David Martin on December 11, 2015, 07:37:48 pm
Waiting for 10b to finish running.
Title: Re: Advent of Code
Post by: Pancho on December 11, 2015, 08:33:06 pm
Still trying to work out how to do arrays.
Title: Re: Advent of Code
Post by: David Martin on December 11, 2015, 10:34:50 pm
10b finished. I was pondering on how best to write the code for 11 but ended up solving both parts by inspection (and only one failed attempt out of 3)
Title: Re: Advent of Code
Post by: David Martin on December 11, 2015, 10:37:14 pm
Still trying to work out how to do arrays.
In perl? Clues to a solution included.
(click to show/hide)


Title: Re: Advent of Code
Post by: red marley on December 11, 2015, 11:23:40 pm
4b is still running. Maybe I was unlucky.

Still crunching away with this too. It's only using 15% CPU .. I'm wondering if a parallel foreach might have been better...

Day 4 (MD5)
(click to show/hide)
Title: Re: Advent of Code
Post by: Pingu on December 11, 2015, 11:34:09 pm
Day 4 done. It helps when you search for the correct string. "000000" has six characters  :facepalm:
Title: Re: Advent of Code
Post by: David Martin on December 11, 2015, 11:35:58 pm
4b is still running. Maybe I was unlucky.

Still crunching away with this too. It's only using 15% CPU .. I'm wondering if a parallel foreach might have been better...

Day 4 (MD5)
(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 11, 2015, 11:36:45 pm
Day 4 done. It helps when you search for the correct string. "000000" has six characters  :facepalm:
You and me both..
Title: Re: Advent of Code
Post by: Oaky on December 12, 2015, 12:35:33 am
Just started this today.  I did 1 and 2 (chose Python, mainly because I learnt it fairly recently, but it fell into disuse and I wanted to blow some cobwebs away).

Was particularly chuffed with (2) because the approach I took fro part a turned out to be trivially extensible for part b.  The meat of which is this:-

(click to show/hide)

the full code (including a few test cases) is here:-

(click to show/hide)
Title: Re: Advent of Code
Post by: Pancho on December 12, 2015, 09:43:24 am
OK, I really didn't want to ask for help - but I'm really stumped. Still on Day 2 Part 1!

In my defence, I am learning everything on the job - from command line linux, use of editors, through to the actual language itself. Solving the problems, as you can see, are a long way down the line.

Anyway, I've done this (please excuse all the comments (I'd get lost without them) and the "print" diagnostics (don't have a debugger)):

(click to show/hide)

Everything seems to work except my calculation of the "slack" paper needed. The sort function works (well, now it does - apparently it doesn't sort numbers without that bit of extra code - took me a long time to work that out) and I take the two lowest and multiply them together - and get guff!

Maybe it's confusing text and numbers? But why does it work for the other instances of multiplication?

Baffled and stuck - help required!

VMT.
Title: Re: Advent of Code
Post by: red marley on December 12, 2015, 09:56:13 am
Pancho, I don't know much about Perl so can't help you there, but here's a hint on the algorithm...

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 12, 2015, 10:07:00 am
The code seems to run for me (once the filename is changed) and seems to give a credible answer. It is going round the houses a long way, looping through the data twice.

Title: Re: Advent of Code
Post by: David Martin on December 12, 2015, 10:14:42 am
Day 12 first part is trivial for a unix hacker. The second part means the quick solution to part A is not extensible but you have to have a proper parser.
Title: Re: Advent of Code
Post by: Pancho on December 12, 2015, 10:21:01 am
Quote
The code seems to run for me (once the filename is changed) and seems to give a credible answer. It is going round the houses a long way, looping through the data twice.

The reason for going round the houses is simply because I have to test everything step by step as I've no idea how things (even loops) actually work. It took me a long time to work out how to load in data so I got that working first. Then I had to work out how to manipulate arrays - but didn't want to muck up the bit I'd got working!

Also, it feels tidier to do things in chunks. Set up some arrays. Load them from a file. Do stuff with them. If you mung all that together, it gets terribly confusing terribly rapidly (well, to an old codger like me).

I spent a long time down a dead-end route. Tried to set up a multi-dimensional array to hold everything but multi-dimensional arrays seemed to be unnecessarily complex so gave up. But I'd still rather have all the data for Parcel x held in ParcelData (ParcelID, Length, Width, Height, Area, Slack).

Anyway, if it broadly works for you, WTF does it tell me:

 (Parcel : 0   L: 3 W: 11 H: 24 A: 738 S: 33738) ?
Title: Re: Advent of Code
Post by: Pancho on December 12, 2015, 10:37:31 am
And yet, when I sum up all the Slacks, it gives a believable answer?

Which turns out to be the correct answer.

Must be something to do with my diagnostic print statements. But I'm stuffed if I know what.

Anyway, on to Day 2, Part 2.
Title: Re: Advent of Code
Post by: Afasoas on December 12, 2015, 11:48:15 am
Day 4 done. It helps when you search for the correct string. "000000" has six characters  :facepalm:
You and me both..

+1 .. :/
Title: Re: Advent of Code
Post by: Pingu on December 12, 2015, 12:15:37 pm
Day 4 done. It helps when you search for the correct string. "000000" has six characters  :facepalm:
You and me both..

+1 .. :/

Is that some sort of regex?
Title: Re: Advent of Code
Post by: Pancho on December 12, 2015, 12:28:51 pm
Day 3 has got me puzzling. There must be a quicker way of doing it than just moving around a virtual x and y grid. Something to do with summing up all the moves or something.

But it's beyond my brain to figure it out.

So, I'm sticking with trekking a counter around a virtual board. Which will take me long enough to actually programme - it's taken me this long to work out how to get hold of one character at a time.
Title: Re: Advent of Code
Post by: red marley on December 12, 2015, 12:37:57 pm
Day 3 hint

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 12, 2015, 12:38:29 pm
Day 3. I think you have to remember where you have been.
(click to show/hide)
Title: Re: Advent of Code
Post by: Pingu on December 12, 2015, 01:31:24 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Pancho on December 12, 2015, 01:50:03 pm
Cracked Day 3 Part 1:

(click to show/hide)

It works but I get shedloads of warnings about unitialised values. I've tried to stop that but failed.
Title: Re: Advent of Code
Post by: Pancho on December 12, 2015, 01:51:48 pm
I'd deliberately not looked at the hints until now as I wasn't fully stuck.

I think I've sort of done what you describe - but differently.
Title: Re: Advent of Code
Post by: Pancho on December 12, 2015, 02:11:14 pm
3b's in the bag - and I've done my first subroutines (santamove, and robomove!).
Title: Re: Advent of Code
Post by: Pancho on December 12, 2015, 02:39:33 pm
I don't even understand the question for Day 4. Well, I do a bit - I vaguely remember some of the jargon.

I'll spend some time on google - that usually cures all ignorance.

But, at first glance, it's either stupidly difficult (write code to do MD5 hashing (whatever that is)) or just boring (keep chucking numbers into existing MD5 functions until you get one back with the appropriate number of zeroes. It's possible I've misunderstood!
Title: Re: Advent of Code
Post by: red marley on December 12, 2015, 03:04:33 pm
MD5 hashing isn't that different in principle to what you did for Day 3. Hashing is just a transformation of some collection of data (e.g. the row and column representing Santa's location) into a single number known as a hash. The key to making the hashing transformation useful is that you want to be pretty sure that the same original data always gives the same hash, and that data collections that are different give different hashes.

The MD5 and other cryptographic hash transformations have the additional property that given the hash, you cannot easily retrieve the original data. It is now known how to break the MD5 hashing such that you can retrieve the original data, but for the purposes of this advent exercise, that's not necessary.

(click to show/hide)
Title: Re: Advent of Code
Post by: Afasoas on December 12, 2015, 03:26:07 pm
Just catching up. Day 5 with some regular expressions.
A bit of regex solves anything :)

(click to show/hide)
Title: Re: Advent of Code
Post by: Pingu on December 12, 2015, 03:54:22 pm
Just catching up. Day 5 with some regular expressions.
A bit of regex solves anything :)

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Pingu on December 12, 2015, 03:55:35 pm
Day 5 done.
Title: Re: Advent of Code
Post by: red marley on December 12, 2015, 04:13:25 pm
I've set up a 'private leaderboard' for YACF if anyone wishes to join it. The access code is 48462-ea506236
Title: Re: Advent of Code
Post by: Pancho on December 12, 2015, 04:26:22 pm
I've set up a 'private leaderboard' for YACF if anyone wishes to join it. The access code is 48462-ea506236

I think I must have hit the anon login option as I have the memorable moniker of "anonymous user #49001".
Title: Re: Advent of Code
Post by: red marley on December 12, 2015, 04:43:20 pm
Should you wish, you can change this to whatever name you use for authenticating access to the Advent site through the 'settings' option.
Title: Re: Advent of Code
Post by: red marley on December 12, 2015, 04:45:14 pm
Not necessary for completing the task, but as I like drawing pictures this is the pattern of lights for my version of Day 6 part b:

(http://staff.city.ac.uk/~jwo/acf/adventLights.jpg)
Title: Re: Advent of Code
Post by: Pancho on December 12, 2015, 05:42:59 pm
I've got to out now so can't do any more this eve :(

Also tomorrow's out as I'm picking up my daughter from the airport after 4 months away from home :)
Title: Re: Advent of Code
Post by: Diver300 on December 12, 2015, 06:46:30 pm
Days 1 - 3 solved using spreadsheets.

It's not efficient and the computer struggles to run the spreadsheets.
Title: Re: Advent of Code
Post by: David Martin on December 12, 2015, 10:48:12 pm
Days 1 - 3 solved using spreadsheets.

It's not efficient and the computer struggles to run the spreadsheets.
Tht sounds like masochism. Just becasue you can, doesn't mean you should. You may find Day 4 a bit hard to do on a spreadsheet.
Title: Re: Advent of Code
Post by: Kim on December 12, 2015, 10:59:59 pm
I ended up simulating neural networks using speadsheets for my final year research project (because reasons).  I wouldn't recommend it, unless you specifically want to make Clippy cry, but it's amazing what you can abuse them for if you're sufficiently determined/desperate/masochistic.
Title: Re: Advent of Code
Post by: Diver300 on December 13, 2015, 10:02:05 am
My reusability of code fell down flat.
Part 5a solved on a spreadsheet
Part 5b used javascipt

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 13, 2015, 10:15:33 am
Not necessary for completing the task, but as I like drawing pictures this is the pattern of lights for my version of Day 6 part b:

(http://staff.city.ac.uk/~jwo/acf/adventLights.jpg)

(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 13, 2015, 10:19:25 am
(click to show/hide)

You could have, but I believe each dataset is unique to your ID, so it wouldn't have got you very far.
Title: Re: Advent of Code
Post by: Pingu on December 13, 2015, 12:06:39 pm
I must be missing something obvious in 6a. It doesn't look that difficult, but I'm not getting the right answer. My code seems to work for small data sets, but fails for the full problem set.
Title: Re: Advent of Code
Post by: David Martin on December 13, 2015, 01:23:10 pm
I must be missing something obvious in 6a. It doesn't look that difficult, but I'm not getting the right answer. My code seems to work for small data sets, but fails for the full problem set.
Off by one error somewhere?

I reverted to building a 2D matrix in numpy

I couldn't readily work out an elegant way of solving 11, and by the time I had thought about how to solve it I already had by inspection.

..d
Title: Re: Advent of Code
Post by: Pingu on December 13, 2015, 01:40:25 pm
I must be missing something obvious in 6a. It doesn't look that difficult, but I'm not getting the right answer. My code seems to work for small data sets, but fails for the full problem set.
Off by one error somewhere?

Maybe, but I can't see where.

Would someone who's done 6a like to try it with my data set and let me know what you get? Here's the set:

turn off 660,55 through 986,197
turn off 341,304 through 638,850
turn off 199,133 through 461,193
toggle 322,558 through 977,958
toggle 537,781 through 687,941
turn on 226,196 through 599,390
turn on 240,129 through 703,297
turn on 317,329 through 451,798
turn on 957,736 through 977,890
turn on 263,530 through 559,664
turn on 158,270 through 243,802
toggle 223,39 through 454,511
toggle 544,218 through 979,872
turn on 313,306 through 363,621
toggle 173,401 through 496,407
toggle 333,60 through 748,159
turn off 87,577 through 484,608
turn on 809,648 through 826,999
toggle 352,432 through 628,550
turn off 197,408 through 579,569
turn off 1,629 through 802,633
turn off 61,44 through 567,111
toggle 880,25 through 903,973
turn on 347,123 through 864,746
toggle 728,877 through 996,975
turn on 121,895 through 349,906
turn on 888,547 through 931,628
toggle 398,782 through 834,882
turn on 966,850 through 989,953
turn off 891,543 through 914,991
toggle 908,77 through 916,117
turn on 576,900 through 943,934
turn off 580,170 through 963,206
turn on 184,638 through 192,944
toggle 940,147 through 978,730
turn off 854,56 through 965,591
toggle 717,172 through 947,995
toggle 426,987 through 705,998
turn on 987,157 through 992,278
toggle 995,774 through 997,784
turn off 796,96 through 845,182
turn off 451,87 through 711,655
turn off 380,93 through 968,676
turn on 263,468 through 343,534
turn on 917,936 through 928,959
toggle 478,7 through 573,148
turn off 428,339 through 603,624
turn off 400,880 through 914,953
toggle 679,428 through 752,779
turn off 697,981 through 709,986
toggle 482,566 through 505,725
turn off 956,368 through 993,516
toggle 735,823 through 783,883
turn off 48,487 through 892,496
turn off 116,680 through 564,819
turn on 633,865 through 729,930
turn off 314,618 through 571,922
toggle 138,166 through 936,266
turn on 444,732 through 664,960
turn off 109,337 through 972,497
turn off 51,432 through 77,996
turn off 259,297 through 366,744
toggle 801,130 through 917,544
toggle 767,982 through 847,996
turn on 216,507 through 863,885
turn off 61,441 through 465,731
turn on 849,970 through 944,987
toggle 845,76 through 852,951
toggle 732,615 through 851,936
toggle 251,128 through 454,778
turn on 324,429 through 352,539
toggle 52,450 through 932,863
turn off 449,379 through 789,490
turn on 317,319 through 936,449
toggle 887,670 through 957,838
toggle 671,613 through 856,664
turn off 186,648 through 985,991
turn off 471,689 through 731,717
toggle 91,331 through 750,758
toggle 201,73 through 956,524
toggle 82,614 through 520,686
toggle 84,287 through 467,734
turn off 132,367 through 208,838
toggle 558,684 through 663,920
turn on 237,952 through 265,997
turn on 694,713 through 714,754
turn on 632,523 through 862,827
turn on 918,780 through 948,916
turn on 349,586 through 663,976
toggle 231,29 through 257,589
toggle 886,428 through 902,993
turn on 106,353 through 236,374
turn on 734,577 through 759,684
turn off 347,843 through 696,912
turn on 286,699 through 964,883
turn on 605,875 through 960,987
turn off 328,286 through 869,461
turn off 472,569 through 980,848
toggle 673,573 through 702,884
turn off 398,284 through 738,332
turn on 158,50 through 284,411
turn off 390,284 through 585,663
turn on 156,579 through 646,581
turn on 875,493 through 989,980
toggle 486,391 through 924,539
turn on 236,722 through 272,964
toggle 228,282 through 470,581
toggle 584,389 through 750,761
turn off 899,516 through 900,925
turn on 105,229 through 822,846
turn off 253,77 through 371,877
turn on 826,987 through 906,992
turn off 13,152 through 615,931
turn on 835,320 through 942,399
turn on 463,504 through 536,720
toggle 746,942 through 786,998
turn off 867,333 through 965,403
turn on 591,477 through 743,692
turn off 403,437 through 508,908
turn on 26,723 through 368,814
turn on 409,485 through 799,809
turn on 115,630 through 704,705
turn off 228,183 through 317,220
toggle 300,649 through 382,842
turn off 495,365 through 745,562
turn on 698,346 through 744,873
turn on 822,932 through 951,934
toggle 805,30 through 925,421
toggle 441,152 through 653,274
toggle 160,81 through 257,587
turn off 350,781 through 532,917
toggle 40,583 through 348,636
turn on 280,306 through 483,395
toggle 392,936 through 880,955
toggle 496,591 through 851,934
turn off 780,887 through 946,994
turn off 205,735 through 281,863
toggle 100,876 through 937,915
turn on 392,393 through 702,878
turn on 956,374 through 976,636
toggle 478,262 through 894,775
turn off 279,65 through 451,677
turn on 397,541 through 809,847
turn on 444,291 through 451,586
toggle 721,408 through 861,598
turn on 275,365 through 609,382
turn on 736,24 through 839,72
turn off 86,492 through 582,712
turn on 676,676 through 709,703
turn off 105,710 through 374,817
toggle 328,748 through 845,757
toggle 335,79 through 394,326
toggle 193,157 through 633,885
turn on 227,48 through 769,743
toggle 148,333 through 614,568
toggle 22,30 through 436,263
toggle 547,447 through 688,969
toggle 576,621 through 987,740
turn on 711,334 through 799,515
turn on 541,448 through 654,951
toggle 792,199 through 798,990
turn on 89,956 through 609,960
toggle 724,433 through 929,630
toggle 144,895 through 201,916
toggle 226,730 through 632,871
turn off 760,819 through 828,974
toggle 887,180 through 940,310
toggle 222,327 through 805,590
turn off 630,824 through 885,963
turn on 940,740 through 954,946
turn on 193,373 through 779,515
toggle 304,955 through 469,975
turn off 405,480 through 546,960
turn on 662,123 through 690,669
turn off 615,238 through 750,714
turn on 423,220 through 930,353
turn on 329,769 through 358,970
toggle 590,151 through 704,722
turn off 884,539 through 894,671
toggle 449,241 through 984,549
toggle 449,260 through 496,464
turn off 306,448 through 602,924
turn on 286,805 through 555,901
toggle 722,177 through 922,298
toggle 491,554 through 723,753
turn on 80,849 through 174,996
turn off 296,561 through 530,856
toggle 653,10 through 972,284
toggle 529,236 through 672,614
toggle 791,598 through 989,695
turn on 19,45 through 575,757
toggle 111,55 through 880,871
turn off 197,897 through 943,982
turn on 912,336 through 977,605
toggle 101,221 through 537,450
turn on 101,104 through 969,447
toggle 71,527 through 587,717
toggle 336,445 through 593,889
toggle 214,179 through 575,699
turn on 86,313 through 96,674
toggle 566,427 through 906,888
turn off 641,597 through 850,845
turn on 606,524 through 883,704
turn on 835,775 through 867,887
toggle 547,301 through 897,515
toggle 289,930 through 413,979
turn on 361,122 through 457,226
turn on 162,187 through 374,746
turn on 348,461 through 454,675
turn off 966,532 through 985,537
turn on 172,354 through 630,606
turn off 501,880 through 680,993
turn off 8,70 through 566,592
toggle 433,73 through 690,651
toggle 840,798 through 902,971
toggle 822,204 through 893,760
turn off 453,496 through 649,795
turn off 969,549 through 990,942
turn off 789,28 through 930,267
toggle 880,98 through 932,434
toggle 568,674 through 669,753
turn on 686,228 through 903,271
turn on 263,995 through 478,999
toggle 534,675 through 687,955
turn off 342,434 through 592,986
toggle 404,768 through 677,867
toggle 126,723 through 978,987
toggle 749,675 through 978,959
turn off 445,330 through 446,885
turn off 463,205 through 924,815
turn off 417,430 through 915,472
turn on 544,990 through 912,999
turn off 201,255 through 834,789
turn off 261,142 through 537,862
turn off 562,934 through 832,984
turn off 459,978 through 691,980
turn off 73,911 through 971,972
turn on 560,448 through 723,810
turn on 204,630 through 217,854
turn off 91,259 through 611,607
turn on 877,32 through 978,815
turn off 950,438 through 974,746
toggle 426,30 through 609,917
toggle 696,37 through 859,201
toggle 242,417 through 682,572
turn off 388,401 through 979,528
turn off 79,345 through 848,685
turn off 98,91 through 800,434
toggle 650,700 through 972,843
turn off 530,450 through 538,926
turn on 428,559 through 962,909
turn on 78,138 through 92,940
toggle 194,117 through 867,157
toggle 785,355 through 860,617
turn off 379,441 through 935,708
turn off 605,133 through 644,911
toggle 10,963 through 484,975
turn off 359,988 through 525,991
turn off 509,138 through 787,411
toggle 556,467 through 562,773
turn on 119,486 through 246,900
turn on 445,561 through 794,673
turn off 598,681 through 978,921
turn off 974,230 through 995,641
turn off 760,75 through 800,275
toggle 441,215 through 528,680
turn off 701,636 through 928,877
turn on 165,753 through 202,780
toggle 501,412 through 998,516
toggle 161,105 through 657,395
turn on 113,340 through 472,972
toggle 384,994 through 663,999
turn on 969,994 through 983,997
turn on 519,600 through 750,615
turn off 363,899 through 948,935
turn on 271,845 through 454,882
turn off 376,528 through 779,640
toggle 767,98 through 854,853
toggle 107,322 through 378,688
turn off 235,899 through 818,932
turn on 445,611 through 532,705
toggle 629,387 through 814,577
toggle 112,414 through 387,421
toggle 319,184 through 382,203
turn on 627,796 through 973,940
toggle 602,45 through 763,151
turn off 441,375 through 974,545
toggle 871,952 through 989,998
turn on 717,272 through 850,817
toggle 475,711 through 921,882
toggle 66,191 through 757,481
turn off 50,197 through 733,656
toggle 83,575 through 915,728
turn on 777,812 through 837,912
turn on 20,984 through 571,994
turn off 446,432 through 458,648
turn on 715,871 through 722,890
toggle 424,675 through 740,862
toggle 580,592 through 671,900
toggle 296,687 through 906,775
Title: Re: Advent of Code
Post by: David Martin on December 13, 2015, 01:44:06 pm
Sorry, I had a power failure and lost my scratch file with the code in.
Title: Re: Advent of Code
Post by: red marley on December 13, 2015, 02:06:39 pm
Pingu, with your light instructions, I get 400410 left on.

Which looks like this:

(http://staff.city.ac.uk/~jwo/acf/adventLightsPingu.png)

and for part b, like this:

(http://staff.city.ac.uk/~jwo/acf/adventLights2Pingu.jpg)

(which clearly shows an image of Jesus imprinted on it, so you must have a very special set of instructions)
Title: Re: Advent of Code
Post by: red marley on December 13, 2015, 04:50:12 pm
Waiting for 10b to finish running.

(click to show/hide)
Title: Re: Advent of Code
Post by: Pancho on December 13, 2015, 04:59:44 pm
Waiting for 4b to spit out an answer. (4a turned out to be the trivially boring case).
Title: Re: Advent of Code
Post by: Pingu on December 13, 2015, 05:39:35 pm
Pingu, with your light instructions, I get 400410 left on.

Thanks jo  :thumbsup:
Title: Re: Advent of Code
Post by: red marley on December 13, 2015, 05:46:57 pm
Does that mean you spotted the reason why you were not getting the correct result? One of the difficult aspects of that particular challenge is that is a hard one to debug.
Title: Re: Advent of Code
Post by: Pingu on December 13, 2015, 05:57:27 pm
It was thanks for trying my data with your solution  :)

I have found the reason why my code didn't work. It was because it extracted strings rather than numbers for the coordinates from the instructions  :facepalm: One day I will learn  ::-)

6a completed.
Title: Re: Advent of Code
Post by: Pingu on December 13, 2015, 05:59:19 pm
(http://staff.city.ac.uk/~jwo/acf/adventLights2Pingu.jpg)

(which clearly shows an image of Jesus imprinted on it, so you must have a very special set of instructions)

I thought yours looked a bit like Bender.
Title: Re: Advent of Code
Post by: David Martin on December 13, 2015, 06:32:24 pm
Waiting for 10b to finish running.

(click to show/hide)
Python on an aging mac. It took a little while, probably my fault for writing stupidly inefficient code. (Couple of minutes? - didn't matter as I was half way through a rather tedious exam invigilation).
Title: Re: Advent of Code
Post by: Pingu on December 13, 2015, 06:57:49 pm
It was thanks for trying my data with your solution  :)

I have found the reason why my code didn't work. It was because it extracted strings rather than numbers for the coordinates from the instructions  :facepalm: One day I will learn  ::-)

6a completed.

And so 6b took about 5 minutes.
Title: Re: Advent of Code
Post by: red marley on December 13, 2015, 09:08:07 pm
I'm finding Day 12 (JSON parsing) rather frustrating.

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 13, 2015, 09:35:05 pm
You could do it with a stream parser, though I tried it and my code didn't work so reverted to a json parser and a recursive tree walker function to do the addition.
Did you write code for 11? I started to think about how I would code it but had solved it by inspection before I worked out how I would code it.
Title: Re: Advent of Code
Post by: David Martin on December 13, 2015, 09:37:18 pm
Day 13
(click to show/hide)
Title: Re: Advent of Code
Post by: Afasoas on December 13, 2015, 11:50:11 pm
Really excited by the number of people taking part. Unfortunately I've not had much weekend time to catch up.. 7 days behind  :-\
Title: Re: Advent of Code
Post by: tonycollinet on December 14, 2015, 06:04:13 am
I've just done days one and two in a spreadsheet. Not gonna work for day 3.


So can anyone suggest a mac based easy to setup and use programming environment. I used to do C a long time ago. Not worried about (re)learning to code, but could do without the pain of learning a clunky environment.

Something with instant feedback would be good. Along the lines of

Print "Hello World"
Run
Hello World

Would be great :-)

Title: Re: Advent of Code
Post by: red marley on December 14, 2015, 07:08:26 am
http://processing.org

It's based on Java, so shares a C like syntax, but with a lower barrier to entry. I've used it to answer the first 12 days' advent questions so far.

println("hello world!");

works straight out of the box.

Loading text files is easy (loadStrings()), as is conversion to character arrays (.toCharArray()) and regular expressions, all of which are helpful for the challenge.
Title: Re: Advent of Code
Post by: Pancho on December 14, 2015, 09:02:19 am
@tonycollinet: from a background of non-coder scared of incomprehensible IDEs, I'm using perl that I found was already on my computer. I just use an ascii text editor to write code, save it, then use perl to compile and run. I think Macs have perl onboard by default. Type perl -v to find version.
Title: Re: Advent of Code
Post by: Oaky on December 14, 2015, 11:26:02 am
I completed day 7 last night.  It took me a lot longer than I'd anticipated.

(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 14, 2015, 12:08:23 pm
Day 7

(click to show/hide)
Title: Re: Advent of Code
Post by: Pingu on December 14, 2015, 06:02:05 pm
I've skipped day 7* and done day 8.




*Javascript does the bitwise operations on 32-bit.
Title: Re: Advent of Code
Post by: red marley on December 14, 2015, 06:21:19 pm
I've skipped day 7* and done day 8.

*Javascript does the bitwise operations on 32-bit.

(click to show/hide)
Title: Re: Advent of Code
Post by: tonycollinet on December 14, 2015, 07:16:18 pm
processing.org seems to fit the bill

Thanks jo.

Will play after my trip to Germany.


(Thanks also Pancho for the perl suggestion.)
Title: Re: Advent of Code
Post by: Oaky on December 14, 2015, 07:42:59 pm
Did you write code for 11? I started to think about how I would code it but had solved it by inspection before I worked out how I would code it.

I can see the answer to my day 11, also by inspection.  I wrote code but it is still running, though, despite applying some optimisations:-

(click to show/hide)

as an aside, I've been using this as an excuse to start playing around in test-driven development using the Python unittest framework

Code: [Select]
class TestIt(unittest.TestCase):
    # Part 1 tests
       
    def test_01(self):
        self.assertEqual(incr('aa'), 'ab')
 
    def test_02(self):
        self.assertEqual(incr('az'), 'ba')
 
    def test_03(self):
        self.assertEqual(incr('zz'), 'aaa') # my own assumption - not mentioned in TEH RULZ

    def test_04(self):
        self.assertFalse(pwOK('hijklmmn'))

    def test_05(self):
        self.assertFalse(pwOK('abbceffg'))

    def test_06(self):
        self.assertFalse(pwOK('abbcegjk'))

    def test_07(self):
        self.assertTrue(pwOK('abcdffaa'))

    def test_08(self):
        self.assertTrue(pwOK('ghjaabcc'))

(I've hidden some tests as they give a clue to some of the stuff I mention in the spoiler above):-

(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 14, 2015, 08:14:59 pm
Re: my Day 11 woes...

As an alternative to looking for optimisations,  I could always just fix the bug that had it spinning in a tight loop going nowhere  :facepalm:

runs in under a second now  ::-)

I am an idiot!
Title: Re: Advent of Code
Post by: red marley on December 14, 2015, 11:14:57 pm
Finally found an answer to Day 12b (JSON parsing)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 14, 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.)
Title: Re: Advent of Code
Post by: David Martin on December 14, 2015, 11:27:17 pm
Finally found an answer to Day 12b (JSON parsing)

(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 14, 2015, 11:31:31 pm
Day 7

(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 15, 2015, 12:12:05 am
yay! finally up to date (well, at least until the next puzzle is released at 5 a.m  ;D).
Title: Re: Advent of Code
Post by: Oaky on December 15, 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)
Title: Re: Advent of Code
Post by: red marley on December 15, 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)
Title: Re: Advent of Code
Post by: David Martin on December 15, 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.
Title: Re: Advent of Code
Post by: David Martin on December 15, 2015, 05:30:16 pm
Really not happy with my solution to day 15.
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 15, 2015, 05:57:44 pm
Day 15:

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 15, 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.
Title: Re: Advent of Code
Post by: Oaky on December 15, 2015, 09:13:00 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Pingu on December 15, 2015, 09:39:50 pm
Day 9a done eventually followed by 9b two minutes later.
Title: Re: Advent of Code
Post by: David Martin on December 15, 2015, 09:55:59 pm
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Pingu on December 15, 2015, 10:28:35 pm
Day 10 done. What a contrast with day 9.
Title: Re: Advent of Code
Post by: red marley on December 16, 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.
Title: Re: Advent of Code
Post by: Oaky on December 16, 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)
Title: Re: Advent of Code
Post by: David Martin on December 16, 2015, 09:33:34 pm
(click to show/hide)
Today was very easy. I dread tomorrow.
Title: Re: Advent of Code
Post by: red marley on December 16, 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).
Title: Re: Advent of Code
Post by: David Martin on December 16, 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)
Title: Re: Advent of Code
Post by: David Martin on December 17, 2015, 08:07:35 am
Day 17 required some thought but very few lines of code.
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 17, 2015, 09:56:39 am
Day 17 required some thought but very few lines of code.
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 17, 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).
Title: Re: Advent of Code
Post by: Feanor on December 17, 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.
Title: Re: Advent of Code
Post by: David Martin on December 17, 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.
Title: Re: Advent of Code
Post by: David Martin on December 18, 2015, 07:49:13 am
Day 18, those blinking lights again.
I didn't use recursion. Fortunately my approach meant that part B required minimal extra coding
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 18, 2015, 10:29:12 am
Day 18, those blinking lights again.
I didn't use recursion. Fortunately my approach meant that part B required minimal extra coding
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 18, 2015, 10:12:41 pm
As Mr Wall says: TMTOWTDI
It was pleasantly easy. I was expecting something like 'if the bulb has been on for 10 iterations continuously it burns out and is permanently off'
Title: Re: Advent of Code
Post by: Oaky on December 19, 2015, 12:28:33 am
Indeed,  the part 2 variation was less taxing than I expected.

I was doing a bit of self-searching about which days i found hardest so far, and from memory the hardest two were

1. day 8 (the string storage thing)
(click to show/hide)
2. day 7 (the circuit thing)
(click to show/hide)

In terms of raw amounts of code (stripping comments), they rank as follows:-

Code: [Select]
oaky@jarlsberg ~/Dropbox/AdventOfCode $ for i in */s*.py; do echo `grep -v '^[ ]*#' $i |  wc -l` $i;done | sort -n
22 1/s1.py
26 2/s2.py
32 4/s4.py
48 17/s17.py
51 8/s8b.py
55 10/s10.py
58 12/s12.py
62 8/s8.py
71 14/s14.py
77 16/s16.py
82 3/s3.py
91 15/s15.py
95 13/s13.py
99 9/s9.py
100 6/s6.py
104 11/s11.py
137 5/s5.py
150 18/s18.py
173 7/s7.py

although it's skewed somewhat since after the first couple of days I started using a unit test framework for varying levels of testing within the script itself (some of the lmid to ater ones were more than 50% test code).
Title: Re: Advent of Code
Post by: Oaky on December 19, 2015, 12:31:45 am
from twitter earlier:-

Quote
Eric Wastl ‏@ericwastl 3h3 hours ago

If #AdventOfCode were a roller coaster, we're about to reach the corkscrews and loops and the part where it takes your picture.
Title: Re: Advent of Code
Post by: red marley on December 19, 2015, 06:12:14 am
Today's is right up David Martin's street.

Part two feels like a proper workout for me at least. I'm impressed that the highest entry on the leaderboard managed both parts within 18 minutes of the puzzle being released.
Title: Re: Advent of Code
Post by: David Martin on December 19, 2015, 09:51:49 am
I've just done part one which was easy. I'm thinking about part 2.
(click to show/hide)
Title: Re: Advent of Code
Post by: Pingu on December 19, 2015, 12:04:45 pm
Took a couple of days off. Just finished day 11. The concept wasn't difficult, but it took me a while to sort out the letter incrementing business.
Title: Re: Advent of Code
Post by: David Martin on December 19, 2015, 04:18:13 pm
Well that doesn't work for day 19 as the time/space required is too big. This requires more thought.
Title: Re: Advent of Code
Post by: Pingu on December 19, 2015, 07:20:57 pm
Finally found an answer to Day 12b (JSON parsing)

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

I'm on 12b now. It's a bit of a bastard. I've not opened the spoilers (yet).
Title: Re: Advent of Code
Post by: David Martin on December 19, 2015, 09:19:20 pm
I had a look at a spoiler for 19
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 20, 2015, 01:30:06 am
19b is eluding me for now, although I'm sure my BFI (brute force and ignorance) approach isn't the best.

I'm going to leave the BFI job running overnight, since it's not apparently consuming exponential memory, but in the morning, I am going to try a different approach:

(click to show/hide)

It may not help, but it beats abusing the company AWS account to do an expensive massively parallel brute force search ;)
Title: Re: Advent of Code
Post by: David Martin on December 20, 2015, 11:10:47 am
I think your revised approach is by far the most sensible (which is why I started with that. Still haven't managed a suitable solution though I think I know how to find one.
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 20, 2015, 05:30:21 pm
Still working on an efficient way of reducing the search space for day 19b.

Day 20 is much easier...

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 20, 2015, 08:38:03 pm
I haven't had a chance to look at 20 as my laptop has decided to overheat and kill the graphics every hour or so.
(click to show/hide)
Title: Re: Advent of Code
Post by: Afasoas on December 21, 2015, 09:23:39 am
I took a look at day 7 yesterday and found myself in a perpetual state of confusion.

I might try and take another look at it tonight.
Title: Re: Advent of Code
Post by: red marley on December 21, 2015, 11:43:03 am
I now have a solution for 19b, Kicking myself I didn't get it earlier.

(click to show/hide)
Title: Re: Advent of Code
Post by: Afasoas on December 21, 2015, 05:31:47 pm
For 7b, I found someone elses explanation of the problem and now I think I understand it.
I've also found out where the bitwise operators are in PowerShell*.


*I'm learning C and Ruby, I've a smattering of experience with Python, PHP and C#. But I'm nowhere near as proficient in those as I am with PowerShell. I figure if I find time to complete all the chellanges in PowerShell, I can try porting my solutions to other languages.
Title: Re: Advent of Code
Post by: David Martin on December 21, 2015, 05:49:16 pm
Laptop was taken to laptop hospital and I really must finish my coursework marking before getting on with AoC.
Title: Re: Advent of Code
Post by: Afasoas on December 21, 2015, 09:13:49 pm
Still stuck on day 7. I think my logic is sound.
I'm either hitting PowerShells limitations or I'm using it wrong.

Code: [Select]
[uint16]$foo = 1
[Uint16]$bar = $foo -shl 2
[Uint16]$car = $foo -shl 15
[Uint16]$har = $foo -shl 16
write-host "foo: $foo"
write-host "bar: $bar"
write-host "car: $car"
write-host "har: $har"

Output:
Code: [Select]
foo: 1
bar: 4
car: 32768
har: 0


On Edit: I'm being dufus. "shl" and "shr" are working as expected. ... **goes back, stares at code**
Title: Re: Advent of Code
Post by: Pingu on December 22, 2015, 09:29:28 pm
Finally found an answer to Day 12b (JSON parsing)

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

I'm on 12b now. It's a bit of a bastard. I've not opened the spoilers (yet).

12b done at last (without spoilers)!  :thumbsup:
Title: Re: Advent of Code
Post by: Pingu on December 23, 2015, 11:35:32 pm
Day 13 completed via a mix of Javascript and spreadsheet. Very much like day 9.
Title: Re: Advent of Code
Post by: Pickled Onion on December 24, 2015, 06:30:48 pm
Yikes, made a bit of meal out of day 9, but quite happy with what I ended up with.
Title: Re: Advent of Code
Post by: Pickled Onion on December 24, 2015, 07:47:17 pm
Quite pleased with this for day 10

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 25, 2015, 06:34:52 am
In 12b, does "red" after an object mean that the object is ignored?

e.g. { 1, 2, {3, 4} , red }

Should that be 7 or 0?
Title: Re: Advent of Code
Post by: Oaky on December 25, 2015, 10:53:40 am
...

ETA: the spoiler below doesn't contain any info about the solution to the question, but does reveal something about part (b) of the question.

(click to show/hide)
Title: Re: Advent of Code
Post by: Pingu on December 25, 2015, 11:36:21 pm
Day 14 done.
Title: Re: Advent of Code
Post by: Pingu on December 25, 2015, 11:43:06 pm
...

ETA: the spoiler below doesn't contain any info about the solution to the question, but does reveal something about part (b) of the question.

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 26, 2015, 06:45:05 am
...

ETA: the spoiler below doesn't contain any info about the solution to the question, but does reveal something about part (b) of the question.

(click to show/hide)

(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: Pingu on December 26, 2015, 03:00:19 pm
...

ETA: the spoiler below doesn't contain any info about the solution to the question, but does reveal something about part (b) of the question.

(click to show/hide)

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

 :thumbsup:
Title: Re: Advent of Code
Post by: Pingu on December 26, 2015, 03:26:46 pm
Day 15 done. Not too difficult compared with some of the previous.
Title: Re: Advent of Code
Post by: Pingu on December 26, 2015, 05:39:22 pm
Day 16 done entirely by the dreaded spreadsheet.
Title: Re: Advent of Code
Post by: Pingu on December 27, 2015, 12:38:51 am
Day 17 done with judicious googling*  :-X

(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 27, 2015, 04:00:08 pm
Day 21 was one of the easier ones. But I did enjoy Day 22 because

(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 27, 2015, 04:08:44 pm
Day 23. Another relatively easy one to compute but with a gotcha in part 2.

(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 27, 2015, 04:18:09 pm
Day 24. Interesting.

(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 27, 2015, 04:24:43 pm
Day 25. A nice finish to the challenge.

(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 28, 2015, 01:11:06 pm
Day 19 - part 2.

(click to show/hide)
Title: Re: Advent of Code
Post by: Pingu on December 30, 2015, 12:31:01 pm
Day 18 done. Plodding on  :thumbsup:
Title: Re: Advent of Code
Post by: Pickled Onion on January 02, 2016, 10:34:22 am
Day 22. What a wind-up. This is the only one where the examples don't give an expected result, just an example of the steps. So all my tests passed but the answer was wrong.

(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on January 02, 2016, 10:45:21 am
Day 25. A nice finish to the challenge.

Thanks for posting this Afasoas, it was fun.

Slight quibble - advent calendars normally have 24 windows, don't they?

Now off to solve waste more time with http://www.gchq.gov.uk/press_and_media/news_and_features/Pages/Directors-Christmas-puzzle-2015.aspx
Title: Re: Advent of Code
Post by: Oaky on January 05, 2016, 09:16:30 am
Day 22. What a wind-up. This is the only one where the examples don't give an expected result, just an example of the steps. So all my tests passed but the answer was wrong.

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on January 05, 2016, 09:31:11 am
I think one of the consequences of the kind of problem you mention for Day 22 and many of the others in the challenge is how useful test driven development can be. I like the way the examples provide a gentle introduction to testing without ever mentioning unit tests and the like. I am considering how to incorporate these coding challenges into some of our undergraduate introductory programming teaching.

If anyone is feeling withdrawal symptoms with no more AoC, I recommend attempting the Synacor Challenge (https://challenge.synacor.com) also from Eric Wastl. It is immensely satisfying, very cleverly designed and rather challenging. But like the AoC, it leads you in gently so caters for a wide range of abilities. I'd also recommend not Googling for it as spoilers abound and one of the most satisfying elements of participating comes from what is revealed and the sense of achievement as you progress through the challenge.
Title: Re: Advent of Code
Post by: David Martin on January 05, 2016, 10:01:22 am
I have to get back into it - haven't done any since the Mac died and Christmas took over.
Title: Re: Advent of Code
Post by: Oaky on January 05, 2016, 10:17:03 am
(click to show/hide)

Title: Re: Advent of Code
Post by: red marley on January 05, 2016, 11:26:41 am
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on January 11, 2016, 09:21:57 am
If anyone is feeling withdrawal symptoms with no more AoC, I recommend attempting the Synacor Challenge (https://challenge.synacor.com) also from Eric Wastl.

That thing is addictive.  I've got the first four codes now.

(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on February 01, 2016, 04:06:22 pm
Some additional stats from Advent of Code have been published:  http://hexatlas.com/entries/8

I like this quote: "I expected 70 users or so, maybe. By Day 2, almost 10,000 were signed up, which caused quite a bit of panic on the server capacity end of things."
Title: Re: Advent of Code
Post by: Oaky on November 22, 2016, 12:23:01 pm
Advent of Code 2016 is imminent!  :thumbsup:

Looks like jo's private leaderboard from last year carries over to 2016 too.
Title: Re: Advent of Code
Post by: David Martin on November 22, 2016, 01:22:59 pm
Oooh.. must do better this year.
Title: Re: Advent of Code
Post by: red marley on November 22, 2016, 02:52:49 pm
Advent of Code 2016 is imminent!  :thumbsup:

Looks like jo's private leaderboard from last year carries over to 2016 too.

In case it is not obvious to anyone new to the Advent of Code, the 'private leaderboard' allows you to view the number of completed challenge questions from YACF people who register. To join the board, simply enter the code 48462-ea506236 under 'leaderboard -> join private leaderboard'.

To enter the challenge at all you will need to log in to the site with one of the following credentials: twitter, Google, GitHub or Reddit. This is necessary as they are used to generate a (possibly) unique set of question variations and validation of your answers. No spamming is involved (as far as I am aware).

I'd really recommend the challenge to anyone with even a passing interest in coding. So far the challenges have been very well designed providing a manageable and satisfying learning curve over the 25 days. Whether you are a beginner wanting to develop skills in a new language (I'm going to attempt some in Elm (http://elm-lang.org) and possibly Racket (http://beautifulracket.com) this year) or are an expert programmer with a familiar language, there is something on offer.
Title: Re: Advent of Code
Post by: Oaky on November 25, 2016, 11:57:08 am
from the Advent of Code author on Twitter:-

https://twitter.com/ericwastl/status/801715851510616064

 ;D
Title: Re: Advent of Code
Post by: red marley on December 01, 2016, 11:56:51 am
I need to apologise as I have inadvertently given out the code for the YACF private leaderboard to colleagues at work (I thought I had generated a new code from a different account, but had passed the wrong one to colleagues). The upshot is that there may be a few others joining the YACF leaderboard this month. If that is a problem for anyone, now would be the time to start a new YACF one.
Title: Re: Advent of Code
Post by: David Martin on December 01, 2016, 12:47:04 pm
I haven't done it yet but this is the approach I will take..

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 01, 2016, 01:03:54 pm
And then there is part 2
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 01, 2016, 03:18:20 pm
Both parts of day 1
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 01, 2016, 05:55:03 pm
Day 1: I did pretty much the same as David Martin. Quite similar to one of the problems last year.

Diver300 - Initially I though your quick solution to part b was rather elegant but...

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 01, 2016, 08:48:22 pm
Day 1: I did pretty much the same as David Martin. Quite similar to one of the problems last year.

Diver300 - Initially I though your quick solution to part b was rather elegant but...

(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 01, 2016, 08:51:54 pm
Day 1: I did pretty much the same as David Martin. Quite similar to one of the problems last year.

Diver300 - Initially I though your quick solution to part b was rather elegant but...

(click to show/hide)
(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: tom_e on December 01, 2016, 09:08:36 pm
Well, that was a bit disappointing.  I'd recommended this to mrs_e on the basis it started off really gently in last year's problems and only gradually picked up in intensity.  This was straight in with an equivalent of day 3 (2015) but with an extra level of complexity due to rotations.
Title: Re: Advent of Code
Post by: red marley on December 02, 2016, 07:45:57 am
I think Day 2 is easier so mrs_e may have more joy today.

Day 2, my solution

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 02, 2016, 08:39:42 am
Interesting. I took a slightly different approach, modelling the keypad more explicitly.
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 02, 2016, 08:56:50 am
(click to show/hide)
Title: Re: Advent of Code
Post by: tom_e on December 02, 2016, 10:57:12 am
I think Day 2 is easier so mrs_e may have more joy today.

S'alright, she got there in the end with day 1 last night.  And while still in bed this morning she reported the same thing you have just said after reading day 2.  ;D
Title: Re: Advent of Code
Post by: David Martin on December 02, 2016, 11:16:20 am
Gone back to day1 in R to force myself to think differently.
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 03, 2016, 07:35:46 am
Day 3 seemed simpler to me than either of the previous days.
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 03, 2016, 10:35:19 am
Agreed. Still trying to do Day 1 part 2 in R. It's very good for row level manipulations but doing all against all is taxing me a bit. I might try embedding an SQL query in the R code (because one can).
Title: Re: Advent of Code
Post by: red marley on December 03, 2016, 03:52:27 pm
Day 3

Because I like drawing pictures, I thought I'd create some festive visualisations of my Day 3 answers. Here's part (a) with each green triangle being a 'real' triangle with edge lengths as provided and impossible ones shown as three pronged branches with the given lengths.

(http://staff.city.ac.uk/~jwo/aoc/aoc2016day3a.jpg)

And here is part b with the vertically derived triangles added in red.

(http://staff.city.ac.uk/~jwo/aoc/aoc2016day3b.jpg)
Title: Re: Advent of Code
Post by: David Martin on December 04, 2016, 08:55:47 am
A bit lengthier to solve today but not hard - bit of regex processing and understanding ascii. Had to look up how to do nested sorts in python as I'd not done that before, otherwise pretty straightforward.
Title: Re: Advent of Code
Post by: Diver300 on December 04, 2016, 09:58:17 am
I used Javascript again today but kept falling over my own programming inability, but got there in the end.



Title: Re: Advent of Code
Post by: Pingu on December 04, 2016, 12:09:31 pm
Late starter  ::-)

Day 1 done, a bit harder than expected.

(https://c7.staticflickr.com/6/5576/31041094230_17449958cf_z.jpg) (https://flic.kr/p/PhZHRQ)
AoC_day_01 (https://flic.kr/p/PhZHRQ) by The Pingus (https://www.flickr.com/photos/the_pingus/), on Flickr

Title: Re: Advent of Code
Post by: Pickled Onion on December 04, 2016, 03:48:07 pm
A bit lengthier to solve today but not hard - bit of regex processing and understanding ascii. Had to look up how to do nested sorts in python as I'd not done that before, otherwise pretty straightforward.

It was good to practice sort functions, but the best I could come up with for the checksum was

(click to show/hide)

I'm sure there must be a way to create the hash anonymously on the fly, but it's eluding me.
Title: Re: Advent of Code
Post by: David Martin on December 04, 2016, 04:32:48 pm
A bit lengthier to solve today but not hard - bit of regex processing and understanding ascii. Had to look up how to do nested sorts in python as I'd not done that before, otherwise pretty straightforward.

It was good to practice sort functions, but the best I could come up with for the checksum was

(click to show/hide)

I'm sure there must be a way to create the hash anonymously on the fly, but it's eluding me.
Title: Re: Advent of Code
Post by: Pickled Onion on December 04, 2016, 05:05:52 pm
I see where you're going with that, but the wriggly problem is to keep track of the counts for each letter.

Looking forward to tomorrow's offering.
Title: Re: Advent of Code
Post by: David Martin on December 04, 2016, 05:27:03 pm
I see where you're going with that, but the wriggly problem is to keep track of the counts for each letter.

Looking forward to tomorrow's offering.

It does that implicitly doesn't it? you are sorting on the letters and it is inefficient in that it runs the regex for every comparison. You don't need to keep track of the counts for each letter if they are readily recalculable.
Title: Re: Advent of Code
Post by: David Martin on December 04, 2016, 06:55:46 pm
OK, there is no easy way to calculate the number of occurences of a substring in Perl so I had to craft a simple function for it.
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 05, 2016, 06:10:01 am
Day 5:

(click to show/hide)

I rather like the challenge to produce a HollywoodOS version of the password decryption. Might have to have a go at that. Now where are those beeps...
Title: Re: Advent of Code
Post by: David Martin on December 05, 2016, 08:11:13 am
Took mine nearly half a minute. I did have a text console holywood version.. ish.
Title: Re: Advent of Code
Post by: Diver300 on December 05, 2016, 11:02:34 pm
The server that I ran the .php file on took about 45 seconds to do the second half.
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 06, 2016, 07:13:45 am
From the creator of Advent of Code this morning...

Quote from: Eric Wastl
I hope everyone has been enjoying #AdventOfCode! Today ends the warmup puzzles. It's uphill from here!
Title: Re: Advent of Code
Post by: Oaky on December 06, 2016, 07:57:03 am
From the creator of Advent of Code this morning...

Quote from: Eric Wastl
I hope everyone has been enjoying #AdventOfCode! Today ends the warmup puzzles. It's uphill from here!

I was just about to post that the first six days felt like "limbering up", and I had a feeling that the difficult stuff was about to start.
Title: Re: Advent of Code
Post by: David Martin on December 06, 2016, 09:38:02 am
Today was straightforward. I have then worked out how to do it in R without loops. One line to read the data in and one very long line to generate the answer.
(click to show/hide)
Title: Re: Advent of Code
Post by: Tim Hall on December 06, 2016, 01:18:59 pm
The Boy, last night, informed me he's cracked 1-4 and was working on 5.   
Title: Re: Advent of Code
Post by: Oaky on December 06, 2016, 06:15:18 pm
Today was straightforward. I have then worked out how to do it in R without loops. One line to read the data in and one very long line to generate the answer.
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 06, 2016, 06:25:59 pm
My colleague has commented how he has learned so much in the last few days. I have too, and will certainly look at the bear bones of the Pandas implementation. Python seems to be my 'goto' to start off with (typically with a few sanity checks, not really tests, along the way). Then I might try something else for fun like R or the Perl from previous. I've not really looked at Pandas - I should do. Numpy is as close as I have got.

Looking forward to something a bit more stretching tomorrow.
Title: Re: Advent of Code
Post by: Oaky on December 06, 2016, 06:34:19 pm
I did consider trying this year in something other than Python, but to be honest, up until now, my day job hasn't involved enough opportunity for data munging for me to have fully assimilated Python yet, despite learning it several years back. 

That's changing right now as I start to spend time with another team in $EMPLOYER, and one of the tools of choice in that team is pandas (plus Jupyter notebooks) so I'm sticking to Python and also playing with the Jupyter/pandas approach on some of these this year.
Title: Re: Advent of Code
Post by: David Martin on December 06, 2016, 10:09:48 pm
I like the Jupyter notebooks approach to problem solving as you document each step along the way (or should).
Title: Re: Advent of Code
Post by: red marley on December 07, 2016, 06:35:28 am
Day 7: (ABBA internet protocols)

Do'h. Couldn't work out why I was getting the wrong answer for part a. Spent ages slowly debugging but could not find any problems with the logic of my code. Finally redownloaded the input text to find that my first attempt to download it had missed the last few lines.

Good challenge today though with plenty of scope for creating efficient pattern matching.
Title: Re: Advent of Code
Post by: David Martin on December 07, 2016, 10:15:25 am
i'm sure there is an efficient and elegant way to do it. Spent far too long trying to vectorise it in R with moderate amounts of nearly success then gave up and brute-forced it in python.

(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 07, 2016, 10:22:52 am
i'm sure there is an efficient and elegant way to do it. Spent far too long trying to vectorise it in R with moderate amounts of nearly success then gave up and brute-forced it in python.

(click to show/hide)

Brute force here too...
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 07, 2016, 01:15:02 pm
Interesting approaches.

Regular expressions seemed the obvious approach...

(click to show/hide)
Title: Re: Advent of Code
Post by: R_nger on December 07, 2016, 01:41:03 pm
I'm using node.js and tried to use regular expressions as far as possible. Difficulties today due to not reading the instructions properly 😳
Title: Re: Advent of Code
Post by: David Martin on December 07, 2016, 02:12:01 pm
Interesting approaches.

Regular expressions seemed the obvious approach...

(click to show/hide)

And I have just learned what a zero width look ahead assertion is. Strangely most of the pages on perl re don't cover that...
Title: Re: Advent of Code
Post by: Oaky on December 07, 2016, 04:39:51 pm
checkout askalski's brute-force Perl regexp solutions over on the adventofcode subreddit (https://www.reddit.com/r/adventofcode/comments/5gy1f2/2016_day_7_solutions/)

And Eric Wastl's response:- ;)

Quote
[–]topaz2078(AoC creator) 13 points 10 hours ago

Did you do this just to make me cry? Because it worked.

 ;D
Title: Re: Advent of Code
Post by: David Martin on December 07, 2016, 04:43:46 pm
Did you look at Part 2 of that thread?
Title: Re: Advent of Code
Post by: Oaky on December 07, 2016, 04:48:56 pm
Did you look at Part 2 of that thread?

His Part 2 solution?  Yep!
Title: Re: Advent of Code
Post by: David Martin on December 07, 2016, 05:06:15 pm
There is some pretty rank coding on display there..
Title: Re: Advent of Code
Post by: R_nger on December 07, 2016, 05:21:50 pm
There is some pretty rank coding on display there..
yep, I'm glad I don't have to support some of that !  I'm not saying mine is pretty or elegant, but at least I'm not on a mission to minimise the line count (and ergo readability)!
Title: Re: Advent of Code
Post by: Ben T on December 07, 2016, 05:46:37 pm
They put in a thing to deliberately confuse (some) regex parsing implementations, i.e.
zazbz
must match zaz and zbz.

not sure whether the challenge was to simply code in one that supports one match starting before another has ended?
or simply to realise that that is what was going on


https://github.com/bjtaylor1/AoC_2016
Title: Re: Advent of Code
Post by: red marley on December 07, 2016, 06:23:45 pm
There is some pretty rank coding on display there..
yep, I'm glad I don't have to support some of that !  I'm not saying mine is pretty or elegant, but at least I'm not on a mission to minimise the line count (and ergo readability)!

Sure. Despite spending most of my career teaching people to prioritise clarity over brevity in programming, there is nevertheless something akin to magic when a 40 line block of procedural code can be replicated with

(click to show/hide)
(an answer to Day 7 pt b from Reddit)

There's lots of geeky humour on that reddit with people deliberately choosing difficult languages (Brainfuck anyone? (http://www.muppetlabs.com/~breadbox/bf/)) so I'd take the one line solutions in that spirit. I've been impressed with the K language (http://archive.vector.org.uk/art10010830) that some have been using. Seems to produce concise and efficient functional expressions  with a limited vocabulary for the kinds of list processing that has been the main feature of the challenges so far.
Title: Re: Advent of Code
Post by: David Martin on December 08, 2016, 09:11:21 am
Array index munging today. With a bit of input parsing thrown in.
Title: Re: Advent of Code
Post by: Oaky on December 08, 2016, 12:13:24 pm
There is some pretty rank coding on display there..

It is deliberately perverse,  this guy has form for it.  I believe it was the same person who posted a solution for one day of last years AoC using a Synacor challenge VM.
Title: Re: Advent of Code
Post by: David Martin on December 08, 2016, 04:04:54 pm
I wasn't talking about the sheer brutality of the explicit regexs but some of the other code snippets that get posted.
Title: Re: Advent of Code
Post by: red marley on December 08, 2016, 04:55:49 pm
One of the things I like about AoC is that it works with multiple levels of coding skill and experience and on multiple levels. I can use it with my first year computing students as well as get experienced computer science academic colleagues interested. Some solutions can be created with spreadsheets and even on paper, while others benefit from highly specialised languages. Inevitably there will be some pretty clumsy attempts being shared - but again, this is one of the rewarding educational aspects of the challenge, seeing how not to approach a problem as well as what works.
Title: Re: Advent of Code
Post by: Oaky on December 08, 2016, 05:59:26 pm
I wasn't talking about the sheer brutality of the explicit regexs but some of the other code snippets that get posted.

Ahhh,  I understand now.

I saw one solution posted in which I could see a clear bug (that I knew to be a bug because I initially did the same myself, but it was smoked out of my code by the unit tests I'd written).  The author was fessing up to that bug (and another one) which individually would have got him the wrong answer, but coincidentally conspired to cancel out.
Title: Re: Advent of Code
Post by: David Martin on December 09, 2016, 08:05:10 am
Ah, definitely a step up. Part one done - straightforward once I remembered to
(click to show/hide)

Part 2 is readily tractable but just need to think a little bit further.
Title: Re: Advent of Code
Post by: Pickled Onion on December 09, 2016, 08:09:15 am
My computer is busted, trying to solve them on a phone would be a challenge too far. I'll have to catch up at the weekend   
Title: Re: Advent of Code
Post by: red marley on December 09, 2016, 09:02:00 am
Day 9 (decompression)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 09, 2016, 09:25:58 am
Day 9 (decompression)

(click to show/hide)
Title: Re: Advent of Code
Post by: tom_e on December 09, 2016, 09:49:07 am
My computer is busted, trying to solve them on a phone would be a challenge too far. I'll have to catch up at the weekend

;D  I made the mistake of starting one on the phone because it looked pretty easy.  I did succeed, but it was quite painful.
Title: Re: Advent of Code
Post by: red marley on December 09, 2016, 11:07:29 am
I fail to see how an infinite length string could be produced from finite input with that decompression method.

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 09, 2016, 11:32:24 am
I fail to see how an infinite length string could be produced from finite input with that decompression method.

(click to show/hide)

OK, I see where you are going with that but you are wrong. given that a compressed string must be formed from an uncompressed string, and given the uncompressed string is [A-Z]+ the compressed string given in your example will never occur. I admit that an invalid string can break the algorithm, but a simple check that all processing instructions are complete (ie contain N characters after the instruction where the instruction is (NxY)) should suffice.
Title: Re: Advent of Code
Post by: red marley on December 09, 2016, 11:49:30 am
I would agree if Eric Wastl was generating the potentially tens of thousands of compressed files used by this challenge by applying the compression algorithm to multi-gigabyte originals, that would be all you need to guarantee a 'good' compression sequence. But clearly, the scale of this means he will have been generating the compressed strings directly and algorithmically, and that was my point about his input generating challenge being a significant one.
Title: Re: Advent of Code
Post by: David Martin on December 09, 2016, 12:06:00 pm
But all you need to do is generate a string of valid commands from other valid commands. it is straightforward. You don't need to start with the uncompressed file.

Title: Re: Advent of Code
Post by: red marley on December 09, 2016, 12:17:42 pm
I'm probably digging myself into a hole here by failing to understand the elegance of your suggested approach to input generation, but :

(5x2)ADVENT generates a valid (finite) uncompressed sequence. And (5xn) is in principle a valid compression command, where n is any integer. But (5xn) applied to that valid sequence renders it invalid. What would be a simple way of detecting such invalid modifications (other than the trivial case of always inserting a non-compression sequence of at least 5 characters after a compression command)?
Title: Re: Advent of Code
Post by: David Martin on December 09, 2016, 01:24:30 pm
You ensure that n is len(what follows the command) or greater.

So (5xn)ADVENT is fine but as (5xn)ADVENT is of length 10, the smallest thing that can be included is (10xn)(5xn)ADVENT. Anything less is invalid

So to generate the input you cna basically reverse the grammar definition


text := [Expansion]?[text][text]?

Expansion :=  (Zxlen{following text}) where Y is the length of the following [text] and Z >1

buildtext :
    text = null
    loop until break:
         text = text + random select:
             (random integer x length of)buildtext
             character in [A-Z]
            break
    return text

so text=buildtext will give you, for suitable random parameterisation, a valid compressed string.



Title: Re: Advent of Code
Post by: red marley on December 10, 2016, 07:39:01 am
^---- Nice. (I think, but I've become distracted by the day 10 challenge)
Title: Re: Advent of Code
Post by: red marley on December 10, 2016, 07:52:57 am
Day 10 (bot dancing)

The challenges are getting more interesting, and finally varying a little more from the pattern matching that has dominated the first week or so. With the possible exception of the first day, I think the difficulty curve over time is better than last year as it feels more of a steady increase in effort.

As for today...
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 10, 2016, 09:49:03 am
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 11, 2016, 12:26:06 am
And a dotified version of the solution to today's

(https://c4.staticflickr.com/1/135/31561265035_e5c8dd1f31_k.jpg) (https://flic.kr/p/Q5XJvZ)dotfile (https://flic.kr/p/Q5XJvZ) by David Martin (https://www.flickr.com/photos/davidmam/), on Flickr
Title: Re: Advent of Code
Post by: Diver300 on December 11, 2016, 08:14:49 am
Is the order of applications of the bot rules important?

I got the first part, once some of the chips end up at outputs, I've got 14 bots, each holding one chip, and nothing further happens.

Any suggestions?
Title: Re: Advent of Code
Post by: David Martin on December 11, 2016, 08:36:57 am
Yes, you have to give the bots the inputs and they only transfer when they have both chips to compare. The graph is acyclic.

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 11, 2016, 08:41:46 am

The first proper hard one today.
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 11, 2016, 02:38:07 pm
There is a recursion depth issue. Still bruteforcing it. There may be a way to optimise the strategy but I haven't worked out how to do that yet. This is taking some time. maybe I should set a search order based on energy minimisation?

ETA: Part 1 done. Part 2 adds substantially and my approach may not be suitable. There has to be a smarter way of doing this but I don't see it.

As a measure of difficulty I should plot my leaderboard position against time. It might be quicker to do a binary search of the final answer, waiting a minute between each input than to calculate the answer using my 'crawl the whole net' approach.

ETA:
There is a smarter way.
(click to show/hide)

However, it still looks like a binary search on the correct answer is quicker than brute forcing it.
Title: Re: Advent of Code
Post by: David Martin on December 11, 2016, 04:58:27 pm
Brute force mostly won the day. Got to a position that was a maximum of 6 off but wasn't sure if it was optimal. It wasn't. Iterated back through the odd numbers till I got the right one. There is a one then five then ten minute delay between answer submissions..
Title: Re: Advent of Code
Post by: red marley on December 11, 2016, 06:34:12 pm
Day 11 (elevator isotope exercises)

That was an exercise in humility for me. By far the toughest puzzle yet of 2016, but satisfying nonetheless.

Part 1:
(click to show/hide)

Part 2:
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 11, 2016, 07:37:32 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 11, 2016, 08:10:12 pm
A tiny modification that knocks the Day 11 part 2 solution down to less than 2 seconds computation time:

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 11, 2016, 08:23:30 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 12, 2016, 03:43:33 am
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 12, 2016, 06:05:56 am
Comment on BenT's Day 11 solution:
(click to show/hide)

As for Day 12 - some welcome relief (especially for anyone who did Day 23 last year (http://adventofcode.com/2015/day/23) or the excellent Synacor Challenge (https://challenge.synacor.com)) after spending too much of Sunday in front of the computer. I suspect today isn't the last we'll see of assembly language interpreting.
Title: Re: Advent of Code
Post by: David Martin on December 12, 2016, 06:52:29 am
Day 12 again can be optimised
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 12, 2016, 07:02:45 am
Day 12 (response to David Martin)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 12, 2016, 10:29:01 am
Day 12 (response to David Martin)

(click to show/hide)
But then you would be in 'how to write a compiler 101' territory rather than a short wee puzzle to solve.
Title: Re: Advent of Code
Post by: Ben T on December 12, 2016, 01:24:13 pm
I wonder how difficult it would be to convert the instructions to actual assembly language? If there are equivalents that they would map to on a 1-1 basis.
Title: Re: Advent of Code
Post by: David Martin on December 12, 2016, 01:45:19 pm
And then set each register as a set of binary digits on a front panel display for an arduino for example?

Title: Re: Advent of Code
Post by: Ben T on December 12, 2016, 02:39:02 pm
You can start a C++ program on a normal computer in seconds, and it can include an "asm { ... } " block IIRC. I'm sure one of the instructions is 'mov', which would be similar to their 'jnz', etc. So I was thinking merely output them to the console to then input into the adventofcode site...but if you know a better way knock yourself out :)
Title: Re: Advent of Code
Post by: Oaky on December 12, 2016, 04:07:13 pm
I fell behind on account of running out of time on the train to work on Friday, and having a surfeit of Real Life stuffs at the weekend.  I've since mostly caught up, but I'm leaving Day 11 until tonight when I can have a proper think about it.  That one looks considerably more difficult than the others so far.
Title: Re: Advent of Code
Post by: Diver300 on December 12, 2016, 06:57:36 pm
I converted day 12 into assembly language for a pic24, a 16 bit microcontroller. I ran the code on a simulator on a PC, and found that 32 bit resolution is needed, well more than 16 bits anyhow.

Line numbering went to pot, so I numbered the lines, and therefore the jumps, according to the original input.

Part 2 was then trivial, and took about 10 seconds to run. It would have been <1 second on a real microcontroller.
Title: Re: Advent of Code
Post by: David Martin on December 13, 2016, 08:29:57 am
Haven't attempted day 13 yet but I know the algorithm
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 13, 2016, 08:58:39 am
Or to put it another way (day 13)...

(click to show/hide)
Title: Re: Advent of Code
Post by: Tim Hall on December 13, 2016, 09:22:20 am
The Boy was still stuck on 11 last night, but very pleased with his solution for 12.  He tried describing to me what he'd done, finishing off with "you don't understand this do you?"  I did manage to grasp he was pleased with the elegance of his solution though.
Title: Re: Advent of Code
Post by: David Martin on December 13, 2016, 11:02:12 am
A colleague of mine pointed me at a way to simplify day 13.
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 13, 2016, 11:16:48 am
(click to show/hide)


Title: Re: Advent of Code
Post by: red marley on December 13, 2016, 11:26:00 am
In response to David's colleague's heuristic...

(click to show/hide)
Title: Re: Advent of Code
Post by: tom_e on December 13, 2016, 08:16:57 pm
Managed day 12 with only pencil and paper.  ;D
Title: Re: Advent of Code
Post by: Oaky on December 13, 2016, 08:28:54 pm
Managed day 12 with only pencil and paper.  ;D

I feel guilty if I manually encode the input data into my script rather than reading it from a file and parsing it.  ;)
Title: Re: Advent of Code
Post by: David Martin on December 14, 2016, 01:06:27 am
Code: [Select]
Finally got round to day 13. Easy enough for the first part, second part is giving me a little grief for a reason I cannot fathom.
I've plotted it and worked through by hand but the answer I get appears to be too low for the site. Having checked it exhaustively by hand, I am convinced there is a bug.
[spoiler]
Input is 1350, value I get is 115. This is too low
[/spoiler]

ETA. Read the instructions. The maze bounds are 0,0 not 1,1.
Doh!
[spoiler]
ETA - new answer 122, still wrong.

[code rows=40]#X##X##            ###     ##### ##### 
#X#XXX# ##  ######## # #####   #  ## ##
XX##XX## ## #  #   ### #     #     ## ##
#XX#X# ## #    ##   #  # #### ####   # 
#XX#X## ####### # # #### ## ###   ## # 
##X#XXX#  #    ## #   #    #    #  # # #
##XXX#X#  # ##    #   ## #  #### #   # 
# ##XXX# ## #### ####  ## # #  ## ##  ##
#####XX#     ###  # #   #   #   ###### 
  ####X###      #  #### ## ### #  ## ###
#  ###X##### ##### ## ## #  ##  #   #   
##  #XXXX#X###  ##   # #  # # #  ##   ##
    #XX#XXXXX#     #  ##### #  # # #####
## #### ####X#  ##### ##  # ###  ###  ##
## #XX###XXXX## #  ##  #  ### ###   #  #
#  ##XXXXX##X##      # # #  #     #  # 
### #X######X##### #  ## #  # ###  #   #
XXX##X##  #XXXXXX## #    # ##   ### ####
X#XXXXXX# #XX##X# #  ##  #   ###  # #  #
XX##XX#X# #####X# ############ ####     
## ##XXX###  #XX##    #  #    #  ##### #
 #  ##X#     #X# ####    # ##        ##
######X# ##  #XX#XX####### ##### ## # ##
##XXX#X##### ##XXXXXX#  #   #  #### ## #
 #X#XXXXXX## # ##XX#XX# ##  # #        #
 ## #####X#  ## ### #X#  # ## # ##  ## #
  # #  ##X### ##  ##XX# ##    ## ##### #
  #     ##   # ##  # ##   ## # ##   #   
######    ## ## # ## # ### # ## #   #  #
     #  #  #   ## #  ### # #   ### ####
 ##  ### #   #    #     ##  ##  ## #  #
#####  ## ##  ## ###### # #   # #  #  #

Sorted: There was a hidden sidestep that added two to the path length.
[/spoiler]
Title: Re: Advent of Code
Post by: red marley on December 14, 2016, 06:34:13 am
Day 14 Hash-mash

People who liked Day 5 will love Day 14.

Hint:
(click to show/hide)


I like to start each day by making at least one stupid mistake before breakfast. Today's was

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 14, 2016, 07:30:22 am
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 14, 2016, 09:17:11 am
For Diver300:
(click to show/hide)

For Jo:
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 14, 2016, 09:31:03 am

(click to show/hide)

I did that one too.

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 14, 2016, 09:49:08 am
Day 14....
Hint:
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 14, 2016, 10:05:47 am
Day 14....
Hint:
(click to show/hide)

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 14, 2016, 11:27:33 am
Day 14 continued...

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 14, 2016, 03:44:26 pm
Day 14

(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 14, 2016, 04:03:15 pm
Day 14

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 14, 2016, 04:32:31 pm
Managed day 12 with only pencil and paper.  ;D
I've just belatedly solved day 11 similarly.
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 14, 2016, 04:33:57 pm
Mine sounds very much like Oaky's using a dict of arrays to store candidate indices which can then be reviewed if pentuples are found.
Title: Re: Advent of Code
Post by: tom_e on December 14, 2016, 05:04:32 pm
Managed day 12 with only pencil and paper.  ;D
I've just belatedly solved day 11 similarly.

It's an interesting question - I have some sympathy for Oaky's point of view above.  Any question where the input is quite small is potentially vulnerable to a more pure mathematical approach.  Particularly something like day 11 where the answer is relatively small and you get more than one attempt.

In this case, I'd argue you've crossed that fine line to guessing.  But since I am myself putting the first answer produced by code into the box and only going back to check for bugs if it fails (and suspect I am not alone in this), I'm not sure how clear-cut the "guessing is cheating" argument is.

Also, note (https://www.reddit.com/r/adventofcode/comments/5hoia9/2016_day_11_solutions/db1v1gk/).
Title: Re: Advent of Code
Post by: Oaky on December 14, 2016, 06:01:23 pm
Managed day 12 with only pencil and paper.  ;D
I've just belatedly solved day 11 similarly.
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 14, 2016, 06:13:20 pm
Managed day 12 with only pencil and paper.  ;D
I've just belatedly solved day 11 similarly.
(click to show/hide)

(click to show/hide)

I agree.

I am not arguing that my solution is in any way robust. The example that you give is intentionally awkward, and I think that the puzzle always starts with the elevator on the ground floor, and it has to be soluble, so I don't think that real puzzles can be quite as awkward as yours, but I am sure there are some that have to start with less efficient moves.

I suspect that once the initial awkwardness is sorted, the  bulk of a solution is perfectly efficient, but I haven't proved it.

We shall see if later puzzles leave me lost due to my lack of rigor in day 11
Title: Re: Advent of Code
Post by: Oaky on December 14, 2016, 06:38:53 pm
Managed day 12 with only pencil and paper.  ;D
I've just belatedly solved day 11 similarly.
(click to show/hide)

(click to show/hide)

I agree.

I am not arguing that my solution is in any way robust. The example that you give is intentionally awkward, and I think that the puzzle always starts with the elevator on the ground floor, and it has to be soluble, so I don't think that real puzzles can be quite as awkward as yours, but I am sure there are some that have to start with less efficient moves.

I suspect that once the initial awkwardness is sorted, the  bulk of a solution is perfectly efficient, but I haven't proved it.

We shall see if later puzzles leave me lost due to my lack of rigor in day 11

 ;D

BTW - I gather that the position I quoted (from p_tseng's reddit post), is a subset of a position that occurs during the optimal solution of an actual input that somebody was given.

Title: Re: Advent of Code
Post by: red marley on December 14, 2016, 11:25:15 pm
Day 14 speed of calculation.

Given the various ways of finding a solution seemed to result in quite different times taken to calculate, I thought I'd have a look at where the bottleneck was when using Java.
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 15, 2016, 07:43:07 am
(click to show/hide)

Day 15:
Straightforward.
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 15, 2016, 08:02:48 am
Why do you need to convert to lower case? It isn't material to the problem.

Because...

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 15, 2016, 09:02:38 am
Day 15:
Straightforward.
(click to show/hide)
(click to show/hide)
As is often the case, part 1 could be solved by brute force, but the seemingly small addition of part 2 made brute force impractical so thinking was needed. My first solution to part 2 depended on the brute force solution to part 1, which made me realise that a far faster and more elegant solution was possible to part 1.

Title: Re: Advent of Code
Post by: David Martin on December 15, 2016, 09:31:39 am
Smartish brute force.. in my case, though it should be possible to describe the equation analytically.
Title: Re: Advent of Code
Post by: Oaky on December 15, 2016, 09:42:58 am
Dumb brute force for both parts (Python 2).

Part 1 runs in ~0.6 sec and Part 2 in ~2.1 sec.

I had a feeling when I set it away using the same brute force that part 2 was going to take too long that way and that I'd have to go back and recode it to be smarter, and was surprised when that wasn't the case.

I did go back and apply a couple of optimisations to my discStack class:-

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 15, 2016, 09:56:17 am
Day 15 really easy. No optimizations even remotely necessary. Both parts run instantaneously
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 15, 2016, 10:48:44 am
Day 15 one liner
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 15, 2016, 11:29:21 pm
After day 15's relatively easy problem, what's the betting day 16 is going to be a stinker?
Title: Re: Advent of Code
Post by: Oaky on December 16, 2016, 05:48:51 am
After day 15's relatively easy problem, what's the betting day 16 is going to be a stinker?

Apparently not.

(click to show/hide)

What am I going to do with the rest of my morning?  Might have to do some work! ;D
Title: Re: Advent of Code
Post by: red marley on December 16, 2016, 06:14:26 am
I didn't really dig today's (Day 16). Just grinding though some standard string manipulation, which is more or less tedious depending on your language of choice.

Yesterday's was more interesting because of there was plenty of scope for optimisation and was good practice for taking a functional approach (and unlike Day 11, could be done before breakfast).
Title: Re: Advent of Code
Post by: Diver300 on December 16, 2016, 06:17:09 am
After day 15's relatively easy problem, what's the betting day 16 is going to be a stinker?

Apparently not.

(click to show/hide)

What am I going to do with the rest of my morning?  Might have to do some work! ;D
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 16, 2016, 06:25:35 am
After day 15's relatively easy problem, what's the betting day 16 is going to be a stinker?

So, day 16 was another easy one.  After this much respite, I'm getting anxious about what Mr Wastl has in store for us next.

(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 16, 2016, 06:59:13 am
Quite sensibly, our toughest one this year (Day 11) was at the weekend. Last year, arguably the toughest one was Day 19 (molecules), also at the weekend. So perhaps we should brace ourselves for a toughie either tomorrow or the day after. I'm sure he wouldn't be so cruel as to set a time consuming challenge the following weekend given we may have other commitments on Sunday morning.
Title: Re: Advent of Code
Post by: Ben T on December 16, 2016, 09:48:24 am
Recently went back and did Day 24 of last year and thought that was pretty hard (partitioning).
https://github.com/bjtaylor1/AoC_2015/blob/master/Day24/UnitTest1.cs
Title: Re: Advent of Code
Post by: Oaky on December 16, 2016, 10:20:42 am
for 2015, day 19 part 2 was the absolute hardest IMO.
Title: Re: Advent of Code
Post by: David Martin on December 16, 2016, 10:44:12 am
Looking at todays (Just got to it, running part 2), it flips the checksum (almost) with each doubling, so the checksum may be calculable from the starting code without needing to calculate the entire string.

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 16, 2016, 12:28:16 pm
for 2015, day 19 part 2 was the absolute hardest IMO.

That's where I got stuck. This year I've skipped a second part. Maybe I should go back and look at the 2015 ones
Title: Re: Advent of Code
Post by: red marley on December 16, 2016, 02:21:09 pm
I didn't really dig today's (Day 16). Just grinding though some standard string manipulation, which is more or less tedious depending on your language of choice.

I was wrong about this. Looking elsewhere (no links here to avoid obvious spoilers), there are some really elegant ways of processing the input that stop this being such an iterative task. If anyone's feeling like they've done too much proper work today, there's plenty of scope for thinking about some nifty optimisations. I should never have doubted Mr Wastl. What makes these challenges great is their hidden depths.
Title: Re: Advent of Code
Post by: Ben T on December 16, 2016, 04:16:35 pm
I didn't really dig today's (Day 16). Just grinding though some standard string manipulation, which is more or less tedious depending on your language of choice.

I was wrong about this. Looking elsewhere (no links here to avoid obvious spoilers), there are some really elegant ways of processing the input that stop this being such an iterative task. If anyone's feeling like they've done too much proper work today, there's plenty of scope for thinking about some nifty optimisations. I should never have doubted Mr Wastl. What makes these challenges great is their hidden depths.

That's fine, although my viewpoint would be that if iteration works fast enough then any further optimisation is straying from science into art :)
I was hoping he was going to say that the memory would be something like many GB, not 272.

for 2015, day 19 part 2 was the absolute hardest IMO.

That's where I got stuck. This year I've skipped a second part. Maybe I should go back and look at the 2015 ones

Having done 2016 day 11, 2015 day 19 part 2 wasn't that hard as it's a similar principle:
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 16, 2016, 07:28:37 pm
I didn't really dig today's (Day 16). Just grinding though some standard string manipulation, which is more or less tedious depending on your language of choice.

I was wrong about this. Looking elsewhere (no links here to avoid obvious spoilers), there are some really elegant ways of processing the input that stop this being such an iterative task. If anyone's feeling like they've done too much proper work today, there's plenty of scope for thinking about some nifty optimisations. I should never have doubted Mr Wastl. What makes these challenges great is their hidden depths.

That's fine, although my viewpoint would be that if iteration works fast enough then any further optimisation is straying from science into art :)
I was hoping he was going to say that the memory would be something like many GB, not 272.

for 2015, day 19 part 2 was the absolute hardest IMO.

That's where I got stuck. This year I've skipped a second part. Maybe I should go back and look at the 2015 ones

Having done 2016 day 11, 2015 day 19 part 2 wasn't that hard as it's a similar principle:
(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 17, 2016, 08:29:22 am
And day 17 appears. I may have to think a little.
Title: Re: Advent of Code
Post by: Oaky on December 17, 2016, 04:45:22 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 17, 2016, 06:28:31 pm
Finally got round to part 1. Part 2 is running, hopefully without an infinite loop.

ETA: hopes were in vain but infinity was removed and results obtained.
Title: Re: Advent of Code
Post by: Ben T on December 17, 2016, 07:02:33 pm
On Day 17 part 2,
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 17, 2016, 07:19:15 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 17, 2016, 08:02:45 pm
(click to show/hide)
 
Title: Re: Advent of Code
Post by: red marley on December 17, 2016, 08:40:15 pm
I thought I'd do a bit of analysis of challenge difficulty (http://gicentre.net/aoctimes), as measured by leaderboard completion time, to see what we have in store for the rest of 2016 (my guess: a toughie tomorrow and a more challenging final week)
Title: Re: Advent of Code
Post by: Ben T on December 18, 2016, 12:08:36 am
The times (and thus points) are definitely skewed though because it makes no observation of when you started it.
Did someone finish it early because they're better at coding or just because they could be bothered to get up early...
For instance, I have to be at my desk in the week, so usually start it at 9 am, but didn't even look at today's till at least 4pm.
Title: Re: Advent of Code
Post by: red marley on December 18, 2016, 05:58:15 am
Except that the leaderboard from which those stats were derived is only the first 100 finishers. Looking at the reddit discussions it is clear that all those who feature in the top 100 will have started the second the day's puzzle was released (with the exception of day 1, 2015 which I excluded).
Title: Re: Advent of Code
Post by: red marley on December 18, 2016, 07:02:52 am
Day 18 (trapped tiles)

(click to show/hide)

(Edited to provide a more seasonal image of the tile layout [and a design for some rather natty Christmas underpants])
Title: Re: Advent of Code
Post by: David Martin on December 18, 2016, 07:52:39 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 18, 2016, 11:00:28 am
I've just caught up with day 17. Reading the question fully would have save some time.
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 18, 2016, 11:01:47 am
Did you manage to skip any rows, i.e. avoid having to do every single 400,000 transformations, or doesit just improve the speed at which you can generate each row from the next.
I thought if it repeated at, say, 100,000, then you could simply multiply the result at that point by 4. But it doesn't.

The ones I really like are where an optimization is essential rather than just pretty.
Title: Re: Advent of Code
Post by: red marley on December 18, 2016, 02:23:00 pm
Did you manage to skip any rows, i.e. avoid having to do every single 400,000 transformations, or doesit just improve the speed at which you can generate each row from the next.

(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 19, 2016, 08:11:45 am
Day 19 (present nabbing)

Great problem today. I like it because it can be tackled from several different angles (with varying degrees of efficiency). A little more challenging in part because if you calculate the wrong result it is not immediately obvious why, so debugging can be more difficult (DAMHIKT).
Title: Re: Advent of Code
Post by: David Martin on December 19, 2016, 08:17:37 am
Actualy part 1 is analytic

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 19, 2016, 09:12:23 am
As is part 2 but slightly different as it is not continuous as a quick simulation of the first 45 parties shows (from 5-99 elves)
(click to show/hide)


Very pleased to have solved it elegantly without needing to brute force it.
Title: Re: Advent of Code
Post by: Ben T on December 19, 2016, 10:51:12 am
day 19 part 1:
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 19, 2016, 01:10:50 pm
day 19 part 2:
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 19, 2016, 05:53:25 pm
generic iterator template for branch style problems
https://github.com/bjtaylor1/AoC_2016/blob/master/puzzle_iterator.h
used in day 17: https://github.com/bjtaylor1/AoC_2016/blob/master/Day17b/Day17b.cpp
part 2 runs in sub-10s in release mode with /Ox.

also works for 2015 day 19 1+2.

Title: Re: Advent of Code
Post by: Oaky on December 19, 2016, 07:26:42 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 20, 2016, 07:28:37 am
That wasn't particularly challenging - or maybe I am missing something
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 20, 2016, 08:07:50 am
I agree.

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 20, 2016, 10:52:35 am
(click to show/hide)
Title: Re: Advent of Code
Post by: tom_e on December 20, 2016, 11:11:00 am
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 20, 2016, 01:07:19 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 20, 2016, 01:21:04 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 20, 2016, 06:41:00 pm
That wasn't particularly challenging - or maybe I am missing something
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 20, 2016, 10:19:38 pm
I was looking at the problem and thinking that it maps onto a typical biological problem 'which parts of my gene have no sequence coverage?'

I'm not sure there is a specific tool for that - I'd probably write a similar script +/- the parsing of appropriate formats.
Title: Re: Advent of Code
Post by: Ben T on December 21, 2016, 12:37:24 pm
Day 21 relies on realising the fact that
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 21, 2016, 12:49:58 pm
Not done it yet. Broadband outage at home so I have sneaked into the office to get it onto the PC. Will look at it tonight, but it doesn't seem so hard.
Not looked at the spoilers either.
Title: Re: Advent of Code
Post by: R_nger on December 21, 2016, 01:29:39 pm
What's happening to Jo"s leader board ? Some mischievous anonymous user(s) having fun ?
Title: Re: Advent of Code
Post by: tom_e on December 21, 2016, 01:41:52 pm
 ::-)  <tries to look innocent and not childish>
Title: Re: Advent of Code
Post by: R_nger on December 21, 2016, 01:53:17 pm
::-)  <tries to look innocent and not childish>
LOL... I just popped over to the CDC thread...and you've beaten me to it !!
Title: Re: Advent of Code
Post by: red marley on December 21, 2016, 02:33:50 pm
Anonymous user 107436 needs to get their act together and get a nice silver star for Day 14.
Title: Re: Advent of Code
Post by: tom_e on December 21, 2016, 02:46:36 pm
Yeah, I couldn't decide about that pixel.  A spurt would take too many rows, and I'm already norty flagged on github now.

Just for you, jo.
Title: Re: Advent of Code
Post by: red marley on December 21, 2016, 03:12:54 pm
Day 21 relies on realising the fact that
(click to show/hide)

Or

(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 21, 2016, 04:41:06 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 21, 2016, 05:37:49 pm
Day 21 relies on realising the fact that
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 21, 2016, 09:02:49 pm
Day 21 relies on realising the fact that
(click to show/hide)

(click to show/hide)
From 5 onwards your rotation is wrong. 

Sent from my SM-G920F using Tapatalk

Title: Re: Advent of Code
Post by: David Martin on December 21, 2016, 11:57:50 pm
Ok, guilty of not reading the instructions. Fortunately I could grab the data at work today but have to enter the answers with the phone as I currently have no broadband. So slightly delayed but now there.

Sent from my SM-G920F using Tapatalk

Title: Re: Advent of Code
Post by: red marley on December 22, 2016, 08:05:02 am
Day 22 (grid computing)

Nice meaty challenge today. First part straightforward but I have to go to work now before getting a solution for second part. Will think about it on way in.
Title: Re: Advent of Code
Post by: David Martin on December 22, 2016, 09:01:14 am
Likewise. Part 1 was straightforward, almost a one-liner in python.
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 22, 2016, 01:09:41 pm
Part 2: Not much coding needed here - easy to do by inspection and simple arithmetic.
(click to show/hide)

Title: Re: Advent of Code
Post by: Oaky on December 22, 2016, 04:30:13 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 22, 2016, 04:39:29 pm
^--- Probably a bit of an unhidden spoiler there David.


(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 22, 2016, 09:27:11 pm
I am attempting to fill in the blanks from last years. The lack of a daily deadline doesn't seem to help.

I do think that many of them are harder than this year. The one I am currently toying with is the elves delivering presents. It is obviously some heinous factorial problem, but instead of a straight sum of factors, it is a sum of the product of every permutation.
Wondering about some sort of branch and bound strategy, and being able to set a suitable bound on the number of primes to consider.

Title: Re: Advent of Code
Post by: red marley on December 22, 2016, 10:26:36 pm
I do think that many of them are harder than this year.

We've still got three days to go yet.  :demon:

But I agree with you. The average completion time of the top 100 finishers last year was 26 min 50s; this year so far it has been 23 min 25s. One difference (which I like) is that the hardest questions this year (Day 11 lifts; Day 19 elf present stealing; Day 22 grid computing) have all had a trick/heuristic that makes the problem considerably easier to solve.

If you want a gentle clue for the present permutation problem from last year:
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 23, 2016, 06:42:15 am
Day 23  (more assembunny)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 23, 2016, 08:59:40 am
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 23, 2016, 02:56:14 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 23, 2016, 04:58:40 pm
Did you put that into the program to generalise from any set of instructions? I had thought about trying that but didn't have time. The challenge means different things to different folks.
Title: Re: Advent of Code
Post by: Ben T on December 23, 2016, 06:07:59 pm
I haven't found a programmatic solution to day 22 or day 23 that will work with anybody's input.

Day 22 is a perfect example of something a human is good at solving based on what they see visually but a computer isn't.
(click to show/hide)

 Day 23,
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 23, 2016, 06:33:58 pm
I haven't found a programmatic solution to day 22 or day 23 that will work with anybody's input.

Day 22 is a perfect example of something a human is good at solving based on what they see visually but a computer isn't.
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 23, 2016, 10:27:44 pm
I haven't found a programmatic solution to day 22 or day 23 that will work with anybody's input.

Day 22 is a perfect example of something a human is good at solving based on what they see visually but a computer isn't.
(click to show/hide)

(click to show/hide)


(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 23, 2016, 10:35:18 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 24, 2016, 09:23:23 am
Day 24: A bigger challenge

(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 24, 2016, 10:08:33 am
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 24, 2016, 01:02:10 pm
Oh dear - some stupid mistakes cost me plenty of time which meant with other Christmas stuff going on, I had to leave it a while before resuming.

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 24, 2016, 02:26:10 pm
I haven't found a programmatic solution to day 22 or day 23 that will work with anybody's input.

Day 22 is a perfect example of something a human is good at solving based on what they see visually but a computer isn't.
(click to show/hide)

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 24, 2016, 02:38:27 pm
(That woe is day 24 not day 23... ) but:
(click to show/hide)
Title: Re: Advent of Code
Post by: red marley on December 24, 2016, 02:38:53 pm
^--- (Ben's Day 22) Sure, but with a grid of only c. 30x30 or so cells, shouldn't it soon exhaust that bottom right corner and find a better route past the wall?

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 24, 2016, 02:42:27 pm
^--- (Ben's Day 22) Sure, but with a grid of only c. 30x30 or so cells, shouldn't it soon exhaust that bottom right corner and find a better route past the wall?

(click to show/hide)
maybe, yeah - I'll revisit and try and find out why it doesn't. I think the reason may be that the hash is 'too unique', i.e. it cares (too much) about the position of actual data rather than just the position of the space.
Title: Re: Advent of Code
Post by: David Martin on December 24, 2016, 03:35:02 pm
Hmm.. Just got back to this and I think my code is really inefficient compared to the times reported. Still running DFS (maybe BFS would be better?)
Title: Re: Advent of Code
Post by: Ben T on December 24, 2016, 04:10:05 pm
Hmm.. Just got back to this and I think my code is really inefficient compared to the times reported. Still running DFS (maybe BFS would be better?)
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 24, 2016, 04:19:29 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 24, 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...
Title: Re: Advent of Code
Post by: David Martin on December 24, 2016, 09:13:09 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 25, 2016, 12:22:19 pm
Today's is quite fun.

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 25, 2016, 01:22:42 pm
(click to show/hide)

or slightly more terse but less calculation:
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 26, 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)
Title: Re: Advent of Code
Post by: David Martin on December 26, 2016, 09:51:47 pm
Very neat.
Title: Re: Advent of Code
Post by: Pickled Onion on December 26, 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...
Title: Re: Advent of Code
Post by: Ben T on December 29, 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.
Title: Re: Advent of Code
Post by: Oaky on November 30, 2017, 12:46:51 pm
2017 AoC in about 16 hours time! :)
Title: Re: Advent of Code
Post by: Greenbank on November 30, 2017, 01:17:00 pm
ooh, signed up

(And going back and doing 2016 as practice...)
Title: Re: Advent of Code
Post by: Diver300 on November 30, 2017, 07:51:42 pm
2017 AoC in about 16 hours time! :)
Arrgghhh!

December productivity will be at it's usual post 2015 levels.
Title: Re: Advent of Code
Post by: David Martin on December 01, 2017, 12:03:08 am
That's the marking taking a back seat then.

Is there a YACF league?
Title: Re: Advent of Code
Post by: Croft on December 01, 2017, 06:27:38 am
From previous years, the YACF leaderboard code is 48462-ea506236
Title: Re: Advent of Code
Post by: davelodwig on December 01, 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.
Title: Re: Advent of Code
Post by: Oaky on December 01, 2017, 01:03:09 pm
I'm using Python again,  trying to use Pandas/numpy wherever possible.

(click to show/hide)
Title: Re: Advent of Code
Post by: freeflow on December 01, 2017, 03:03:31 pm
Done today's using VBA. Tomorrow I'll try python.
Title: Re: Advent of Code
Post by: David Martin on December 01, 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)
Title: Re: Advent of Code
Post by: Pickled Onion on December 01, 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?
Title: Re: Advent of Code
Post by: Greenbank on December 01, 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.
Title: Re: Advent of Code
Post by: David Martin on December 01, 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.
Title: Re: Advent of Code
Post by: Pickled Onion on December 01, 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)
Title: Re: Advent of Code
Post by: Greenbank on December 02, 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).
Title: Re: Advent of Code
Post by: Pickled Onion on December 03, 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.
Title: Re: Advent of Code
Post by: David Martin on December 03, 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)
Title: Re: Advent of Code
Post by: Pickled Onion on December 03, 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:
Title: Re: Advent of Code
Post by: Greenbank on December 03, 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)
Title: Re: Advent of Code
Post by: Pickled Onion on December 03, 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?
Title: Re: Advent of Code
Post by: David Martin on December 03, 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.

Title: Re: Advent of Code
Post by: Oaky on December 03, 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)
Title: Re: Advent of Code
Post by: Diver300 on December 03, 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
Title: Re: Advent of Code
Post by: Greenbank on December 04, 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.
Title: Re: Advent of Code
Post by: Croft on December 04, 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.
Title: Re: Advent of Code
Post by: David Martin on December 04, 2017, 10:54:46 am
Today's was very much a start of week 1 problem.
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 04, 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.
Title: Re: Advent of Code
Post by: Croft on December 04, 2017, 11:20:04 am
Medicine for Rudolph (Day 19, 2015)

(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 04, 2017, 11:58:23 am
Today's was very much a start of week 1 problem.
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 04, 2017, 11:07:28 pm
My pandas fu is not that developed.
Title: Re: Advent of Code
Post by: Diver300 on December 05, 2017, 06:38:14 am
Day 5 seemed quite straightforward.

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 05, 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...)
Title: Re: Advent of Code
Post by: David Martin on December 05, 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.
Title: Re: Advent of Code
Post by: David Martin on December 06, 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)
Title: Re: Advent of Code
Post by: Greenbank on December 06, 2017, 08:07:03 am
Day 6:

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 06, 2017, 11:06:02 am
Day 6:
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 06, 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)
Title: Re: Advent of Code
Post by: David Martin on December 06, 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)
Title: Re: Advent of Code
Post by: Oaky on December 06, 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)
Title: Re: Advent of Code
Post by: Diver300 on December 06, 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)
Title: Re: Advent of Code
Post by: David Martin on December 07, 2017, 07:54:45 am
That was a bit more satisfying.. Note: read the text more carefully.
Title: Re: Advent of Code
Post by: Greenbank on December 07, 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.
Title: Re: Advent of Code
Post by: David Martin on December 07, 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)
Title: Re: Advent of Code
Post by: Greenbank on December 07, 2017, 11:41:07 am
Day 7:

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 07, 2017, 01:21:28 pm
Day 7:

(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 07, 2017, 01:41:31 pm
Day 7:

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 07, 2017, 01:47:42 pm
That reminds me of the reddit competition to find the most ridiculous way to test if a number was even or odd.
It is order(N) for every lookup, making it approach order (N^2) overall.

(click to show/hide)

Title: Re: Advent of Code
Post by: Ben T on December 07, 2017, 02:07:42 pm
did it in a probably over verbose OO way https://github.com/bjtaylor1/AoC2017/blob/day07part2/Day07/App.cs but didn't take long and was basically shot from the hip and didn't require any debugging to get right pretty much first time
Title: Re: Advent of Code
Post by: Greenbank on December 07, 2017, 02:41:40 pm
Day 7:

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 07, 2017, 04:10:34 pm
OK, here is my python
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 07, 2017, 04:15:17 pm
Day 7:

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 07, 2017, 05:20:46 pm
can you not (instead of the two cases) do:

Almost certainly, but that file was pretty much the first thing that gave me the correct answer (whether it prints it explicitly like mine, or gives enough information to work out the answer like yours). I don't bother polishing it once I've submitted a correct answer. If I was going to use it for anything else in the future then I'd spend some time refactoring it and adding suitable comments. I'd also consider how it would handle much larger inputs.

The last thing I want to be doing is chasing bugs in the code that reads the input, so I've no problem with a bit of duplication there.

[EDIT] It's only when the problems start to get properly challenging that I will take more care on my programs. My goal is to get the answer as quickly as possible (and in a reasonable execution time). The competition is not really making me learn anything new (if you want that then the Valladolid Online Judge or Project Euler are much better).
Title: Re: Advent of Code
Post by: Pickled Onion on December 07, 2017, 09:48:05 pm
My goodness I made a meal out of that one. Must remember to read the question properly  :facepalm:
Title: Re: Advent of Code
Post by: David Martin on December 07, 2017, 10:49:09 pm
Thanks for the links to Project Euler and the Valladolid Judge sites. Interesting challenges though the sites are not terribly clear on how they work.
Title: Re: Advent of Code
Post by: Greenbank on December 07, 2017, 10:58:36 pm
Valladolid was submit your code by email (at least when I was doing it back in 2001!). The automated system then sanitised it (to make sure you weren't doing anything silly or destructive) and then ran the code against an unseen input.

Their trick was the example inputs you got given on the website were a fraction of the size of the real input (which you never saw), or the real input was the pathological case for the standard algorithm.

So many times I'd be confident about my code, email it off, only to receive a "Time Limit Exceeded" response.

Can't remember much about Project Euler, only did one or two but I discussed a lot of the problems with someone from work I was mentoring.

Day 8: Will it be another fake CPU question (I do like them) or something like a knapsack or another TSP-esque classic?
Title: Re: Advent of Code
Post by: David Martin on December 07, 2017, 11:06:44 pm
We have had the first tree traversal one. Must be some magic codes to parse (medicine for rudolf). Still in early days so shouldn't be too taxing (hostage to fortune there).
Title: Re: Advent of Code
Post by: Diver300 on December 07, 2017, 11:11:19 pm
Day 7
Solved with a spreadsheet. It did get quite big but not as large as many I written that have a more serious purpose.
Title: Re: Advent of Code
Post by: David Martin on December 07, 2017, 11:34:22 pm
I cannot imagine voluntarily choosing to do it that way. It makes me cringe even thinking about it.
Title: Re: Advent of Code
Post by: Oaky on December 07, 2017, 11:50:43 pm
Day 7 p2 is still not done.

RL has got in the way -- I can see two ways of attacking it, both of which should work, but haven had the time yet to give either a go.

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 08, 2017, 12:01:05 am
Recursion works when recursion works.
What is the non-recursive approach?
Title: Re: Advent of Code
Post by: Diver300 on December 08, 2017, 06:18:02 am
I cannot imagine voluntarily choosing to do it that way. It makes me cringe even thinking about it.

There towers are only 6 levels high, so finding a group of formulas that works, and copying across until there are no more sub-towers doesn't take long
The spreadsheet was 6000 lines long, as each step ended up at 9 lines. In retrospect 10 would have been easier on the brain.
Title: Re: Advent of Code
Post by: Diver300 on December 08, 2017, 06:20:41 am
Day 8 didn't seem all that difficult.
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 08, 2017, 07:41:36 am
Pretty much
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 08, 2017, 09:38:23 am
Day 8:

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 08, 2017, 10:53:29 am
self contained dynamic compilation https://github.com/bjtaylor1/AoC2017/blob/day08part2/Day08/Program.cs
essentially the same, my TranslateCode function is your line of sed and my main function is orchestrating the running of it.
Title: Re: Advent of Code
Post by: Greenbank on December 08, 2017, 02:00:05 pm
Day 8: Will it be another fake CPU question (I do like them) or something like a knapsack or another TSP-esque classic?

And, lo, it was a fake CPU type question.

I wrote an interpreter for my solution before doing the above horrific command line transpose nonsense.

Will we get a couple of biggies to do over the weekend? I hope so!
Title: Re: Advent of Code
Post by: Oaky on December 08, 2017, 04:08:02 pm
Finally got round to doing day 7 part 2.  (after knocking out day 8 )

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 08, 2017, 04:42:47 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 09, 2017, 01:08:39 am
Hoping to sober up enough to be able to do Day 9 tomorrow today.

Hic.

I foresee much keyboard thrashing and grumpiness...
Title: Re: Advent of Code
Post by: Ben T on December 09, 2017, 10:16:07 am
nothing taxing as long as you don't try and be too fancy.
Title: Re: Advent of Code
Post by: Greenbank on December 09, 2017, 11:06:57 am
I've written enough stuff that parses input (specifically SQL and CSV) to understand the joy of string parsing with escape characters. Even with a slightly foggy brain from a mild hangover.

(click to show/hide)
Title: Re: Advent of Code
Post by: Manotea on December 09, 2017, 11:42:40 am
Inspired by Greenbank, I started reading this (https://www.gamedev.net/articles/programming/general-and-gameplay-programming/finite-state-machines-and-regular-expressions-r3176/)

Then realised I had something else to do today.  :)
Title: Re: Advent of Code
Post by: Ben T on December 09, 2017, 01:54:14 pm
I've written enough stuff that parses input (specifically SQL and CSV) to understand the joy of string parsing with escape characters. Even with a slightly foggy brain from a mild hangover.

(click to show/hide)

I'm reasonably au fait with regex but wouldn't attempt to use it to try and count group nesting.... I didn't see any need for recursion but whether it could have made it more elegant I don't know. Mine's a fairly simple literal interpretation of the logic as described https://github.com/bjtaylor1/AoC2017/blob/day09part2/Day09/Program.cs
nothing wrong with recursion if you just like it though :)
Title: Re: Advent of Code
Post by: Pickled Onion on December 09, 2017, 03:23:24 pm
...then a second one to parse the garbage free input into the groups, then a recursive function to score it all.
The input was well-formed enough that it only required counting the { up and } down

Quote
I'm secretly hoping that someone attempts this with a regex and eventually learns the lesson about regular expressions and context-free grammars.

This particular one would be fairly straightforward with a regex, but yes it's the perennial question "how do I parse **ML with a regex?" A: DON'T!!

For a laugh I solved this (https://www.gchq.gov.uk/news-article/christmas-card-cryptographic-twist-charity) using regular expressions, it took rather longer to code than doing it with a pencil but the result was quite impressive nonetheless.
Title: Re: Advent of Code
Post by: David Martin on December 09, 2017, 04:02:32 pm
Just plough through and process it as a stream.

(click to show/hide)

I did come across an interesting puzzle that was easily solved to a certain state with matrix algebra. I then have to sort a matrix to get the minimum diagonal to get the appropriate order of rows.
Title: Re: Advent of Code
Post by: Oaky on December 09, 2017, 04:49:26 pm
Just plough through and process it as a stream.

(click to show/hide)

I did come across an interesting puzzle that was easily solved to a certain state with matrix algebra. I then have to sort a matrix to get the minimum diagonal to get the appropriate order of rows.

I don't think you pushed your day 9 changes to github yet ;)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 09, 2017, 07:14:02 pm
Good spot. Didn't tick the 'push to origin automatically' box in Sourcetree.
Title: Re: Advent of Code
Post by: Oaky on December 09, 2017, 08:40:38 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 10, 2017, 06:27:17 am
The instructions for day 10 almost lead you though the programming steps needed. It reads more like a lesson in computing than a puzzle.
Title: Re: Advent of Code
Post by: David Martin on December 10, 2017, 08:59:01 am
Agreed. Involved but not hard. Bleary eyed typos notwithstanding. Not sure I have the oomph in the morning to test-suite it. I'd have sorted the tests after finding the things that needed to be tested, by which time they would be unnecessary.
Title: Re: Advent of Code
Post by: David Martin on December 11, 2017, 07:20:21 am
Ouch - my head hurts a bit after trying to sort that one out. Probably an inelegant solution to calculate the total number of steps. I'm sure there must be a better way to resolve the axes than a series of if/else looking at the relevant cases. Possibly something matrixy but my brain isn't functioning.
Title: Re: Advent of Code
Post by: Croft on December 11, 2017, 07:37:02 am
Day 11

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 11, 2017, 10:14:45 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Croft on December 11, 2017, 10:41:34 am
Day 11

(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 11, 2017, 11:15:05 am
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 11, 2017, 12:25:55 pm
Day 11

(click to show/hide)
I must admit that trying to sort that at early morning after dealing with a frozen pipe leading to a major water leak in the house was challenging enough - I thought it should be able to be done something like that. Instead I did it the hard way.
Title: Re: Advent of Code
Post by: David Martin on December 11, 2017, 12:59:04 pm
Day 11

(click to show/hide)

I am struggling to see how you come up with that matrix.

Title: Re: Advent of Code
Post by: Greenbank on December 11, 2017, 01:45:59 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Croft on December 11, 2017, 01:47:29 pm
Greenbank beat me to it, but..
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 11, 2017, 03:33:59 pm
Doh! I was looking at steps but not in the right directions.
Title: Re: Advent of Code
Post by: Greenbank on December 11, 2017, 08:22:17 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 12, 2017, 07:45:31 am
Underwhelming today...

Jo's graphs seem to back up my suspicion that 2017 (so far at least) is quite a bit easier than the previous years: https://github.com/jwoLondon/adventOfCode
Title: Re: Advent of Code
Post by: Oaky on December 12, 2017, 08:22:59 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 12, 2017, 09:01:31 am
(click to show/hide)

I'm far too thick to think up any 3D solution so just did it in 2D and for part 1 did a BFS that worked fine and ran in under a second.
But for part 2 I firstly assumed incorrectly that the furthest away in 2D distance (the geographical furthest) would have the furthest number of steps, in fact it didn't.
I knew that the max steps (the answer) couldn't be much more than the number of steps for geographical furthest, but didn't want to keep guessing.
So I simply optimized it by factorizing the hexagons and only considering moves outside a minimum radius inside which they couldn't possibly take as many steps as the geographical furthest.
Still takes about a minute though. https://github.com/bjtaylor1/AoC2017/blob/day11part2b/Day11/Program.cs   :facepalm:
Quite good though, first reasonably difficult one.
Title: Re: Advent of Code
Post by: David Martin on December 12, 2017, 09:32:08 am
Today was straightforward.
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 12, 2017, 01:57:06 pm
Today was straightforward.
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 13, 2017, 02:30:07 am
Slowly doing the Anti-AoC:-

How close to 5am (UK time) can I still be up but with no chance of being up to 5am to attempt the challenge (let alone be sober enough!)
Title: Re: Advent of Code
Post by: David Martin on December 13, 2017, 08:35:19 am
Today: I've done part 1 but part 2 will have to wait till I get home as I have too much marking to do. I recognize the problem but can't remember the elegant solution
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 13, 2017, 10:07:13 am
day 12 quite easy going from part 1 to 2 https://github.com/bjtaylor1/AoC2017/compare/day12part1...day12part2
Title: Re: Advent of Code
Post by: Greenbank on December 13, 2017, 01:16:06 pm
My simple naive brute force version took just under 20 seconds for day 13 part b.

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 13, 2017, 06:33:00 pm
I've kind of worked out how I want to do part 2 but am currently shattered so will pick it up after a wee pause.
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 13, 2017, 07:43:22 pm
Still working on a more elegant solution for day 13b.

My work in progress (big spoiler):-

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 13, 2017, 08:38:53 pm
And the final bit (using my puzzle input, so it won't be the same for everyone)...

(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 13, 2017, 08:48:56 pm
Still working on a more elegant solution for day 13b.

My work in progress (big spoiler):-




Neat!


Today's was the first this year where part 2 didn't respond well to a simplistic approach.
Title: Re: Advent of Code
Post by: Greenbank on December 13, 2017, 09:06:20 pm
Today's was the first this year where part 2 didn't respond well to a simplistic approach.

Really? I spent 5 minutes writing this to get the answer in 20 seconds:-

(click to show/hide)

My usual method is to see if the basic/naive approach will work and whether it produces the answer before I can implement something that runs faster.

But then I spent another 90 minutes or so to bring the execution time down to nothing, just to do it the right way (or at least one of the right ways).

Yes, that's 90 minutes to bring the execution time of a one-off task down from 20 seconds to 0 seconds. Unsurprisingly according to the chart (https://xkcd.com/1205/) it was not worth the time. But I did learn (or at least remind myself of) a few things along the way.
Title: Re: Advent of Code
Post by: David Martin on December 13, 2017, 11:26:29 pm
You have a faster computer than me. Mine took a few minutes to run and I was completely naive with searching every possibility. The approach I had been thinking about is this:
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 14, 2017, 08:04:04 am
The one I posted checks every possibility (delay=0,1,2,3,4,5,...),  it just does the individual checks in a more 'mathsy' way.

Anyway, Day 14 and use of previous solutions (which I like and had hoped would appear more in AoC 2017).

I wonder if I need to make my knot hash code faster in case it's used more and more in future challenges. It currently takes 10 seconds to produce the 128 knot hashes required as input for parts (a) and (b), I'm sure I can get this down (and will give me something to do for AoC for part of the rest of the day).
Title: Re: Advent of Code
Post by: Ben T on December 14, 2017, 11:01:45 am
You have a faster computer than me. Mine took a few minutes to run and I was completely naive with searching every possibility. The approach I had been thinking about is this:
(click to show/hide)

My day 13 part 2 runs in 0.4 of a second.
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 14, 2017, 11:22:37 am
Naive 13b down to under 3 seconds if I check them in range depth order (from smallest to largest). I was already bailing early but checking the layers in a suboptimal order. Using an interpreted language doesn't help either.

But my 'clever' solution for day13b runs in 0.002 seconds.
* For the example input I do my pre-computation then checks just one possible delay value.
* For my real input I do my pre-computation and then have to check just 36 possible delay values.

I could speed this up too as:
(click to show/hide)

I'll see if I can knock up an input that has an answer that is orders of magnitude larger.
Title: Re: Advent of Code
Post by: David Martin on December 14, 2017, 11:40:25 am
Today's may have to wait till tomorrow or the weekend -overrun with other things right now.

Title: Re: Advent of Code
Post by: Diver300 on December 14, 2017, 11:45:05 am
I used a spreadsheet (again!) for day 13.  It had far fewer active cells than for day 7 and it didn't do much more than I could have done with a pencil and paper and a calculator.

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 14, 2017, 11:49:39 am
I'll see if I can knock up an input that has an answer that is orders of magnitude larger.

OK, try this against your 2017 day 13b solver: http://www.greenbank.org/misc/aoc2017/2017_13b.huge.txt

The answer is about ~250 times larger than my answer for 13b was, which should give you a rough idea of execution time if it's checking every number along the way. (The answer still fits inside a signed 32-bit integer though, so programs shouldn't need to be altered.)

Mine gets it in under 0.001s after only having to try 38 numbers.

[EDIT] In contrast, my naive solver took 738s to get the answer.
Title: Re: Advent of Code
Post by: Diver300 on December 14, 2017, 12:24:18 pm
Day 14 relies on a code written for day 10.

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 14, 2017, 12:55:18 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 15, 2017, 10:34:38 am
Pretty simple today (day 15), no surprises.
Title: Re: Advent of Code
Post by: Oaky on December 15, 2017, 04:50:24 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 15, 2017, 04:52:49 pm
Ooh. Do 4 colours suffice?
Title: Re: Advent of Code
Post by: Oaky on December 15, 2017, 05:12:30 pm
Ooh. Do 4 colours suffice?

Well, given my input, I'm using
(click to show/hide)
  colours (including the black for the background), but in the 4-colour sense, two suffices for this pattern. :)  Doesn't look as nice then, though.
Title: Re: Advent of Code
Post by: Oaky on December 15, 2017, 05:48:24 pm
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 15, 2017, 09:56:56 pm
Day 15

I thought that Javascript might struggle doing modulus 231. It didn't, and only takes a few seconds to run.

The whole point about day 13 was that it took too long to run when brute-forced. When reading day 15, I thought that the maths that is simple in principle would have some feature that would trip up the simple approach.
Title: Re: Advent of Code
Post by: David Martin on December 15, 2017, 11:13:32 pm

Far too busy to do yesterday and today till now.

Day 14 was easy for part 1,
(click to show/hide)

Day 15 was straightforward
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 16, 2017, 07:53:22 am
day 16 part 2 is proving difficult.....
Title: Re: Advent of Code
Post by: Pickled Onion on December 16, 2017, 08:10:00 am
day 16 part 2 is proving difficult.....
You're not the only one stuck on that

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 16, 2017, 10:03:52 am
I am finding part 2 challenging
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 16, 2017, 10:40:21 am
I didn't think that would work.

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 16, 2017, 10:45:00 am
OK, simple error
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 16, 2017, 10:45:32 am
I didn't think that would work.

(click to show/hide)
That is now obvious. :)
Title: Re: Advent of Code
Post by: Greenbank on December 16, 2017, 12:57:50 pm
Bit late to it today...

(click to show/hide)

It's annoying as I'm solving the majority of these in a faster time than the 100th person on the main leaderboard (today I would have scraped into the top 10). But I guess quite a few other people are too (who also just don't happen to be at their computer at midnight EST).
Title: Re: Advent of Code
Post by: Diver300 on December 16, 2017, 04:43:35 pm
I didn't think that would work.

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 16, 2017, 05:25:07 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 16, 2017, 05:31:18 pm
Day 16
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 16, 2017, 05:38:58 pm
Day 16
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 16, 2017, 09:11:40 pm
Day 16
(click to show/hide)

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 16, 2017, 10:36:19 pm
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 17, 2017, 06:53:36 am
Day 17 was quite straightforward.
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 17, 2017, 08:41:39 am
Day 17 was quite straightforward.
(click to show/hide)

64 characters for part 2, including input data.  ;D

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 17, 2017, 09:59:29 am
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 17, 2017, 10:05:54 am
(click to show/hide)

64 characters for part 2, including input data.  ;D

I can get it down to 84 in perl, but then I'm not very good at code golf.
Title: Re: Advent of Code
Post by: Pickled Onion on December 17, 2017, 10:43:24 am
64 characters for part 2, including input data.  ;D

I can get it down to 84 in perl, but then I'm not very good at code golf.

I look forward to comparing line noise tomorrow!
Title: Re: Advent of Code
Post by: David Martin on December 17, 2017, 02:01:18 pm
17a was quite straightforward.
17b required minor thought but eventually succumbed to brute force
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 17, 2017, 02:17:44 pm
17a was quite straightforward.
17b required minor thought but eventually succumbed to brute force
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 17, 2017, 02:24:39 pm
pretty much the same here. Took a bit longer than 3 seconds (about 10 or so)
Title: Re: Advent of Code
Post by: Pickled Onion on December 17, 2017, 02:32:26 pm
Don't you need to increment buf_len?

My Perl version took 18 seconds with a grep BLOCK, but that's because grep allocates the whole list before it starts. Turning that into a for(RANGE) runs in 8 seconds. Oh and I'm down to 61 characters in the golf version  :)
Title: Re: Advent of Code
Post by: Ben T on December 17, 2017, 03:13:28 pm
17a was quite straightforward.
17b required minor thought but eventually succumbed to brute force
(click to show/hide)

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Croft on December 17, 2017, 03:33:35 pm
Ben T:
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 17, 2017, 05:08:27 pm
Ben T:
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 17, 2017, 06:27:35 pm
Don't you need to increment buf_len?
Yes.

I put that after the conditional bit for some reason.
Title: Re: Advent of Code
Post by: Croft on December 17, 2017, 07:14:23 pm
Ben T:
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 18, 2017, 09:25:38 am
Day 18.

Part a: Yet another psuedo CPU question. Boooring, or so I thought.

But part b was a lovely twist on it.

(00:15:45 from start to part a solution, 00:35:14 from start to part b solution, would have been a minute quicker if I'd read which answer I needed to give more closely.)

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 18, 2017, 09:29:48 am
64 characters for part 2, including input data.  ;D

I can get it down to 84 in perl, but then I'm not very good at code golf.

I look forward to comparing line noise tomorrow!

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 18, 2017, 01:11:16 pm
First read the instructions..

(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 18, 2017, 01:21:15 pm
64 characters for part 2, including input data.  ;D

I can get it down to 84 in perl, but then I'm not very good at code golf.

I look forward to comparing line noise tomorrow!

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: R_nger on December 18, 2017, 06:05:00 pm
First read the instructions..

(click to show/hide)

Should that be Day 18 ?
Title: Re: Advent of Code
Post by: Oaky on December 18, 2017, 09:58:13 pm

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 18, 2017, 10:32:19 pm
First read the instructions..

(click to show/hide)

Should that be Day 18 ?

That was probably one of the bugs..
Title: Re: Advent of Code
Post by: Greenbank on December 19, 2017, 08:12:59 am
Not much of a workout today. (Day 19). And scarily I wrote a 97 line perl program that ran first time with no syntax errors (but one minor logic error that my checking caught).

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 19, 2017, 08:39:53 am
Again, a lot of code for not much intellectual input - overengineered it but that isn't a bad thing.

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 19, 2017, 08:50:38 am
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 19, 2017, 11:59:55 am
Fortunately the input was well behaved, I had considered cases like two corners in consecutive steps, realised that the coding would be more involved and if it came across a not immediately tractable solution to print the local environment and ask for guidance. It didn't need to as there was at least one step between each corner.
Title: Re: Advent of Code
Post by: Croft on December 19, 2017, 12:14:50 pm
A bit disappointed in the simplicity of Part 1. I was almost certain when doing part 1, that the second part was going to ask for the shortest path from start to destination point of part 1.
Title: Re: Advent of Code
Post by: David Martin on December 19, 2017, 12:21:50 pm
By only taking known routes and adding corners where they cross.. I'm just expecting a humdinger tomorrow then.
Title: Re: Advent of Code
Post by: Pickled Onion on December 19, 2017, 12:33:40 pm
Tripped up by having my packet fall off the end of the route and carry on going. The test data was fine as that took it off the circuit board and stopped, but on the actual circuit it found another path and carried on in circles. Oops.
Title: Re: Advent of Code
Post by: Greenbank on December 19, 2017, 01:05:05 pm
Fortunately the input was well behaved, I had considered cases like two corners in consecutive steps, realised that the coding would be more involved and if it came across a not immediately tractable solution to print the local environment and ask for guidance. It didn't need to as there was at least one step between each corner.

Not sure why this would be a problem, there are no decisions to be made at any corners. Either you can continue on in a straight line still or you have to choose left or right (and there won't be a choice).

For example:-

Code: [Select]
  |
B++A
  ++

is unambiguous.

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 19, 2017, 01:55:07 pm

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 19, 2017, 03:45:47 pm

(click to show/hide)

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 19, 2017, 04:19:59 pm

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 19, 2017, 04:21:26 pm
Fortunately the input was well behaved, I had considered cases like two corners in consecutive steps, realised that the coding would be more involved and if it came across a not immediately tractable solution to print the local environment and ask for guidance. It didn't need to as there was at least one step between each corner.

Not sure why this would be a problem, there are no decisions to be made at any corners. Either you can continue on in a straight line still or you have to choose left or right (and there won't be a choice).

For example:-

Code: [Select]
  |
B++A
  ++

is unambiguous.

but
Code: [Select]
   ||||
   ++++
isn't unless you look further afield than immediately adjacent characters. I couldn't be bothered so just wrote a prompt in to look at it by eye and indicate where it should go

Title: Re: Advent of Code
Post by: Greenbank on December 19, 2017, 04:35:52 pm
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 19, 2017, 04:39:13 pm
but
Code: [Select]
   A|BC
   ++++
isn't unless you look further afield than immediately adjacent characters. I couldn't be bothered so just wrote a prompt in to look at it by eye and indicate where it should go

If you're coming down from A then it's unambiguous. You go down, turn left (as you can't turn right), to the end of that line (because you only turn when you can't continue straight on) and then the only choice is to turn left (up) to get to C.

Likewise coming down from C is unambiguous (C down, right, all the way to the end, right and up to A).

Coming down from B is ambiguous as you have a choice of which way to turn, but my reading of the instructions was that this was not going to occur since it didn't say what to do in such cases.
Title: Re: Advent of Code
Post by: Oaky on December 19, 2017, 06:01:01 pm

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 19, 2017, 06:37:09 pm
(click to show/hide)

(click to show/hide)

[EDIT] Sorry, I keep editing the above, we need a YACF-AOC Slack channel. I've created one but would this be a good idea or do people want to keep the discussion here?
Title: Re: Advent of Code
Post by: Oaky on December 19, 2017, 07:33:41 pm
I'd join a Slack channel.

(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 19, 2017, 07:50:26 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 19, 2017, 09:01:02 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 19, 2017, 09:31:20 pm
(click to show/hide)

(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 19, 2017, 10:43:52 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 20, 2017, 09:10:49 am
Relatively simple today (day 20).

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 20, 2017, 12:49:43 pm
I must have something wrong with my iterations as it is taking a long time and not finding collisions.
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 20, 2017, 01:23:20 pm
*blush* Silly bug. Not updating z coordinate. Now solved.
Title: Re: Advent of Code
Post by: Diver300 on December 20, 2017, 01:59:44 pm
Day 20
First part was solved with one run through the data.
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 20, 2017, 02:17:00 pm
Day 20
First part was solved with one run through the data.
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 20, 2017, 02:47:23 pm
Day 20
First part was solved with one run through the data.
(click to show/hide)

(click to show/hide)
True. I'm not claiming that my algorithm for part 1 would work with all possible inputs.
Title: Re: Advent of Code
Post by: Oaky on December 20, 2017, 03:10:29 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 20, 2017, 03:47:55 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 20, 2017, 07:47:45 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 20, 2017, 09:06:48 pm
Day 20 b
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 20, 2017, 09:39:18 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 20, 2017, 10:27:04 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 20, 2017, 11:50:29 pm
 how have you all identified the state where won't be any more collisions for part b, ( or changes in closest to origin for a)?
Did you identify merely a point at which there probably won't be any more or that there can't possibly be?
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 21, 2017, 08:50:04 am
Day 21 looking meaty...

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 21, 2017, 09:23:33 am
Definitely requiring more thought. First time this year in the top 1000

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 21, 2017, 09:54:57 am
Day 21.

Correct answer for part (a), wrong answer for part (b).

The madness begins.
Title: Re: Advent of Code
Post by: David Martin on December 21, 2017, 10:17:42 am
Off by one in your iteration count?
Title: Re: Advent of Code
Post by: Greenbank on December 21, 2017, 11:33:36 am
Off by one in your iteration count?

Nope, more serious than that, but I got it (took me about 20 minutes to find it but I've been doing some real work for the last couple of hours). 43 minutes from submitting part (a) to submitting part (b). Ugh.

(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 21, 2017, 02:13:36 pm
Off by one in your iteration count?

Nope, more serious than that, but I got it (took me about 20 minutes to find it but I've been doing some real work for the last couple of hours). 43 minutes from submitting part (a) to submitting part (b). Ugh.

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 21, 2017, 03:07:09 pm
Down to 30s for 21.b. I'd left my test code in there so I was doubling up on the expensive split/combine work for each iteration.

Will work on ways to get this down to <1s if I can in-between bouts of RealWork(TM).

[EDIT] 17s after simplifying some of the steps, still a way to go.
[EDIT] 15.38s and I think I know how to remove a lot of the complexity from here
[EDIT] 5.23s and much simpler now too, enthusiasm for further refactoring is waning
Title: Re: Advent of Code
Post by: David Martin on December 21, 2017, 03:12:14 pm
Calculating part 2 from scratch took <20secs with my rather naive implementation. Adding in the minor optimisation of adding patterns as you find them took it down to sub 14s from scratch.

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 21, 2017, 04:27:58 pm
55 seconds. Probably some optimizations but possibly marginal gains.
Was hoping it would  create a christmas tree but it didn't.
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 21, 2017, 05:10:14 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 21, 2017, 11:55:15 pm
Day 21, part 2 took my computer 4.637 seconds
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 22, 2017, 12:47:27 am
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 22, 2017, 09:12:45 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 22, 2017, 11:56:18 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 22, 2017, 12:33:25 pm
(click to show/hide)

Late to it today as I was helping set up a family party.

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 22, 2017, 12:58:06 pm
(click to show/hide)

They have been a little bit samey. Maybe a new thread with some 'extra' puzzles on?
Title: Re: Advent of Code
Post by: Greenbank on December 22, 2017, 01:22:29 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 22, 2017, 03:15:11 pm
(click to show/hide)

They have been a little bit samey. Maybe a new thread with some 'extra' puzzles on?

Agree, unlike last year, there hasn't been any this year that I have found hard. Some fairly 'involved', that took a few hours, but nothing more than that.
Title: Re: Advent of Code
Post by: David Martin on December 22, 2017, 03:27:44 pm
OK, new thread started. I'll throw some data up for the first in due course.
Title: Re: Advent of Code
Post by: Pickled Onion on December 22, 2017, 03:46:55 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 22, 2017, 04:01:28 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 22, 2017, 06:35:40 pm
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 22, 2017, 07:59:19 pm
I did the same as Ben T.
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 22, 2017, 10:09:35 pm
(click to show/hide)

Got it!

My code was doing exactly what I expected, apart from the input data importer, which had a mistake in my regexp so that I was truncating the z coordinates to one digit only.

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 23, 2017, 09:26:58 am
Day 23 part A is straightforward

Part B:
(click to show/hide)
ETA: Where was I going wrong? An inability to count the number of zeros. *blush*
And then an off by one errror
Title: Re: Advent of Code
Post by: Pickled Onion on December 23, 2017, 10:16:08 am
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 23, 2017, 10:34:24 am
(click to show/hide)
That is why it is in (ETA: now multiple) spoiler tags.
Title: Re: Advent of Code
Post by: Pickled Onion on December 23, 2017, 11:34:22 am
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 23, 2017, 11:45:42 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 23, 2017, 11:53:14 am
Neat  ;)
Title: Re: Advent of Code
Post by: Diver300 on December 23, 2017, 12:39:10 pm
Day 23 part 2
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 23, 2017, 01:28:59 pm
Thankfully I chose wisely at the start of today's challenge.

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 23, 2017, 03:35:40 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 23, 2017, 03:47:41 pm
With my numbers, the first time f was not 0 was at row 38 in a table similar to yours.

Title: Re: Advent of Code
Post by: Pickled Onion on December 23, 2017, 03:51:35 pm
I've not done 21, so now my circuit shows the connections for 22 & 23 but won't light up.  :-[
Title: Re: Advent of Code
Post by: David Martin on December 23, 2017, 05:06:37 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 23, 2017, 05:28:03 pm
The different patterns in the circuit are getting more creative. Just had a chip labelled 1.21GW - must be a flux capacitor.
Title: Re: Advent of Code
Post by: Ben T on December 23, 2017, 07:04:12 pm
(click to show/hide)


(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 23, 2017, 07:18:11 pm
(click to show/hide)


(click to show/hide)


(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 23, 2017, 08:06:12 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 24, 2017, 08:59:05 am
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 24, 2017, 09:06:46 am
Day 24 a bit more interesting, but not complicated.

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 24, 2017, 09:32:05 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Croft on December 24, 2017, 12:27:01 pm
Day 24
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 24, 2017, 01:42:21 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 25, 2017, 09:58:54 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Oaky on December 25, 2017, 10:09:47 pm
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 27, 2017, 09:47:40 am
Day 24.

Well that took me far too long, but it taught me quite a lot about what takes time in a program.

I wrote a routine that worked out strengths of possible bridges made out of components, and when it comes to more than one that fits, another possible bridge is created, to be looked at later. I had sorted the components so that they could be indexed by number of pins, so finding the next available connector was quick.

Stupidly, I got the programme to look for the first unfinished possible bridge each time a component was added to a possible bridge. It was that looking that took most of the time, being a loop within a loop. As the number of bridges got large, that got too large to manage, while with small numbers of bridges it wasn't a problem. I didn't realise the cause initially.

I looked at the data to optimise it, and saw that there were various unusable components, some components that would always be worse than others, and many combinations that could only usefully fit together one way. I used that to create a reduced data input set, but one with an extra column for the "strength" of the missed connectors. For instance, if I found that the only connectors with 33 pins were 1/33 and 2/33, I would create a new component that was 1/2 but had an extra 66 of strength to be added when used.

With that, I got the answer, but the code took a minute or more to run.

Then I saw that everyone else had code that ran in seconds or less, and I realised that my loop within a loop was the problem. I sorted that, and worked out the statistics.

The full data ran added 1.8 million components, and tried 600,000 possible bridges
The reduced data added 66,000 components and tried 31,000 possible bridges.

The reduced data, when the code was searching for unfinished bridges, did 485 million loops just looking for the next bridge to try.


Title: Re: Advent of Code
Post by: Greenbank on March 18, 2018, 11:05:32 pm
Decided to learn go so redoing 2017 in go.

https://github.com/alexgreenbank/AdventOfCode

It's certainly easier when you know how to solve each one efficiently (or at least efficiently enough).

Day 5 and I finally got to the point where I wrote the complete program for part one and only had to correct typos after the first attempt at running it.
Title: Re: Advent of Code
Post by: David Martin on March 18, 2018, 11:46:30 pm
Really not got the time till after the Easter break. Love to get back into it, but that will have to wait till the summer.
Title: Re: Advent of Code
Post by: Ben T on March 19, 2018, 06:33:20 am
Decided to learn go so redoing 2017 in go.

https://github.com/alexgreenbank/AdventOfCode

It's certainly easier when you know how to solve each one efficiently (or at least efficiently enough).

Day 5 and I finally got to the point where I wrote the complete program for part one and only had to correct typos after the first attempt at running it.
If you want more practice try some project euler problems, AoC is easy in comparison (mostly).  :P
Title: Re: Advent of Code
Post by: Greenbank on March 19, 2018, 12:27:35 pm
If you want more practice try some project euler problems, AoC is easy in comparison (mostly).  :P

Yep, and the UVA (https://uva.onlinejudge.org/). The limiting factor in all of this is free time.
Title: Re: Advent of Code
Post by: Croft on November 30, 2018, 06:59:30 am
Anyone getting up early tomorrow morning?
Title: Re: Advent of Code
Post by: Greenbank on November 30, 2018, 12:03:52 pm
I'll never get up early to do it, it has to fit into my day somehow. I won't get around to Sunday's until late in the evening (and I'll probably still be hungover).

I'll probably do mine first time in perl or C and then reimplement in Go. Have been meaning to look at Rust too.
Title: Re: Advent of Code
Post by: telstarbox on November 30, 2018, 02:19:24 pm
I've solved a couple of the puzzles from last year using Excel (formulae not Visual Basic) but it's clearly not the best solution for most of them. I don't know any specific programming languages so would you recommend any particular one for having a go at this year's puzzles?
Title: Re: Advent of Code
Post by: Croft on November 30, 2018, 03:51:42 pm
If all programming languages are new to you, I think the best choice would be the one you would most like to learn. Most are going to be languages that at least could be used to answer the AoC challenges, so really it's about what might motivate you to learn any one of them.

Some common candidates would be Python (probably the sweet spot between ease of learning and suitability for AoC-type questions), Javascript (or one of its variants such as Typescript) and Java. But there are plenty more to chose from (someone in the last couple of years set themselves the challenges of using a different language for every question - that's 50 over two years! But not something I would recommend unless you have a lot of time on your hands and feel the need to have programmed in 50 languages).
Title: Re: Advent of Code
Post by: SoreTween on November 30, 2018, 05:19:27 pm
VBA is a perfectly decent programming language for tasks at this level, why not just use that as you have it available?  Most other languages will have a learning curve associated with the tools, excel VBA is about as simple as it gets in that respect. Plus excel formulae are well suited to some puzzles, use whatever works best for each and keep it all together in one file.  You'll soon start subliminally learning about code re-use too.

Aside: addictive innit.
Title: Re: Advent of Code
Post by: David Martin on December 02, 2018, 02:16:14 pm
It has started off gently enough though the part twos are a bit more complex than typical from previous years. I am left thinking there must be a better/more efficient way to solve some of them.
Title: Re: Advent of Code
Post by: Ben T on December 02, 2018, 05:29:12 pm
Day 1 part 2 looks like there might be a Dynamic Programming solution but I can't see exactly what it is at the moment.
Title: Re: Advent of Code
Post by: vorsprung on December 02, 2018, 05:30:07 pm
Did day 1 and 2 with perl one liners.  Although the second part of day 2 was a bit long

Not sure if ICBA to carry on with this :)
Title: Re: Advent of Code
Post by: Croft on December 02, 2018, 06:23:53 pm
Did day 1 and 2 with perl one liners.  Although the second part of day 2 was a bit long

Not sure if ICBA to carry on with this :)

You can join the YACF leaderboard with the code 48462-ea506236. And it does get quite addictive (and the puzzles more varied).
Title: Re: Advent of Code
Post by: Greenbank on December 02, 2018, 08:35:13 pm
Caught up with day 1 and 2 now I'm back from a weekend away. Nice gentle start.

(click to show/hide)
Title: Re: Advent of Code
Post by: vorsprung on December 02, 2018, 08:46:21 pm
Jo,

I am anonymous user #241788  apparently
Title: Re: Advent of Code
Post by: Greenbank on December 02, 2018, 09:00:50 pm
Jo left here a long time ago.

Forgot to say, now that it has started I can now legitimately wear my AoC t-shirt.
Title: Re: Advent of Code
Post by: Greenbank on December 03, 2018, 10:07:45 am
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 04, 2018, 09:50:11 pm
Is it just me or are they quite involved with no obvious 'simple algorithm'? Day 4 took me a while - not difficult, just involved.

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 04, 2018, 11:45:44 pm
Yes, not a difficult algorithm but like you say involved. https://github.com/bjtaylor1/AoC2018/blob/master/Day04/Program.cs (link contains spoiler). Didn't take long but I did use classes where I normally wouldn't have to bother.
Title: Re: Advent of Code
Post by: Greenbank on December 05, 2018, 09:35:29 am
Day 4 wasn't about a specific algorithm, it was just about using appropriate data structures for the job. The better choice of data structure the easier it would be to implement the solution.

That and...
(click to show/hide)

With some of the puzzles there's usually only one (high-level) algorithm that will work in a reasonable time frame, and certainly only one (high-level) algorithm that would work if the input was considerably larger (which would show up the inefficient algorithm choices).

There's a number of different ways that you could have approached day 4, all perfectly valid.

I guess it highlights the fact that it's important to know when to optimise something, or choose to correct algorithm, and when you can just get away with anything that works.
Title: Re: Advent of Code
Post by: Ben T on December 05, 2018, 11:09:01 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 05, 2018, 02:44:42 pm
Ooh, if we're doing timings...

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 05, 2018, 03:09:35 pm
Hmm. Interesting. Code?
Only reason I'm curious is if single threaded, I would have expected 5.2 to take 26 times as long as 5.1. Your perl solution did, but C took only 11 times longer, so are you doing some sort of BFS/DFS type search?
Title: Re: Advent of Code
Post by: Greenbank on December 05, 2018, 04:51:24 pm
There's an initial cost to parsing the input string which will mean part 2 won't take exactly 26 times as long as the first.

Code and comments:
(click to show/hide)
Title: Re: Advent of Code
Post by: telstarbox on December 05, 2018, 05:15:06 pm
For day 1 part 2 - do you need to use more than one loop of the input text? It's confusing me lots!
Title: Re: Advent of Code
Post by: Greenbank on December 05, 2018, 06:58:29 pm
For day 1 part 2 - do you need to use more than one loop of the input text? It's confusing me lots!

"
Note that your device might need to repeat its list of frequency changes many times before a duplicate frequency is found, and that duplicates might be found while in the middle of processing the list.
"
Title: Re: Advent of Code
Post by: David Martin on December 05, 2018, 08:32:27 pm
My code for day 5 is obviously inefficient (it does a lot of string allocation) in Python
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 05, 2018, 09:04:47 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 06, 2018, 09:08:15 am
Day 6 was nicely different.

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 06, 2018, 11:23:56 am
Day 6 is interesting, weirdly I found part 1 harder than part 2.
(click to show/hide)

Title: Re: Advent of Code
Post by: Greenbank on December 06, 2018, 11:41:39 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 07, 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.
Title: Re: Advent of Code
Post by: Ben T on December 07, 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
Title: Re: Advent of Code
Post by: Pickled Onion on December 07, 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 :(
Title: Re: Advent of Code
Post by: Diver300 on December 08, 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.
Title: Re: Advent of Code
Post by: Greenbank on December 08, 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...
Title: Re: Advent of Code
Post by: David Martin on December 08, 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)
Title: Re: Advent of Code
Post by: David Martin on December 08, 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)
Title: Re: Advent of Code
Post by: Greenbank on December 08, 2018, 11:03:14 am
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 08, 2018, 12:17:46 pm
(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 08, 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)
Title: Re: Advent of Code
Post by: David Martin on December 08, 2018, 11:19:47 pm
OK, here is my python version for day 8 - not so different.
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 09, 2018, 10:22:33 am
Aha. Day 9 starts to make it really interesting.

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 09, 2018, 10:23:35 am
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 09, 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.
Title: Re: Advent of Code
Post by: Greenbank on December 09, 2018, 01:05:55 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 09, 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)
Title: Re: Advent of Code
Post by: David Martin on December 09, 2018, 09:24:04 pm
(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 09, 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.
Title: Re: Advent of Code
Post by: Diver300 on December 10, 2018, 08:46:58 am
I found day 10 straightforward.

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 10, 2018, 09:56:10 am
I found day 10 straightforward.

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 10, 2018, 10:37:09 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 10, 2018, 11:12:12 am
(click to show/hide)

Title: Re: Advent of Code
Post by: Greenbank on December 10, 2018, 11:38:34 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 10, 2018, 11:54:13 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 10, 2018, 11:55:47 am
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Croft on December 10, 2018, 12:03:23 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 10, 2018, 12:05:20 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 10, 2018, 12:17:48 pm
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 10, 2018, 12:29:00 pm
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 10, 2018, 10:33:22 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 11, 2018, 08:59:50 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 11, 2018, 09:19:59 am
Day 11 part  2
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 11, 2018, 10:33:27 am
Day 11 part  2
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 11, 2018, 11:18:02 am
naive implementation in C++ https://github.com/bjtaylor1/AoC2018/blob/master/Day11/Day11.cpp (link may contain spoiler)
takes about a couple or three seconds
Title: Re: Advent of Code
Post by: Greenbank on December 11, 2018, 02:20:49 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 11, 2018, 02:44:55 pm
Day 10 extension  :)
Code: [Select]
position=<679, 117> velocity=<-7, -1>
position=<584, 498> velocity=<-6, -5>
position=<489, 594> velocity=<-5, -6>
position=<109, 310> velocity=<-1, -3>
position=<585, 399> velocity=<-6, -4>
position=<300, 305> velocity=<-3, -3>
position=<680, 211> velocity=<-7, -2>
position=<586, 493> velocity=<-6, -5>
position=<586, 494> velocity=<-6, -5>
position=<397, 398> velocity=<-4, -4>
position=< 18, 683> velocity=< 0, -7>
position=< 19,  18> velocity=< 0,  0>
position=<399, 399> velocity=<-4, -4>
position=< 19,  20> velocity=< 0,  0>
position=<115,  21> velocity=<-1,  0>
position=<591, 402> velocity=<-6, -4>
position=<401, 403> velocity=<-4, -4>
position=<307, 308> velocity=<-3, -3>
position=<498, 305> velocity=<-5, -3>
position=<308, 686> velocity=<-3, -7>
position=<688, 117> velocity=<-7, -1>
position=<404, 586> velocity=<-4, -6>
position=<594, 112> velocity=<-6, -1>
position=< 24, 398> velocity=< 0, -4>
position=< 24, 399> velocity=< 0, -4>
position=<215,  16> velocity=<-2,  0>
position=<216, 491> velocity=<-2, -5>
position=<121,  17> velocity=<-1,  0>
position=< 27, 588> velocity=< 0, -6>
position=< 28,  18> velocity=< 0,  0>
position=<503,  19> velocity=<-5,  0>
position=<218, 495> velocity=<-2, -5>
position=<503, 686> velocity=<-5, -7>
position=<598, 212> velocity=<-6, -2>
position=<601, 223> velocity=<-6, -2>
position=< 31, 319> velocity=< 0, -3>
position=<126, 510> velocity=<-1, -5>
position=<411, 701> velocity=<-4, -7>
position=<221, 227> velocity=<-2, -2>
position=<127, 223> velocity=<-1, -2>
position=<412, 323> velocity=<-4, -3>
position=<697, 419> velocity=<-7, -4>
position=<603, 507> velocity=<-6, -5>
position=<128, 705> velocity=<-1, -7>
position=<318, 326> velocity=<-3, -3>
position=<319, 696> velocity=<-3, -7>
position=<224, 232> velocity=<-2, -2>
position=<130, 696> velocity=<-1, -7>
position=<605, 707> velocity=<-6, -7>
position=< 36, 696> velocity=< 0, -7>
position=<226, 510> velocity=<-2, -5>
position=<606, 518> velocity=<-6, -5>
position=<322, 601> velocity=<-3, -6>
position=<702, 511> velocity=<-7, -5>
position=< 37, 139> velocity=< 0, -1>
position=<513, 601> velocity=<-5, -6>
position=<418, 511> velocity=<-4, -5>
position=<418, 140> velocity=<-4, -1>
position=< 39, 506> velocity=< 0, -5>
position=<609,  36> velocity=<-6,  0>
position=<514, 710> velocity=<-5, -7>
position=<705, 221> velocity=<-7, -2>
position=<705, 131> velocity=<-7, -1>
position=<135, 615> velocity=<-1, -6>
position=<326, 506> velocity=<-3, -5>
position=<136, 319> velocity=<-1, -3>
position=<231, 225> velocity=<-2, -2>
position=< 41, 701> velocity=< 0, -7>
position=<516, 236> velocity=<-5, -2>
position=<137,  31> velocity=<-1,  0>
position=<517, 319> velocity=<-5, -3>
position=<612, 236> velocity=<-6, -2>
position=<613, 506> velocity=<-6, -5>
position=<233, 412> velocity=<-2, -4>
position=<613,  33> velocity=<-6,  0>
position=<613,  46> velocity=<-6,  0>
position=< 50,  54> velocity=< 0,  0>
position=<145, 340> velocity=<-1, -3>
position=<525, 436> velocity=<-5, -4>
position=<620, 152> velocity=<-6, -1>
position=<525, 153> velocity=<-5, -1>
position=<240, 344> velocity=<-2, -3>
position=< 50, 155> velocity=< 0, -1>
position=<430, 156> velocity=<-4, -1>
position=<525, 442> velocity=<-5, -4>
position=<431, 624> velocity=<-4, -6>
position=<432, 624> velocity=<-4, -6>
position=<242, 245> velocity=<-2, -2>
position=< 53, 530> velocity=< 0, -5>
position=<434, 245> velocity=<-4, -2>
position=<625, 435> velocity=<-6, -4>
position=<721, 340> velocity=<-7, -3>
position=<721,  56> velocity=<-7,  0>
position=<351, 255> velocity=<-3, -2>
position=<161, 541> velocity=<-1, -5>
position=<161, 162> velocity=<-1, -1>
position=<352, 730> velocity=<-3, -7>
position=<257, 448> velocity=<-2, -4>
position=< 67, 354> velocity=< 0, -3>
position=<257, 450> velocity=<-2, -4>
position=<162, 166> velocity=<-1, -1>
position=<637, 262> velocity=<-6, -2>
position=<352, 738> velocity=<-3, -7>
position=<448, 159> velocity=<-4, -1>
position=<544, 634> velocity=<-5, -6>
position=<260,  64> velocity=<-2,  0>
position=<736, 444> velocity=<-7, -4>
position=<357,  64> velocity=<-3,  0>
position=<168, 729> velocity=<-1, -7>
position=<367, 741> velocity=<-3, -7>
position=<558, 171> velocity=<-5, -1>
position=< 83,  93> velocity=< 0,  0>
position=<274, 361> velocity=<-2, -3>
position=<369, 473> velocity=<-3, -4>
position=<465, 552> velocity=<-4, -5>
position=<180, 553> velocity=<-1, -5>
position=<370,  93> velocity=<-3,  0>
position=<181, 554> velocity=<-1, -5>
position=<561, 473> velocity=<-5, -4>
position=<752,  80> velocity=<-7,  0>
position=<372, 283> velocity=<-3, -2>
position=<468, 271> velocity=<-4, -2>
position=<373, 188> velocity=<-3, -1>
position=<184, 645> velocity=<-1, -6>
position=<469, 171> velocity=<-4, -1>
position=<279, 172> velocity=<-2, -1>
position=<754, 268> velocity=<-7, -2>
position=<659, 744> velocity=<-6, -7>
position=<184, 650> velocity=<-1, -6>
position=< 89,  81> velocity=< 0,  0>
position=<374, 747> velocity=<-3, -7>
position=<469,  83> velocity=<-4,  0>
position=<564, 559> velocity=<-5, -5>
position=<564, 750> velocity=<-5, -7>
position=<374, 656> velocity=<-3, -6>
position=<279, 562> velocity=<-2, -5>
position=<754, 373> velocity=<-7, -3>
position=<469, 374> velocity=<-4, -3>
position=<564, 565> velocity=<-5, -5>
position=<564, 186> velocity=<-5, -1>
position=<184, 472> velocity=<-1, -4>
position=< 89, 283> velocity=< 0, -2>
position=<280,  75> velocity=<-2,  0>
position=<565,  76> velocity=<-5,  0>
position=<185, 172> velocity=<-1, -1>
position=<375, 743> velocity=<-3, -7>
position=<470, 744> velocity=<-4, -7>
position=<470, 460> velocity=<-4, -4>
position=<566, 455> velocity=<-5, -4>
position=<566, 551> velocity=<-5, -5>
position=<625, 775> velocity=< 3,  2>
position=<626, 490> velocity=< 3,  5>
position=<342, 490> velocity=< 6,  5>
position=<817, 593> velocity=< 1,  4>
position=<342, 784> velocity=< 6,  2>
position=<818, 585> velocity=< 1,  4>
position=<818, 403> velocity=< 1,  6>
position=<344, 396> velocity=< 6,  6>
position=<344, 777> velocity=< 6,  2>
position=<439, 496> velocity=< 5,  5>
position=<249, 592> velocity=< 7,  4>
position=<440, 873> velocity=< 5,  1>
position=<725, 684> velocity=< 2,  3>
position=<915, 305> velocity=< 0,  7>
position=<251, 970> velocity=< 7,  0>
position=<442, 875> velocity=< 5,  1>
position=<917, 306> velocity=< 0,  7>
position=<348, 304> velocity=< 6,  7>
position=<823, 782> velocity=< 1,  2>
position=<634, 494> velocity=< 3,  5>
position=<349, 878> velocity=< 6,  1>
position=<730, 403> velocity=< 2,  6>
position=<920, 309> velocity=< 0,  7>
position=<449, 400> velocity=< 5,  6>
position=<829, 496> velocity=< 1,  5>
position=<449, 687> velocity=< 5,  3>
position=<354, 973> velocity=< 6,  0>
position=<354, 404> velocity=< 6,  6>
position=<544, 880> velocity=< 4,  1>
position=<639, 786> velocity=< 3,  2>
position=<449, 882> velocity=< 5,  1>
position=<544, 408> velocity=< 4,  6>
position=<450, 305> velocity=< 5,  7>
position=<641, 780> velocity=< 3,  2>
position=<927, 400> velocity=< 0,  6>
position=<453, 590> velocity=< 5,  4>
position=<359, 305> velocity=< 6,  7>
position=<359, 401> velocity=< 6,  6>
position=<740, 401> velocity=< 2,  6>
position=<836, 782> velocity=< 1,  2>
position=<362, 783> velocity=< 6,  2>
position=<362, 879> velocity=< 6,  1>
position=<742, 785> velocity=< 2,  2>
position=<743, 974> velocity=< 2,  0>
position=<933, 975> velocity=< 0,  0>
position=<743, 311> velocity=< 2,  7>
position=<269, 973> velocity=< 7,  0>
position=<934, 596> velocity=< 0,  4>
position=<554, 597> velocity=< 4,  4>
position=<839, 978> velocity=< 1,  0>
position=<650, 783> velocity=< 3,  2>
position=<461, 783> velocity=< 5,  2>
position=<937, 878> velocity=< 0,  1>
position=<558, 403> velocity=< 4,  6>
position=<844, 973> velocity=< 1,  0>
position=<655, 498> velocity=< 3,  5>
position=<941, 879> velocity=< 0,  1>
position=<562, 784> velocity=< 4,  2>
position=<658, 689> velocity=< 3,  3>
position=<658, 785> velocity=< 3,  2>
position=<469, 691> velocity=< 5,  3>
position=<849, 977> velocity=< 1,  0>
position=<671, 498> velocity=< 3,  5>
position=<576, 404> velocity=< 4,  6>
position=<291, 785> velocity=< 7,  2>
position=<861, 501> velocity=< 1,  5>
position=<482, 972> velocity=< 5,  0>
position=<387, 692> velocity=< 6,  3>
position=<578, 686> velocity=< 4,  3>
position=<958, 883> velocity=< 0,  1>
position=<389, 591> velocity=< 6,  4>
position=<389, 979> velocity=< 6,  0>
position=<579, 505> velocity=< 4,  5>
position=<295, 401> velocity=< 7,  6>
position=<580, 505> velocity=< 4,  5>
position=<866, 876> velocity=< 1,  1>
position=<866, 315> velocity=< 1,  7>
position=<677, 306> velocity=< 3,  7>
position=<867, 505> velocity=< 1,  5>
position=<393, 686> velocity=< 6,  3>
position=<583, 409> velocity=< 4,  6>
position=<393, 315> velocity=< 6,  7>
position=<394, 401> velocity=< 6,  6>
position=<964, 972> velocity=< 0,  0>
position=<774, 974> velocity=< 2,  0>
position=<394, 314> velocity=< 6,  7>
position=<775, 879> velocity=< 2,  1>
position=<680, 883> velocity=< 3,  1>
position=<490, 979> velocity=< 5,  0>
position=<586, 404> velocity=< 4,  6>
position=<396, 405> velocity=< 6,  6>
position=<871, 786> velocity=< 1,  2>
position=<871, 977> velocity=< 1,  0>
position=<682, 501> velocity=< 3,  5>
position=<588, 406> velocity=< 4,  6>
position=<778, 312> velocity=< 2,  7>
position=<589, 502> velocity=< 4,  5>
position=<495, 977> velocity=< 5,  0>
position=<506, 318> velocity=< 5,  7>
position=<792, 508> velocity=< 2,  5>
position=<603, 401> velocity=< 4,  6>
position=<698, 687> velocity=< 3,  3>
position=<413, 878> velocity=< 6,  1>
position=<413, 974> velocity=< 6,  0>
position=<603, 785> velocity=< 4,  2>
position=<793, 982> velocity=< 2,  0>
position=<889, 971> velocity=< 1,  0>
position=<509, 500> velocity=< 5,  5>
position=<604, 691> velocity=< 4,  3>
position=<414, 407> velocity=< 6,  6>
position=<794, 788> velocity=< 2,  2>
position=<699, 697> velocity=< 3,  3>
position=<415, 306> velocity=< 6,  7>
position=<795, 599> velocity=< 2,  4>
position=<700, 792> velocity=< 3,  2>
position=<701, 496> velocity=< 3,  5>
position=<416, 410> velocity=< 6,  6>
position=<891, 316> velocity=< 1,  7>
position=<797, 505> velocity=< 2,  5>
Title: Re: Advent of Code
Post by: Greenbank on December 11, 2018, 05:09:30 pm
Day 10 extension  :)

Excellent, found it but will need to work on an algorithm to detect when to stop as I had to manually step through once in the right area to get the exact frame.

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 11, 2018, 09:01:32 pm
Day 10 extension  :)

Excellent, found it but will need to work on an algorithm to detect when to stop as I had to manually step through once in the right area to get the exact frame.

What does it say then? And at what time (frame)?


(click to show/hide)

You don't need all that - see #669  ...  https://yacf.co.uk/forum/index.php?topic=94710.msg2349625#msg2349625

Title: Re: Advent of Code
Post by: Greenbank on December 11, 2018, 11:18:15 pm
What does it say then? And at what time (frame)?

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 12, 2018, 12:24:38 am
Day 11 was nice. I have only got round to it but looked at it briefly at Makerspace tonight. One of my fellow hackers had done it naively and it took a while, so having the benefit of seeing part 2 I realised that
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 12, 2018, 08:15:37 am
Day 12. Can't see why my part 2 is wrong.
Title: Re: Advent of Code
Post by: Diver300 on December 12, 2018, 08:27:40 am
Day 12. Can't see why my part 2 is wrong.
Nor me.
Title: Re: Advent of Code
Post by: Greenbank on December 12, 2018, 09:08:58 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Diver300 on December 12, 2018, 09:10:52 am
Day 12. Can't see why my part 2 is wrong.
Nor me.
(click to show/hide)
Title: Re: Advent of Code
Post by: Croft on December 12, 2018, 05:19:05 pm
(click to show/hide)

Nice.

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 12, 2018, 10:50:26 pm
(click to show/hide)

Nice.

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 13, 2018, 12:00:34 am
(click to show/hide)

Nice.

(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 13, 2018, 12:06:17 am
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 13, 2018, 01:13:11 am
Got it - massive speed up.
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 13, 2018, 08:10:20 am
OK, not quite enough
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 13, 2018, 09:37:27 am
(click to show/hide)

It's not the answer but it will lead you in the right direction, up to you whether you read it obviously.
Title: Re: Advent of Code
Post by: Greenbank on December 13, 2018, 09:48:31 am
Day 13 done.

(click to show/hide)

Looking forward to the first pseudo-assembly-language type question of 2018. I liked those from previous years.
Title: Re: Advent of Code
Post by: Croft on December 13, 2018, 10:26:02 am

(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 13, 2018, 12:58:04 pm
(click to show/hide)

It's not the answer but it will lead you in the right direction, up to you whether you read it obviously.
interesting idea. Will try that.
Title: Re: Advent of Code
Post by: Diver300 on December 14, 2018, 08:17:01 am
Day 14, part 2
(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 14, 2018, 11:46:05 am
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 14, 2018, 08:45:52 pm
(click to show/hide)

It's not the answer but it will lead you in the right direction, up to you whether you read it obviously.
interesting idea. Will try that.
Been rather busy so AoC has been on hold.
(click to show/hide)

Now onward and upward.
Title: Re: Advent of Code
Post by: David Martin on December 14, 2018, 10:48:23 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 15, 2018, 10:48:14 am
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 15, 2018, 10:52:38 am
Day 15. It has taken so long to read the question and it will be a long time to code. Other things to do so I might come back to it later. Trying to think of how I can avoid calculating a shortest path every time, though it is easy to only calculate one per round per enemy.

Later
Title: Re: Advent of Code
Post by: Greenbank on December 15, 2018, 08:23:47 pm
Oof, hungover and family around but managed to get Day 15 done.

Hours. Hours and hours. Oof.

Will rework it tomorrow if/when I have time.
Title: Re: Advent of Code
Post by: Greenbank on December 16, 2018, 03:12:29 pm
Day 16: Wasted far too long chasing a silly bug in the implementation of one of the opcodes which made part (a) give the wrong answer.

Guessed at what part (b) would be so implemented part (a) in a way that would make it easier without a load of rework.
Title: Re: Advent of Code
Post by: Ben T on December 16, 2018, 04:29:02 pm
My code for Day 15's horrible. Lots of nested loops with break-outs, inline functions and branches. Eugh.   ::-) ;D
(click to show/hide)
Title: Re: Advent of Code
Post by: David Martin on December 16, 2018, 08:29:08 pm
Horrible cold so I have put day 15 and 16 on hold for the moment. Will return when my brain does.
Title: Re: Advent of Code
Post by: Greenbank on December 16, 2018, 11:52:23 pm
My code for Day 15's horrible. Lots of nested loops with break-outs, inline functions and branches. Eugh.   ::-) ;D
(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 17, 2018, 11:52:29 am
Missing something in Day 17. Part (a) answer is correct but part (b) is wrong and can't see why.

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 17, 2018, 02:31:07 pm
My code for Day 15's horrible. Lots of nested loops with break-outs, inline functions and branches. Eugh.   ::-) ;D
(click to show/hide)
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 17, 2018, 03:47:48 pm
Day 15: Some people go a little over the top on their visualisations:

https://www.reddit.com/r/adventofcode/comments/a6sej7/day_15_unity_visualization/
Title: Re: Advent of Code
Post by: Greenbank on December 17, 2018, 08:54:55 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 18, 2018, 10:21:45 am
Nice to have a relatively simple one again today. Lucky as I have lots of real work to do!
Title: Re: Advent of Code
Post by: Greenbank on December 19, 2018, 09:42:32 am
I suppose I did ask for a psuedo assembly language one.

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 20, 2018, 07:05:16 pm
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 21, 2018, 11:19:37 am
Interesting one today, but a bit of a slog to the answer.

(click to show/hide)

The recent challenges have seemed harder than in recent years, I wonder if this is responsible for, what looks like, a drop in participation.
Title: Re: Advent of Code
Post by: Greenbank on December 21, 2018, 11:57:09 am
Also liked this touch:

"Clearly, the Elves who wrote this system were worried that someone might introduce a bug while trying to emulate this system with a scripting language."

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 21, 2018, 12:00:10 pm
Still stuck on day 17, havent' tried any subsequent ones - have had to go out to the shops for new jelly and nails as I keep running out, and start again in a new room with a fresh ceiling.
Title: Re: Advent of Code
Post by: Greenbank on December 21, 2018, 03:02:13 pm
Still stuck on day 17, havent' tried any subsequent ones - have had to go out to the shops for new jelly and nails as I keep running out, and start again in a new room with a fresh ceiling.

Ooh. What's the problem? Wrong answer, not fast enough or just can't get it to work properly at all?

I had a bug in mine where it wouldn't accept my answer for part (b), when I eventually fixed it I got the right answer for part (b) but the answer it gave for part (a) changed as well but my original (now incorrect) answer for part (a) was accepted.
Title: Re: Advent of Code
Post by: Ben T on December 21, 2018, 08:07:53 pm
Still stuck on day 17, havent' tried any subsequent ones - have had to go out to the shops for new jelly and nails as I keep running out, and start again in a new room with a fresh ceiling.

Ooh. What's the problem? Wrong answer, not fast enough or just can't get it to work properly at all?

I had a bug in mine where it wouldn't accept my answer for part (b), when I eventually fixed it I got the right answer for part (b) but the answer it gave for part (a) changed as well but my original (now incorrect) answer for part (a) was accepted.

I've come up with an answer but it doesn't accept it at all.
I have produced a pretty picture of what it looks like: https://1drv.ms/u/s!AtNSfl0sxZVlgZIQQ8xv9FsIru8Jww

I have got a loop which I can't figure out how to exit, but at the point where it is not finding any new tiles the situation is as the picture above (should open in paint or simple bmp editor), and it gets to that situation in under a second.
I guessed
(click to show/hide)

Title: Re: Advent of Code
Post by: Greenbank on December 21, 2018, 08:25:11 pm
FWIW, my program agrees with yours for your input. I get the same answer and I can't see anything wrong in the output.

My previous version the program also gives the same answer (even though it exhibits a bug with my input).

I'd move on.
Title: Re: Advent of Code
Post by: Ben T on December 21, 2018, 08:35:12 pm
FWIW, my program agrees with yours for your input. I get the same answer and I can't see anything wrong in the output.

My previous version the program also gives the same answer (even though it exhibits a bug with my input).

I'd move on.

Groan............... found it,
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 21, 2018, 08:40:17 pm
Ah - part 2 was easy for my algorithm.
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 21, 2018, 08:49:26 pm
Groan............... found it,
(click to show/hide)

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 22, 2018, 11:10:25 am
(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 23, 2018, 11:04:15 am
Ooh, day 23 part b looks like a stinker, have ideas and not going to look anywhere for hints. Might take a while!

[EDIT] Got the answer for part b but not satisfied with my method at all. It doesn't work at all on the simple example given in the problem.

Some details in this spoiler.

(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 23, 2018, 06:55:44 pm
Quite enjoyed day 19.
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 23, 2018, 08:34:17 pm
(click to show/hide)
(click to show/hide)
Title: Re: Advent of Code
Post by: Ben T on December 24, 2018, 03:27:03 pm
Done day 21... dog alone knows what the algorithm is trying to do, unlike 19 that there actually seems to be a point to it.
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 24, 2018, 07:47:23 pm
Ooh, day 23 part b looks like a stinker, have ideas and not going to look anywhere for hints. Might take a while!
[EDIT] Got the answer for part b but not satisfied with my method at all. It doesn't work at all on the simple example given in the problem.
My method was something similar but opposite results - it worked for the example but unfortunately not the real data  :(
Title: Re: Advent of Code
Post by: Ben T on December 25, 2018, 07:24:28 pm
Ooh, day 23 part b looks like a stinker, have ideas and not going to look anywhere for hints. Might take a while!

[EDIT] Got the answer for part b but not satisfied with my method at all. It doesn't work at all on the simple example given in the problem.

Some details in this spoiler.

(click to show/hide)

To be honest I had absolutely no idea.
However if you read this (contains spoiler) (https://raw.githack.com/ypsu/experiments/master/aoc2018day23/vis.html), the methodology makes perfect sense and from the description of the method, I was able to code it in C++ (https://github.com/bjtaylor1/AoC2018/blob/master/Day23/Day23.cpp) purely from my understanding of the method, and without looking at his algorithm. But I've got to admit, I'm not sure I would have come up with that idea on my own.
(click to show/hide)
Title: Re: Advent of Code
Post by: Pickled Onion on December 26, 2018, 11:31:19 am
Ooh, day 23 part b looks like a stinker, have ideas and not going to look anywhere for hints. Might take a while!
[EDIT] Got the answer for part b but not satisfied with my method at all. It doesn't work at all on the simple example given in the problem.
My method was something similar but opposite results - it worked for the example but unfortunately not the real data  :(
Finally got it.

(click to show/hide)
Title: Re: Advent of Code
Post by: Greenbank on December 27, 2018, 11:53:38 am
Finished now (didn't get a chance to do more than a few minutes during the last 3 days).

Wasted a bit of time with a misreading of the 24th but got it in 10 minutes this morning and part 2 followed on simply. Not a big fan of big wordy plods like this, but they're quite representative of real world coding with slightly imprecise specs and long slogs of boring programming!
Title: Re: Advent of Code
Post by: Ben T on December 27, 2018, 05:08:35 pm
Finished now (didn't get a chance to do more than a few minutes during the last 3 days).

Wasted a bit of time with a misreading of the 24th but got it in 10 minutes this morning and part 2 followed on simply. Not a big fan of big wordy plods like this, but they're quite representative of real world coding with slightly imprecise specs and long slogs of boring programming!

 :-\ :-\ Not sure where you work - but can I have a job there?!

Whilst I think it's nice that AoC has presented a dimension of difficulty in terms of having a verbose, complicated spec - I would disagree that they're representative - I would say that AoC specs are far, far better written and more concise than real world specs.
 :)

e.g. AoC
Spec: "During the target selection phase, each group attempts to choose one target. In decreasing order of effective power, groups choose their targets; in a tie, the group with the higher initiative chooses first. The attacking group chooses to target the group in the enemy army to which it would deal the most damage (after accounting for weaknesses and immunities, but not accounting for whether the defending group has enough units to actually receive all of that damage)."

Real world would be:
Spec: "The strongest [sic] attack first."
Dev: " 'Strongest' meaning? The one with the most power, or the most units?"
Sponsor: "Oh, er... the one with the most power."
Dev: "Ok."
Later:
Sponsor: "This is a BUG! Unit C has attacked before unit D!"
Dev: "Yes, well, they've both got the same power. As designed."
Sponsor: "Yes but D has got higher initiative!"
Dev: "You didn't say anything about higher initiative attacking first in the event of a tie."
Sponsor: "Well, that should have been obvious!"

Recent AoC problems like Day 24 test the skill of data modelling, as well as just procedural logic.

I don't think any of the specs have been ambiguous. Some have been confusing, particularly Day 17, which required reading every single bit of it very very carefully, with crucial detail being in the letter rather than the spirit of the rules, but I don't think any have actually required a leap of faith or reading between the lines, or been noticeably ambiguous.

Clarifications like 'not accounting for whether the defending group has enough units to actually receive all of that damage' are the exact sort of things that are missing from real world specs as it is the sort of thing only a developer would think about.
In reality, if you were programming a real army, some devs might decide that the spon