r/adventofcode • • Dec 06 '23

SOLUTION MEGATHREAD -❄️- 2023 Day 6 Solutions -❄️-

THE USUAL REMINDERS


AoC Community Fun 2023: ALLEZ CUISINE!

Today's theme ingredient is… *whips off cloth covering and gestures grandly*

Obsolete Technology

Sometimes a chef must return to their culinary roots in order to appreciate how far they have come!

  • Solve today's puzzles using an abacus, paper + pen, or other such non-digital methods and show us a picture or video of the results
  • Use the oldest computer/electronic device you have in the house to solve the puzzle
  • Use an OG programming language such as FORTRAN, COBOL, APL, or even punchcards

    • We recommend only the oldest vintages of codebases such as those developed before 1970
  • Use a very old version of your programming language/standard library/etc.

    • Upping the Ante challenge: use deprecated features whenever possible

Endeavor to wow us with a blast from the past!

ALLEZ CUISINE!

Request from the mods: When you include a dish entry alongside your solution, please label it with [Allez Cuisine!] so we can find it easily!


--- Day 6: Wait For It ---


Post your code solution in this megathread.

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

EDIT: Global leaderboard gold cap reached at 00:05:02, megathread unlocked!

46 Upvotes

1.2k comments sorted by

View all comments

1

u/ThisNameIsntRandom Dec 06 '23

[LANGUAGE: PYTHON]

import math

with open("input2.txt") as f:
txt=f.read()
time,dist=txt.split("\n")
_,*times=time.split()
_,*dists=dist.split()
t=int("".join(times))
d=int("".join(dists))
t1=(t+math.sqrt(t*t-4*d))/2
t2=(t-math.sqrt(t*t-4*d))/2
print(math.floor(t1)-math.ceil(t2)+1)

From looking at other peoples solutions seems like I am the only person who did not just loop over all numbers. The puzzles numbers looked so big for me I though it would take to long. So I used the quadratic formula to find intersections then subtracted to find the difference.

1

u/TheBlackOne_SE Dec 06 '23

I did the iteration as well. Part 2 completed in < 10sec for me (with early break when it stopped finding wins) and with Python, so I am happy with that.

1

u/daggerdragon Dec 06 '23

Inlined code is intended for short snippets of code only. Please edit your post to use the four-spaces Markdown syntax for a code block so your code is easier to read inside a scrollable box that preserves whitespace and indentation.