Author Topic: Advent of Code  (Read 28462 times)

Ben T

  • What you saying, then?
Re: Advent of Code
« Reply #25 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?
Unless you put on overalls, boots, and a helmet with a high tech pre fitted lamp - and you dig coal - nope, you don't know me.

Re: Advent of Code
« Reply #26 on: December 11, 2015, 03:42:41 pm »
A Few Apples Short of a Strudel

Pancho

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

Pancho

  • لَا أَعْبُدُ مَا تَعْبُدُونَ
Re: Advent of Code
« Reply #28 on: December 11, 2015, 04:50:08 pm »
Whoops.

It seems I've only done Part 1 of Day 1. Back to the grindstone.

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #29 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.
"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 #30 on: December 11, 2015, 06:48:03 pm »
Day 2 done in a spreadsheet  :demon:

Re: Advent of Code
« Reply #31 on: December 11, 2015, 07:11:18 pm »
Part 1 of Day 1 done in a word processor   :demon:

Pingu

  • Put away those fiery biscuits!
  • Mrs Pingu's domestique
    • the Igloo
Re: Advent of Code
« Reply #32 on: December 11, 2015, 07:22:24 pm »
Day 3 done (javascript).

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #33 on: December 11, 2015, 07:37:48 pm »
Waiting for 10b to finish running.
"By creating we think. By living we learn" - Patrick Geddes

Pancho

  • لَا أَعْبُدُ مَا تَعْبُدُونَ
Re: Advent of Code
« Reply #34 on: December 11, 2015, 08:33:06 pm »
Still trying to work out how to do arrays.

David Martin

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

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #36 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)


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

red marley

Re: Advent of Code
« Reply #37 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)

Pingu

  • Put away those fiery biscuits!
  • Mrs Pingu's domestique
    • the Igloo
Re: Advent of Code
« Reply #38 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:

David Martin

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

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #40 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..
"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 #41 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)
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

Pancho

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

red marley

Re: Advent of Code
« Reply #43 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)

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #44 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.

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

David Martin

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

Pancho

  • لَا أَعْبُدُ مَا تَعْبُدُونَ
Re: Advent of Code
« Reply #46 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) ?

Pancho

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

Re: Advent of Code
« Reply #48 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 .. :/
A Few Apples Short of a Strudel

Pingu

  • Put away those fiery biscuits!
  • Mrs Pingu's domestique
    • the Igloo
Re: Advent of Code
« Reply #49 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?