this post was submitted on 05 Nov 2025
12 points (92.9% liked)

Advent Of Code

1199 readers
2 users here now

An unofficial home for the advent of code community on programming.dev! Other challenges are also welcome!

Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Everybody Codes is another collection of programming puzzles with seasonal events.

EC 2025

AoC 2025

Solution Threads

M T W T F S S
1 2 3 4 5 6 7
8 9 10 11 12

Visualisations Megathread

Rules/Guidelines

Relevant Communities

Relevant Links

Credits

Icon base by Lorc under CC BY 3.0 with modifications to add a gradient

console.log('Hello World')

founded 2 years ago
MODERATORS
 

Quest 1: Whispers in the Shell

  • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
  • You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL

Link to participate: https://everybody.codes/

you are viewing a single comment's thread
view the rest of the comments
[โ€“] janAkali 4 points 1 month ago

So far I really like the difficulty level of EC, compared to AOC.
Quest 1 is pretty straightforward:

  • part 1: add offsets to index then clamp it between 0..limit e.g. min(limit, max(0, index))
  • part 2: add offsets and then modulo to figure out last index
  • part 3: swap first element with element at index mod names.len until done =)

My solution in Nim:

proc parseInput(input: string): tuple[names: seq[string], values: seq[int]] =
  let lines = input.splitLines()
  result.names = lines[0].split(',')

  let values = lines[2].multiReplace({"R":"","L":"-"})
  for num in values.split(','):
    result.values.add parseInt(num)

proc solve_part1*(input: string): Solution =
  let (names, values) = parseInput(input)
  var pos = 0
  for value in values:
    pos = min(names.high, max(0, pos + value))
  result := names[pos]

proc solve_part2*(input: string): Solution =
  let (names, values) = parseInput(input)
  let pos = values.sum()
  result := names[pos.euclMod(names.len)]

proc solve_part3*(input: string): Solution =
  var (names, values) = parseInput(input)
  for value in values:
    swap(names[0], names[euclMod(value, names.len)])
  result := names[0]

Full solution at Codeberg: solution.nim