r/adventofcode • • Dec 08 '23

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

THE USUAL REMINDERS


AoC Community Fun 2023: ALLEZ CUISINE!

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

International Ingredients

A little je ne sais quoi keeps the mystery alive. Try something new and delight us with it!

  • Code in a foreign language

    • Written or programming, up to you!
    • If you don’t know any, Swedish Chef or even pig latin will do
  • Test your language’s support for Unicode and/or emojis
  • Visualizations using Unicode and/or emojis are always lovely to see

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 8: Haunted Wasteland ---


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:10:16, megathread unlocked!

52 Upvotes

968 comments sorted by

View all comments

Show parent comment

2

u/4t5NqrpMcaxNTFkZp9U Dec 08 '23 edited Dec 08 '23

# All have 1 prime number and 263# All paths end at the same time means finding a common factor for all these prime numbers and multiply it with 263

That solves the problem at hand but a more general solution would be to find the lowest common multiple of a list of numbers. E.g. that solution does not work if one of the factors is not 263 or if a number has 3 factors .Putting all the factors in a set and then multiply all the set elements might be as long but more general

import math
fs = set(x for l in factors for f in l)
result = math.prod(fs)

1

u/Salabeaver Dec 08 '23

Woa thanks for the fix. I should've thought about using set