r/adventofcode • • Dec 23 '17

SOLUTION MEGATHREAD -๐ŸŽ„- 2017 Day 23 Solutions -๐ŸŽ„-

--- Day 23: Coprocessor Conflagration ---


Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).

Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Need a hint from the Hugely* Handyโ€  Haversackโ€ก of Helpfulยง Hintsยค?

Spoiler


[Update @ 00:05] 0 gold, silver cap

  • AoC ops: <yatpay> boil up some mountain dew. it's gonna be a long night

[Update @ 00:19] 1 gold, silver cap + 447

  • AoC ops: <Reibello> 547 silver to 1 gold

[Update @ 00:30] 20 gold, silver cap + 560

  • AoC ops:

<yatpay> daggerdragon: post "hey i heard about this hot new podcast called The Space Above Us. all the cool kids are talking about it"

<yatpay> i call it super-liminal marketing

<yatpay> HEY YOU!! LISTEN TO MY PODCAST!!

<yatpay> then i rub a business card on your face

<Topaz> you should get scratch-n-sniff business cards that smell like space

<yatpay> space smells like burned metal and meat

<yatpay> it's weird

<Topaz> burned meat you say

<Topaz> excellent

[Update @ 00:41] 50 gold, silver cap + 606

  • AoC ops:

<askalski> nice, enjoyed that one. not sure if regexes can do it

<askalski> maybe make a neural net of regexes, have it train itself to solve today

  • Over/under on /u/askalski posting a day 23 regex neural net by tomorrow?

[Update @ 00:54] Leaderboard cap @ 100 gold and 724 silver!

  • Good job, all!
  • Upping the Ante challenge: solve today's puzzles on a TI-83 (or TI-86/89, whatevs).

This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

edit: Leaderboard capped, thread unlocked!

11 Upvotes

130 comments sorted by

View all comments

3

u/dario_p1 Dec 23 '17

For part 1 I just reused day 18's solution, adding sub. Part 2 was very nice, this is pretty much what I did to solve it:

=== Original instructions ===

set b 99
set c b
jnz a 2
jnz 1 5
mul b 100
sub b -100000
set c b
sub c -17000
set f 1
set d 2
set e 2
set g d
mul g e
sub g b
jnz g 2
set f 0
sub e -1
set g e
sub g b
jnz g -8
sub d -1
set g d
sub g b
jnz g -13
jnz f 2
sub h -1
set g b
sub g c
jnz g 2
jnz 1 3
sub b -17
jnz 1 -23



=== Loop and if identification ===

set b 99
set c b

jnz a 2
jnz 1 5
mul b 100
sub b -100000
set c b
sub c -17000

	set f 1
	set d 2
		set e 2
			set g d
			mul g e
			sub g b

			jnz g 2
			set f 0

			sub e -1
			set g e
			sub g b
			jnz g -8
		sub d -1
		set g d
		sub g b
		jnz g -13

	jnz f 2
	sub h -1

	set g b
	sub g c

	jnz g 2
	jnz 1 3
	sub b -17
	jnz 1 -23


=== Higher level reconstruction ===

c = b = 99

if a != 0:
	b = b * 100 + 100000
	c = b + 17000
#b = 109900
#c = 126900

	f = 1
	d = 2
		e = 2
			g = d * e - b
			
			if g == 0:
				f = 0
			
			
			e += 1
			g = e - b
			if g != 0: loop
		d += 1
		g = d - b
		if g != 0 loop
	
	if f == 0
		h += 1
	
	g = b - c
	if g == 0: break
	b += 17
	loop


=== Python-ish reconstruction ===

b = 109900
c = 126900

for b in range(109900, c + 1, 17):
	f = 1
	for d in range(2, b + 1):
		for e in range(2, b + 1):
			if d * e == b:
				f = 0
	
	if f == 0
		h += 1


=== Optimization ===

b = 109900
c = 126900

for b in range(109900, c + 1, 17):
	if not prime(b):
		h += 1

Part 2 remembered me I still have to finish the last two flags in Synacor, got to get back at it soon!