Author Topic: Advent of Code  (Read 111722 times)

red marley

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

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #251 on: 11 December, 2016, 07:37:32 pm »
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

red marley

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

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #253 on: 11 December, 2016, 08:23:30 pm »
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

Ben T

Re: Advent of Code
« Reply #254 on: 12 December, 2016, 03:43:33 am »
(click to show/hide)

red marley

Re: Advent of Code
« Reply #255 on: 12 December, 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 or the excellent Synacor Challenge) 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.

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #256 on: 12 December, 2016, 06:52:29 am »
Day 12 again can be optimised
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

red marley

Re: Advent of Code
« Reply #257 on: 12 December, 2016, 07:02:45 am »
Day 12 (response to David Martin)

(click to show/hide)

David Martin

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

Ben T

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

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #260 on: 12 December, 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?

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

Ben T

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

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #262 on: 12 December, 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.
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 #263 on: 12 December, 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.
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #264 on: 13 December, 2016, 08:29:57 am »
Haven't attempted day 13 yet but I know the algorithm
(click to show/hide)
"By creating we think. By living we learn" - Patrick Geddes

red marley

Re: Advent of Code
« Reply #265 on: 13 December, 2016, 08:58:39 am »
Or to put it another way (day 13)...

(click to show/hide)

Tim Hall

  • Victoria is my queen
Re: Advent of Code
« Reply #266 on: 13 December, 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.
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

David Martin

  • Thats Dr Oi You thankyouverymuch
Re: Advent of Code
« Reply #267 on: 13 December, 2016, 11:02:12 am »
A colleague of mine pointed me at a way to simplify day 13.
(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 #268 on: 13 December, 2016, 11:16:48 am »
(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

red marley

Re: Advent of Code
« Reply #269 on: 13 December, 2016, 11:26:00 am »
In response to David's colleague's heuristic...

(click to show/hide)

Re: Advent of Code
« Reply #270 on: 13 December, 2016, 08:16:57 pm »
Managed day 12 with only pencil and paper.  ;D

Oaky

  • ACME Fire Safety Officer
  • Audax Club Mid-Essex
    • MEMWNS Map
Re: Advent of Code
« Reply #271 on: 13 December, 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.  ;)
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 #272 on: 14 December, 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]
"By creating we think. By living we learn" - Patrick Geddes

red marley

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

Re: Advent of Code
« Reply #274 on: 14 December, 2016, 07:30:22 am »
(click to show/hide)
Quote from: Kim
Paging Diver300.  Diver300 to the GSM Trimphone, please...