Author Topic: Advent of Code  (Read 109911 times)

Afasoas

Advent of Code
« on: 10 December, 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.

Ben T

Re: Advent of Code
« Reply #1 on: 10 December, 2015, 09:57:02 pm »

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #2 on: 10 December, 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'.

"By creating we think. By living we learn" - Patrick Geddes

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #3 on: 10 December, 2015, 10:53:26 pm »
4b is nasty. It is taking a while to bruteforce.
"By creating we think. By living we learn" - Patrick Geddes

Afasoas

Re: Advent of Code
« Reply #4 on: 10 December, 2015, 10:58:04 pm »
Ben T, if we were Golfing 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"

David Martin

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

Afasoas

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

David Martin

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

Ben T

Re: Advent of Code
« Reply #8 on: 11 December, 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?

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #9 on: 11 December, 2015, 10:18:21 am »
It takes a very long time if you have a silly bug in your code :embarassed: Done.
"By creating we think. By living we learn" - Patrick Geddes

Pingu

  • Put away those fiery biscuits!
  • Mrs Pingu's domestique
    • the Igloo
Re: Advent of Code
« Reply #10 on: 11 December, 2015, 10:56:52 am »
Did 1a & 1b with javascript  :P

Ben T

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

red marley

Re: Advent of Code
« Reply #12 on: 11 December, 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?

David Martin

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

Mr Larrington

  • A bit ov a lyv wyr by slof standirds
  • Custard Wallah
    • Mr Larrington's Automatic Diary
Re: Advent of Code
« Reply #14 on: 11 December, 2015, 12:28:48 pm »
I no longer have access to a VMS Fortran compiler so that's me stuffed ;D
External Transparent Wall Inspection Operative & Mayor of Mortagne-au-Perche
Satisfying the Bloodlust of the Masses in Peacetime

Pancho

  • لَا أَعْبُدُ مَا تَعْبُدُونَ
Re: Advent of Code
« Reply #15 on: 11 December, 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

Ben T

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

Afasoas

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


Pancho

  • لَا أَعْبُدُ مَا تَعْبُدُونَ
Re: Advent of Code
« Reply #18 on: 11 December, 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.

Afasoas

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

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #20 on: 11 December, 2015, 01:35:12 pm »

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

David Martin

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

red marley

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

Pancho

  • لَا أَعْبُدُ مَا تَعْبُدُونَ
Re: Advent of Code
« Reply #23 on: 11 December, 2015, 03:25:03 pm »
Well, I haven't even figured out how to bring a file in a character at a time yet!

Ben T

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