24
\$\begingroup\$

Following last year's event, we're doing Advent of Code Golf Code Golf Advent Calendar 20221! On each day between Dec 1st and Dec 25th (inclusive), a new challenge will be posted at UTC midnight2. It is a free-for-all and just-have-fun-by-participation event, no leaderboards and no prizes for solving them fast or solving them in the shortest code.

For this event to run successfully, we need 25 different challenges prepared before December. If you want to write a challenge for this event, please post it as an answer to this post. All 25 challenges are ready, and no more challenges are being accepted. This post will also act as a sandbox dedicated to the event.

Also unlike last year, the challenge writer will get to post the challenge they write. When you post a challenge, please attach the preferred date(s) you want to post it on. For reference, Dec 1st is Thursday, and Christmas is Sunday.

   December 2022    
Su Mo Tu We Th Fr Sa
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

You may also post "sandbox gems" (old abandoned sandbox posts) as event challenges, but please follow the process for ownership transfer:

  • If a challenge proposal was not edited or commented on for a month, you can leave a comment that you would like take over the challenge, get it ready for main and post it.
  • If the OP does not reply within two weeks, telling you that they still intend to post the challenge themselves, you are free to proceed with the challenge as you see fit.

You're free to discuss about this event in the dedicated chat room too.

Notice for challenge writers. When posting your challenge to main, please follow the rules below:

  • The title should be in the form of CGAC2022 Day X: <challenge title>
  • The body should start with a notice about this event:
    Part of [**Code Golf Advent Calendar 2022**](https://codegolf.meta.stackexchange.com/questions/25251/announcing-code-golf-advent-calendar-2022-event-challenge-sandbox) event. See the linked meta post for details.
    
    ---
    
    <challenge body>
    

1 Following Eric Wastl's request to change the event's name to not contain "Advent of Code", we decided the new name in this meta post.

2 Each individual challenge may be posted a few hours late if UTC midnight doesn't fit with the challenge writer's schedule.


Challenges posted

\$\endgroup\$
5
  • \$\begingroup\$ What happens if we have <25 challenges? \$\endgroup\$
    – DialFrost
    Oct 19, 2022 at 11:24
  • 6
    \$\begingroup\$ @DialFrost Then the event silently fails. But I'm pretty sure it won't happen, mainly because Wheat Wizard seems to be happy to produce ~20 challenges for this event :D \$\endgroup\$
    – Bubbler
    Oct 19, 2022 at 22:30
  • 6
    \$\begingroup\$ We may need to rename this event to something like "Advent of Golf"; see here and here. \$\endgroup\$
    – Ginger
    Oct 28, 2022 at 18:03
  • \$\begingroup\$ @JvdV Nice challenge :) but the event schedule is already full, so no more challenges are being accepted. \$\endgroup\$
    – Bubbler
    Dec 8, 2022 at 1:08
  • \$\begingroup\$ Thanks for the feedback @Bubbler. I'll keep the question in the Sandbox then. \$\endgroup\$
    – JvdV
    Dec 8, 2022 at 8:59

28 Answers 28

7
\$\begingroup\$

CGAC2022 Day 1: Let's build a chocolate pyramid!

\$\endgroup\$
6
\$\begingroup\$

Infinite Santa Queue Rename Sorry

(no preferred date)

Santa is a busy man. This Christmas, he's delivering infinitely many presents to infinitely many people. He has a list of the repeating 2D pattern of Naughty and Nice houses to deliver to, and tasks the elves with coming up with a repeating sequence of items (either Coal or Gifts) to deliver to them.

Your job is to verify, given Santa's naughty-and-nice-list, and the elves' gift-or-coal sequence, whether it is possible for Santa to deliver nonstop.

Specification

You are given Santa's grid as a square pattern of values representing either Naughty or Nice houses. For our examples, we will be using 0 for Naughty and 1 for Nice. You may assume there will always be at least one of each. Example:

1 1 0 1
1 1 0 0
0 0 0 1
0 0 1 1

This pattern tiles the infinite grid of houses:

    . . . . . . . .
    . . . . . . . .
    . . . . . . . .
... 1 1 0 1 1 1 0 1 ...
... 1 1 0 0 1 1 0 0 ...
... 0 0 0 1 0 0 0 1 ...
... 0 0 1 1 0 0 1 1 ...
... 1 1 0 1 1 1 0 1 ...
... 1 1 0 0 1 1 0 0 ...
... 0 0 0 1 0 0 0 1 ...
... 0 0 1 1 0 0 1 1 ...
    . . . . . . . .
    . . . . . . . .
    . . . . . . . .

Similarly, the elves give you a list of items, with values representing either Coal or Gifts. In the examples, we will be using 0s to represent Coal, and 1s to represent Gifts. You may assume there will always be at least one of each. Naughty houses should be delivered Coal, and Nice houses should be delivered Presents. Note that every house may not necessarily receive an item, but each house in Santa's path should be delivered the correct item.

Example:

1 0 1 1 0

This list of items repeats infinitely 1 0 1 1 0 1 0 1 1 0 1 0 1 1 0....

(TODO: put a worked out example of the decision problem here)

: Decide whether, with a given infinite list and on a given infinite grid, Santa can follow an orthogonal path on the infinite grid and deliver each item on the list to each house he passes in order.

: Shortest code in bytes wins!

Test cases

(todo!)

meta:

THIS is a work in progress sorry for quality issues im working on it ive been really busy lately but i wanna participate if possible at all haha !!! ^_^

\$\endgroup\$
4
  • \$\begingroup\$ Does Santa have to deliver a present to every house, or would e.g. 0 0 0 1 work as the presents list for this grid because he can just go in a straight line left-to-right and ignore everybody else? \$\endgroup\$
    – DLosc
    Nov 1, 2022 at 15:15
  • \$\begingroup\$ @DLosc santa can ignore people because if he has to deliver to every house, i thiiiiink it becomes undecideable? However, feel free to prove me wrong :-). Is there any way I can clarify this in the post? \$\endgroup\$ Nov 2, 2022 at 3:10
  • 1
    \$\begingroup\$ "He has a list of ... Naughty and Nice houses that he needs to deliver to" is the main part that sounds like each house should get a present, so that should be reworded. Other than that, just add a sentence somewhere that says "Not every house on the grid will get a present." I think adding the worked example will help too. \$\endgroup\$
    – DLosc
    Nov 2, 2022 at 3:49
  • \$\begingroup\$ hey i havent actually been super interested in cgcc lately i cant promise ill be able to bring this to completion in time for the event; if anyone wants to finish this youre welcome to but also if you need to boot this thats ok too... If you really need me to clean this up though just yell at me and ill give it my best shot :P \$\endgroup\$ Nov 25, 2022 at 5:14
6
\$\begingroup\$

CGAC2022 Day 2: Self-trapping Elf

\$\endgroup\$
5
\$\begingroup\$

Light all of the candles

  • Preferred date: (Hanukkah) >= Dec 18

It's Hanukkah! Unfortunately, it appears some of the candles in your menorah have been blown out. You've got a lighter on hand, but it doesn't work quite right. Whenever you use your lighter at position k, the candles at positions k-1, k, and k+1 all toggle. Let's see an example. We'll represent our candles as a binary sequence with 1 being the "lit" state.

[1, 1, 1, 1, 0, 1, 1, 1, 1]  initial
[1, 1, 1, 0, 1, 0, 1, 1, 1]  light 4
[1, 1, 0, 1, 0, 0, 1, 1, 1]  light 3
[0, 0, 1, 1, 0, 0, 1, 1, 1]  light 1
[1, 1, 1, 1, 0, 0, 1, 1, 1]  light 0
[1, 1, 1, 1, 1, 1, 0, 1, 1]  light 5
[1, 1, 1, 1, 1, 1, 1, 0, 0]  light 7
[1, 1, 1, 1, 1, 1, 1, 1, 1]  light 8

The challenge

To cover our candelabra bases, we'll be working with any n>0 candles. Given the initial state of the candles as input, you must output a lighter usage sequence which will result in all of the candles being lit. Input and output can be taken in any reasonable form for a sequence. Output can be 0 or 1 indexed, but all numbers must fall within the range of the length (ie. no using the lighter at -1). You may assume that the input is always solvable, and you need only output one valid solution.

Test cases

These examples are zero indexed.

[1, 1, 1, 1, 0, 1, 1, 1, 1] -> [4, 3, 1, 0, 5, 7, 8]
[0, 1, 1, 1, 1, 1, 1, 1, 1] -> [1, 2, 4, 5, 7, 8]
[1, 0, 1, 1, 1, 1, 1, 1, 1] -> [2, 4, 5, 7, 8]
[0, 0, 0, 0, 0, 0, 0, 0, 0] -> [1, 4, 7]
[1, 1, 1, 1, 1, 1, 1, 1, 1] -> []
[1, 1, 1, 0, 1, 1, 1] -> [0, 1, 3, 5, 6]
[0, 1, 1, 1, 1, 1, 1] -> [0, 2, 3, 5, 6]
[1, 1, 1, 1, 1, 1, 1] -> []
[0] -> [0]
[1] -> []
\$\endgroup\$
6
  • \$\begingroup\$ The answer is not unique (or answer does not exist) when the length is 3k+2. It should be specified what to output in this case. Some suggestions are: a) assume all inputs have unique answer b) assume all inputs have one or more answers, and allow to output any valid answer. \$\endgroup\$
    – Bubbler
    Oct 27, 2022 at 23:18
  • \$\begingroup\$ @Bubbler Good catch, can't believe I missed that. Fixed now, thanks. \$\endgroup\$ Oct 28, 2022 at 5:51
  • 1
    \$\begingroup\$ I'm almost certain we've had this (or something very similar) as a challenge before. So far, though, all I've found is the two-dimensional version. \$\endgroup\$
    – DLosc
    Nov 1, 2022 at 15:23
  • \$\begingroup\$ It could be made more complicated if people think that would be more interesting. (For example: also take an arbitrary flipping pattern as input) \$\endgroup\$ Nov 1, 2022 at 16:00
  • \$\begingroup\$ Can you post this on Dec 18? \$\endgroup\$
    – Bubbler
    Nov 29, 2022 at 6:08
  • \$\begingroup\$ @Bubbler Can do \$\endgroup\$ Nov 29, 2022 at 14:43
5
\$\begingroup\$

When The Planets Align

(no preferred date) \ Assigned date: December 25th


As a Christmas gift, you were given a toy solar system. In this toy, all the orbits are circular and happen in the same plane. Each planet starts at a fixed location, has a fixed circumference orbit, and moves at a fixed speed. You want to figure out, given these variables, at what time all of the planets will align (relative to the star which they orbit).

The challenge

You are given three lists of non-negative integers, which are each \$n>1\$ items long:

  • \$R_x\$, indicating the circumference of orbit for planet \$x\$ (will not be zero)
  • \$P_x\$, indicating the start position of planet \$x\$ (positions are zero-indexed; you can assume \$P_x < R_x\$ for all \$x\$)
  • \$S_x\$, indicating the number of units that planet \$x\$ moves along its orbit

(You may also take these as a collection of 3-tuples \$(R_x, P_x, S_x)\$ or a permutation thereof.)

Starting from \$t=0\$, after each time step, each planet moves \$S_x\$ units around their orbit (i.e. \$P_x \leftarrow (P_x + S_x) \mod P_x\$). Your goal is to find the smallest time \$t\$ where \$P_x\$ of all the planets are the same (i.e. \$t\$ such that \$(P_1 + t * S_1) \mod R_1 = (P_2 + t * S_2) \mod R_2 = \ldots = (P_n + t * S_n) \mod R_n\$). You may assume that such a time exists.

Test cases

\$R\$ \$P\$ \$S\$ \$t\$
\$[1,1]\$ \$[0,0]\$ \$[0,0]\$ \$0\$
\$[100,100]\$ \$[0,99]\$ \$[1,0]\$ \$99\$

(TODO: I haven't verified these test cases with code; I also should add a few more)

\$\endgroup\$
9
  • \$\begingroup\$ Unless I'm not mistaken, shouldn't \$(P_1+t∗S_1)\$ mod \$P_1\$ be \$(P_1+t∗S_1)\$ mod \$R_1\$? And are you wanting just the integer value of \$P_x\$ to be the same for all planets, as opposed to actually aligning (which would be same \$P_x/R_x\$) \$\endgroup\$
    – jezza_99
    Nov 1, 2022 at 23:48
  • \$\begingroup\$ @jezza_99 You're right, thanks for pointing out the typo \$\endgroup\$ Nov 2, 2022 at 18:03
  • 1
    \$\begingroup\$ I still think for proper alignment, you should use angular alignment as opposed to the linear alignment currently in your problem \$\endgroup\$
    – jezza_99
    Nov 3, 2022 at 7:23
  • \$\begingroup\$ @jezza_99 Yeah, I should probably reword the question so that it's clear the values represent the angular position rather than linear. \$\endgroup\$ Nov 3, 2022 at 17:20
  • \$\begingroup\$ Can you post this on Dec 25? \$\endgroup\$
    – Bubbler
    Nov 29, 2022 at 6:12
  • \$\begingroup\$ @Bubbler I can do that, though I think it needs a few more edits \$\endgroup\$ Nov 29, 2022 at 19:30
  • \$\begingroup\$ @97.100.97.109 you posting this? \$\endgroup\$
    – jezza_99
    Dec 25, 2022 at 21:56
  • \$\begingroup\$ Frick, I forgot, sorry. \$\endgroup\$ Dec 25, 2022 at 23:22
  • 1
    \$\begingroup\$ @jezza_99 Posted. \$\endgroup\$ Dec 25, 2022 at 23:40
5
\$\begingroup\$

CGAC2022 Day 5: Preparing an advent calendar

\$\endgroup\$
2
  • \$\begingroup\$ @KamilDrakari "You may choose to use any two distinct characters or numbers instead of R and G respectively." \$\endgroup\$
    – Bubbler
    Oct 26, 2022 at 1:09
  • \$\begingroup\$ thank you for curing my blindness \$\endgroup\$ Oct 26, 2022 at 14:56
5
\$\begingroup\$

Reconstruct Santa's Book

Date: Dec 20

Oh no, Santa spilled wine all over his great book. Now most of the letters are illegible. How will Santa now know who is groovy and who is unspeakable?

Challenge

There was once a sequence of words, like this:

groovy groovy groovy unspeakable groovy groovy unspeakable unspeakable

However, most of the letters have gone missing and now it looks like this:

     v   oo   g      unsp        gr   y gro            b   uns

Then squashed together:

voogunspgrygrobuns

Your task is to recover the shortest sequence of words that could reduce to the given damaged string.

Note: The words will never have any overlapping characters. Since the book uses different words in different languages you need to handle different words.

Test Cases

Word A Word B Sentence Result
a b ab ab
ab cd abcd ab cd
ab cd abc ab cd
ab cd ac ab cd
ab cd bd ab cd
ab cd bda ab cd ab
ab cd aa ab ab
ooq dr ooqdr ooq dr
ooq dr oooqdr ooq ooq dr
groovy unspeakable voogunspgrygrobuns groovy groovy groovy unspeakable groovy groovy unspeakable unspeakable
\$\endgroup\$
4
  • \$\begingroup\$ Can you post this on Dec 17? \$\endgroup\$
    – Bubbler
    Nov 29, 2022 at 6:14
  • \$\begingroup\$ Ok I'll add it to my agenda \$\endgroup\$
    – mousetail
    Nov 29, 2022 at 6:21
  • 1
    \$\begingroup\$ @JvdV I specified there can never be overlap in letters between the words \$\endgroup\$
    – mousetail
    Dec 7, 2022 at 15:23
  • \$\begingroup\$ Dumb me. Missed that \$\endgroup\$
    – JvdV
    Dec 7, 2022 at 15:38
4
\$\begingroup\$

CGAC2022 Day 4: Can Santa fit down the chimney?

\$\endgroup\$
5
  • \$\begingroup\$ I think having the height be always one is a more interesting challenge personally \$\endgroup\$ Nov 2, 2022 at 4:44
  • \$\begingroup\$ Agree. Otherwise apply a filter to your code \$\endgroup\$ Nov 2, 2022 at 12:22
  • \$\begingroup\$ "Assume a rectangular frictionless Santa..." \$\endgroup\$
    – DLosc
    Nov 10, 2022 at 16:46
  • 1
    \$\begingroup\$ Can you post this on Dec 4? \$\endgroup\$
    – Bubbler
    Nov 29, 2022 at 6:05
  • \$\begingroup\$ @Bubbler yep I can \$\endgroup\$
    – jezza_99
    Nov 30, 2022 at 7:49
4
\$\begingroup\$

CGAC2022 Day 6: Shuffles with specific "magic number"

\$\endgroup\$
4
\$\begingroup\$

CGAC2022 Day 10: Help Santa sort presents!

\$\endgroup\$
2
  • \$\begingroup\$ Can you post this on Dec 11? \$\endgroup\$
    – Bubbler
    Nov 29, 2022 at 6:13
  • \$\begingroup\$ (changed to Dec 10 in chat) \$\endgroup\$
    – Bubbler
    Nov 30, 2022 at 23:41
3
\$\begingroup\$

Reduce, Reuse, Regift

Traditionally presents are kept secret in boxes wrapped in paper. Since the ice caps are melting Santa Claus has begun to investigate some ways they might make the whole gift wrapping operation a little more eco-friendly. The first thing they've decided to do is to put all presents in perfectly cubic boxes. This makes things more efficient to process and cuts down on waste. The second thing they are doing is to reuse some of the scrap paper to wrap boxes as opposed to tossing it.

In this challenge you will help Santa make a machine which will identify which pieces of scrap can still be used to wrap gifts. Because of the industrial wrapper cutting machine used scraps will always be connected faces of a square tiling.

For example you might get the following scrap:

   #
####
 #

This scrap can fold around the cube perfectly with no overlap and no empty space. Some scraps might overlap, for example:

 #
#######
#

Can wrap around the cube perfectly, but since there are more than 6 squares there must be overlap. This is fine and this scrap can be used to wrap.

Some scraps can't wrap a cube without leaving some gaps. For example

######

This has 6 squares, but there's no way to fold them which covers all sides of a cube. So this should be sent to the recycling plant.

Some scraps can wrap the cube but require fancy folding techniques. For example:

####
####
####

This can be folded to wrap around a cube, but it requires folds that aren't along the edges of the squares. The wrapping machine just isn't that fancy, so this should be sent to the recycling plant.

Task

For this challenge, take a scrap as input in any reasonable method. Output one of two consistent distinct values. One value should only be output if the scrap can be used as gift wrapping, the other should only be output if the scrap should be sent to the recycling plant.

In order to be eco-friendly Santa is asking you to minimize the size of your source code as measured in bytes. (You've tried to explain that that's not how things work.) So this is .

Ideas for extensions

Would any of these extensions be fun or worthwhile for the advent event?

  1. Take a scrap and cut out as many (non-overlapping) scraps as possible which can be used to wrap presents. Harder
  2. Take a scrap and determine if it can wrap a cube with fancy folds. Harder
  3. Scraps are made from the triangular tiling but need to wrap octahedral boxes. Harder, more complex input

You might at a glance extension 2 is easier. Just determine if the scrap contains some net right? However the following can be used to wrap a cube and contains no net of the cube:

#######
\$\endgroup\$
3
  • 1
    \$\begingroup\$ I think allowing fancy folds would make the challenge too difficult \$\endgroup\$
    – mousetail
    Nov 9, 2022 at 8:03
  • \$\begingroup\$ Sorry for the reschedule, but can you post this on Dec 11? \$\endgroup\$
    – Bubbler
    Dec 1, 2022 at 0:36
  • \$\begingroup\$ @Bubbler Sure. No problem. \$\endgroup\$
    – Wheat Wizard Mod
    Dec 1, 2022 at 2:33
3
\$\begingroup\$

Momentum Sledding

(Idea from Math Games With Bad Drawings.)

You have a track, marked with a starting point and an ending point. # is snow and . is void.

S###########....
...........#....
######.....#....
######.....#....
######..........
################
################
..............##
..............##
E###############
################
################

You start with velocity \$(0,0)\$. Every frame you tweek your velocity by \$(h,v)\$, where \$h,v\in\{-1,0,1\}\$.

You will calculate the minimum ammount of frames it will take to go from the starting point to the ending point. You cannot travel to the void, but you can travel across void.

Walkthrough of Example

01#2##3#4#5#....
...........6....
######.....#....
######.....7....
######..........
###########8####
############9###
..............##
..............0#
6####5###4#####1
############3#2#
################

It took sisteen frames.

enter image description here

Scoring

still applies.

Test Cases

Input:

S.....#######E
.#...#........
..#.#.........
...#..........

Output:

7

Input:

S#.#..#...#..#.###E

Output:

7

Input:

S###########....
...........#....
######.....#....
######.....#....
######..........
################
################
..............##
..............##
E###############
################
################

Output:

16

\$\endgroup\$
5
  • \$\begingroup\$ Meta: should we make scoring rubric time instead? \$\endgroup\$ Nov 4, 2022 at 10:41
  • \$\begingroup\$ What do you mean by "scoring rubric time"? Do you want this to be fastest-code? Also, I think the output of the first test case is wrong. SE -> SE -> EE -> NE -> NEE -> EEE -> EEE gives 7. \$\endgroup\$
    – Bubbler
    Nov 7, 2022 at 0:08
  • \$\begingroup\$ Firsst question yes, second question fixxed \$\endgroup\$ Nov 7, 2022 at 8:52
  • \$\begingroup\$ I think this needs more explanation: how do snow and void change things? How are you able to go from 3 to 4 in the bottom half of the walkthru? \$\endgroup\$
    – Jonah
    Dec 6, 2022 at 5:53
  • \$\begingroup\$ Why not? The velocity is changed by (-1,1) \$\endgroup\$ Dec 6, 2022 at 11:27
3
\$\begingroup\$

CGAC Day 17: Present Heap

\$\endgroup\$
4
  • \$\begingroup\$ Can you post this on Dec 21? \$\endgroup\$
    – Bubbler
    Nov 29, 2022 at 6:09
  • \$\begingroup\$ @Bubbler Maybe, I'm not sure yet. I'll tell you once I'm sure. \$\endgroup\$
    – Ginger
    Nov 29, 2022 at 12:09
  • \$\begingroup\$ Sorry but may I reassign this to Dec 24? \$\endgroup\$
    – Bubbler
    Dec 1, 2022 at 0:40
  • \$\begingroup\$ Possible example of multiple possible outputs (if I understood the challenge correctly): [1, 1, 2, 2, 3, 3, 4, 4] -> [1, 4], [1, 4], [2, 3], [2, 3] or [1, 2, 3, 4], [1, 2, 3, 4] or [1, 1, 4, 4], [2, 2, 3, 3] \$\endgroup\$
    – Bubbler
    Dec 1, 2022 at 0:49
2
\$\begingroup\$

CGAC2022 Day 9: Playing with bits

\$\endgroup\$
2
\$\begingroup\$

CGAC2022 Day 21: Present stack headache

\$\endgroup\$
1
\$\begingroup\$

Sled Machine

(Idea from Cell Machine.)

You are given a board.

>v.....
.>#O...

And a number, say, 5.

You will simulate the board for that many iterations.

Moving Rules

  • > (sleds) moves right, v moves down, < moves left, and ^ moves up. All sleds move at the same time.
  • # (snowballs) generally do not move.
  • O (rotater) rotate nearby sleds around it, from
>.
O.

to

..
Ov
  • . is just empty.

Edge Cases (in order)

(By "X meet Y", I mean "X moves into a cell that contains Y")

  • Sled meet sled(s). Then they crash together and form a snowball.
  • Sled meet snowball. Then the sled will push the snowball in the same direction.
  • Snowball meet snowball. Then they compress to make one snowball.
  • Snowball meet sled. Then the sled gets crashed and the snowball is moved.
  • Sled meet rotator. Then the sled replaces the rotater.
  • Snowball meet rotator. Then the rotator gets pushed.
  • Rotator meet sled. Then the rotator is broken into pieces, and makes a snowball.
  • Rotator meet snowball. Then the rotator is crashed into the snowball.
  • Rotator meet rotator. Then the moving rotator disappears.

Anything travelling off the grid is considered to never exist again.

Scoring

still applies.

Test Cases

TBD

\$\endgroup\$
4
  • \$\begingroup\$ What are the results of >.< and ><? Do the sleds move sequentially or simultaneously? By "X meet Y", do you mean "X moves into a cell that contains Y" or something else? \$\endgroup\$
    – Bubbler
    Nov 4, 2022 at 4:17
  • \$\begingroup\$ Answered, answered. >.< would result in edge case 1 making .#. and >< would become <> since all sleds travel at the same time. \$\endgroup\$ Nov 4, 2022 at 10:19
  • \$\begingroup\$ Suggested testcases: >#< (how does the snowball move?), ..\n>O (is a sled's movement ignored if it is moved by a rotator?), >#Ov\n.... and >#O.\n..>. (what if a rotator rotating a sled is moved at the same time?) \$\endgroup\$
    – Bubbler
    Nov 7, 2022 at 0:04
  • \$\begingroup\$ First, sleds meet make snowball, snowballs meet make snowballs Second, sled meet rotator and replaces rotator Third, both move, as events are simultaneous (Will add) \$\endgroup\$ Nov 7, 2022 at 8:54
1
\$\begingroup\$

CGAC2022 Day 3: \$n\$-dimensional Chocolate Pyramid

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Can you post this on Dec 3? \$\endgroup\$
    – Bubbler
    Nov 29, 2022 at 6:05
  • \$\begingroup\$ @Bubbler OK. Dec 3. \$\endgroup\$
    – alephalpha
    Nov 29, 2022 at 6:13
1
\$\begingroup\$

CGAC2022 Day 7: Fen The Wicked

\$\endgroup\$
1
\$\begingroup\$

CGAC2022 Day 8: Fen The Wicked, Part 2

\$\endgroup\$
1
\$\begingroup\$

CGAC2022 Day 12: Santa's gift and the laser lock

\$\endgroup\$
1
  • \$\begingroup\$ I'm confused by the significance of the red and green cells \$\endgroup\$
    – mousetail
    Dec 11, 2022 at 15:31
1
\$\begingroup\$

CGAC2022 Day 13: Santa's gift and the laser lock, Part 2

\$\endgroup\$
1
\$\begingroup\$

CGAC2022 Day 14: Chimney cleaning

\$\endgroup\$
1
\$\begingroup\$

CGAC2022 Day 19: I Made It Out Of Clay

\$\endgroup\$
3
  • \$\begingroup\$ @Bubbler am I good to post this on the 19th? \$\endgroup\$
    – AAM111
    Dec 17, 2022 at 19:51
  • \$\begingroup\$ Yes. \$\text{}\$ \$\endgroup\$
    – Bubbler
    Dec 18, 2022 at 23:50
  • \$\begingroup\$ @Bubbler Posted! \$\endgroup\$
    – AAM111
    Dec 19, 2022 at 5:19
1
\$\begingroup\$

CGAC2022 Day 22: Present stack headache, Part 2

\$\endgroup\$
0
\$\begingroup\$

North Pole Railroads, Part 2

  • Preferred date: Dec 23

Santa and the Elves are secretly preparing for a new tourist train service, called "North Pole Railroads". The train will travel through various sightseeing spots near the North Pole.

As a part of this project, they want to know how many seats they will need. They already have the list of travels for each passenger (given as "from station X to station Y"), which is thanks to the same magic that lets Santa know which children are nice. Each station is numbered from 1, starting from the North Pole.

The Elves are arguing over how to determine the number of seats. Another option is to have just enough seats to allow all passengers to choose their seats. Note that they will have to consider all possible order of reservations. Two passengers with strictly overlapping travel cannot share a seat (e.g. one is (1, 3) and the other is (2, 4)), but a travel that ends at X is not overlapping with another that starts at X.

Task

Given the list of X, Y pairs that represent the travel of each passenger, output how many seats will be needed for North Pole Railroads.

Standard rules apply. The shortest code in bytes wins.

Test cases

(1, 2), (2, 3), (1, 3), (3, 4) -> 3
1---2---3---4
 AAA     DDD
     BBB
 CCCCCCC
Explanation: if A takes seat 1 and B takes seat 2, C needs the third seat

(1, 2), (1, 3), (2, 3), (3, 4) -> 3
Explanation: the order in the input does not matter

(1, 3), (1, 3), (3, 6), (3, 6) -> 2

(1, 5), (2, 8), (6, 9), (5, 7), (4, 6) -> 5
Explanation: B's travel overlaps with the other 4, so if ACDE gets to book first,
B will need the 5th seat
\$\endgroup\$
0
\$\begingroup\$

CGAC2022 Day 15: Chimney cleaning, Part 2

\$\endgroup\$
0
\$\begingroup\$

CGAC2022 Day 16: Playing with bits, Part 2

\$\endgroup\$
0
\$\begingroup\$

CGAC2022 Day 23: North Pole Railroads

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .