Author Topic: Advent of Code  (Read 112572 times)

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #200 on: 04 December, 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)
"By creating we think. By living we learn" - Patrick Geddes

red marley

Re: Advent of Code
« Reply #201 on: 05 December, 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...

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #202 on: 05 December, 2016, 08:11:13 am »
Took mine nearly half a minute. I did have a text console holywood version.. ish.
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #203 on: 05 December, 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)
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

red marley

Re: Advent of Code
« Reply #204 on: 06 December, 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!

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #205 on: 06 December, 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.
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

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

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #206 on: 06 December, 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)
"By creating we think. By living we learn" - Patrick Geddes

Tim Hall

  • Victoria is my queen
Re: Advent of Code
« Reply #207 on: 06 December, 2016, 01:18:59 pm »
The Boy, last night, informed me he's cracked 1-4 and was working on 5.   
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #208 on: 06 December, 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)
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

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

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #209 on: 06 December, 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.
"By creating we think. By living we learn" - Patrick Geddes

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #210 on: 06 December, 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.
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

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

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #211 on: 06 December, 2016, 10:09:48 pm »
I like the Jupyter notebooks approach to problem solving as you document each step along the way (or should).
"By creating we think. By living we learn" - Patrick Geddes

red marley

Re: Advent of Code
« Reply #212 on: 07 December, 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.

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #213 on: 07 December, 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)
"By creating we think. By living we learn" - Patrick Geddes

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #214 on: 07 December, 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)
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

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

Re: Advent of Code
« Reply #215 on: 07 December, 2016, 01:15:02 pm »
Interesting approaches.

Regular expressions seemed the obvious approach...

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

Re: Advent of Code
« Reply #216 on: 07 December, 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 😳

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #217 on: 07 December, 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...
"By creating we think. By living we learn" - Patrick Geddes

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #218 on: 07 December, 2016, 04:39:51 pm »
checkout askalski's brute-force Perl regexp solutions over on the adventofcode subreddit

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
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

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

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #219 on: 07 December, 2016, 04:43:46 pm »
Did you look at Part 2 of that thread?
"By creating we think. By living we learn" - Patrick Geddes

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #220 on: 07 December, 2016, 04:48:56 pm »
Did you look at Part 2 of that thread?

His Part 2 solution?  Yep!
You are in a maze of twisty flat droves, all alike.

85.4 miles from Marsh Gibbon

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

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #221 on: 07 December, 2016, 05:06:15 pm »
There is some pretty rank coding on display there..
"By creating we think. By living we learn" - Patrick Geddes

Re: Advent of Code
« Reply #222 on: 07 December, 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)!

Ben T

Re: Advent of Code
« Reply #223 on: 07 December, 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

red marley

Re: Advent of Code
« Reply #224 on: 07 December, 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?) so I'd take the one line solutions in that spirit. I've been impressed with the K language 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.