Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Commit 3b23140

Browse files
committed
Added new question: quantum-conveyor-belts
1 parent 9a6b69f commit 3b23140

File tree

6 files changed

+992
-0
lines changed

6 files changed

+992
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

competition/quantum-conveyor-belts/Cargo.lock

Lines changed: 203 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "quantum-conveyor-belts"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
rand = "0.9.1"
8+
rand_chacha = "0.9.0"
9+
regex = "1.11.1"
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---toml
2+
[fuzz]
3+
exec = ["cargo", "run", "--release", "--", "generate"]
4+
env = {}
5+
6+
[judge]
7+
exec = ["cargo", "run", "--release", "--quiet", "--", "validate"]
8+
9+
[problem]
10+
points = 20
11+
difficulty = 3
12+
---
13+
14+
# ⚛️ Quantum Conveyor Belts?!
15+
16+
A higher-dimensional being has dropped you into a maze of conveyor belts!
17+
These conveyor belts connect stations together,
18+
each station being marked by a unique 3-letter identifier.
19+
You currently find yourself situated in one such station.
20+
21+
You notice that some conveyor belts are activated by pressing
22+
a key labelled with a letter, while others are always active.
23+
You are also told that when emerging from the end of a conveyor belt,
24+
you may emerge in one of several possible stations.
25+
*It's also possible for a key press to lead you nowhere,
26+
since some conveyor belts are seemingly unavailable.*
27+
28+
While you look around trying to see if there is a way out,
29+
a loud echoing bout of laughter rings throughout the maze.
30+
"The only way out of here is to answer my question correctly," it booms.
31+
**"Every time you tap on a key labelled with a letter, the set of possible stations
32+
you could be in changes. How many such sets are impossible for you to achieve?"**
33+
34+
Although this question sounds intimidating, you know that the higher-dimensional being
35+
is never directly observing you, but rather only keeping track of your key presses.
36+
This means that the "set of possible stations" it refers to always refers to
37+
every single station you *could* possibly be in, even if you know that you aren't in it.
38+
39+
For the sake of simplicity, let's call such sets "superpositions".
40+
41+
### Small Example
42+
43+
Here's a small example to demonstrate the question being asked.
44+
Consider the following layout of conveyor belts and stations,
45+
where you start your journey in the `aaa` station.
46+
In this setup, there are only two kinds of letters that will appear: `x` and `y`.
47+
```
48+
aaa: drift(bbb); x(bbb, ccc); y(ccc)
49+
bbb: drift(); x(); y(ddd)
50+
ccc: drift(ddd); x(); y(bbb)
51+
ddd: drift(ccc); x(); y(ccc)
52+
```
53+
54+
Before you press any key, you can take a conveyor belt for free to go to station `bbb`.
55+
Thus, the very first superposition you reach is the set `{aaa, bbb}`.
56+
57+
If you are in station `aaa`, pressing the `x` key on the conveyor belt
58+
will either land you in station `bbb` or `ccc`.
59+
If you are in station `bbb`, pressing the `x` key on the conveyor belt lands you nowhere.
60+
61+
However, `{bbb, ccc}` is *not* the superposition we end up with after pressing `x`!
62+
It is possible to move on a conveyor belt for free from station `ccc` to `ddd`.
63+
Hence, the actual superposition after pressing `x`
64+
from the `{aaa, bbb}` superposition is `{bbb, ccc, ddd}`.
65+
66+
Then, from the superposition `{aaa, bbb}`, pressing the `y` key lands you in
67+
the station `ccc` (if starting from `aaa`), or the station `ddd` (if starting from `bbb`).
68+
It is possible to hop onto conveyor belts for free from those stations,
69+
but you only ever reach `ccc` or `ddd`.
70+
Hence, the superposition after pressing `x` from the `{aaa, bbb}` superposition is `{ccc, ddd}`.
71+
72+
Note that the superposition `{ccc, ddd}` is different from `{bbb, ccc, ddd}`.
73+
In fact, every different combination of stations (ignoring order)
74+
is considered a different superposition of its own.
75+
76+
Continuing down this line, we find that from the superposition `{ccc, ddd}`,
77+
if you press the `x` key, you actually end up *nowhere*!
78+
Funnily enough, this is still a valid superposition. Let's denote this as `{}`.
79+
80+
Meanwhile, if you press the `y` key from the superposition `{ccc, ddd}`,
81+
you end up in the superposition `{bbb, ccc, ddd}`
82+
(`ddd` is reached by "drifting" from `ccc` after moving to it from `bbb`).
83+
84+
Then, from the `{bbb, ccc, ddd}` superposition,
85+
if you press the `x` key, you reach `{}` again.
86+
Meanwhile, if you press the `y` key, you will go back to `{bbb, ccc, ddd}`.
87+
88+
In this example, there are no more new superpositions that can be reached.
89+
Thus, the only 4 reachable superpositions are `{aaa, bbb}`, `{bbb, ccc, ddd}`, `{ccc, ddd}`, and `{}`.
90+
This means that the there are **12 unreachable** superpositions, as follows:
91+
```
92+
{aaa}, {bbb}, {ccc}, {ddd},
93+
{aaa, ccc}, {aaa, ddd}, {bbb, ccc}, {bbb, ddd},
94+
{aaa, bbb, ccc}, {aaa, bbb, ddd}, {aaa, ccc, ddd}, {aaa, bbb, ccc, ddd}.
95+
```
96+
97+
## Input
98+
99+
The input will be a map of all the stations and the conveyor belts connecting them,
100+
with each line in the input representing the outgoing conveyor belts from a single station.
101+
102+
The first line will always be the station (not superposition) that you start your journey in.
103+
104+
The format of each line is as follows:
105+
```
106+
<station name>: drift(<comma-separated list of stations>); <letter>(<list of stations>); ...
107+
```
108+
For example,
109+
```
110+
aju: drift(bkv); a(bkv, clw); b(clw)
111+
```
112+
means that from the station `aju`, you can move to station `bkw` for free
113+
(but this does not mean you can move from `bkw` to `aju` for free).
114+
115+
If you press the `a` key in `aju`, you may end up either in `bkv` or `clw`.
116+
If you press the `b` key in `aju`, you will end up in `clw`.
117+
118+
### Constraints
119+
* There are at most 32 stations in the map.
120+
* You always start in the state described by the very first line in the prompt.
121+
* Every line will contain exactly the same number of letter transitions.
122+
(i.e., if the first line shows transitions for letters `p`, `q` and `r`,
123+
all other lines are guaranteed to show the same letters.)
124+
125+
### Example
126+
127+
Here's another example of the question input.
128+
```
129+
aju: drift(bkv); a(bkv, clw); b(clw)
130+
bkv: drift(dmx); a(bkv); b(bkv)
131+
clw: drift(); a(eny); b(bkv)
132+
dmx: drift(); a(); b(eny)
133+
eny: drift(dmx); a(aju, dmx); b(bkv, clw)
134+
```
135+
136+
Here, you start your journey in the `aju` station,
137+
but in fact your first reachable superposition is `{aju, bkv, dmx}`
138+
since you can take two conveyor belts for free to reach `bkv` and then `dmx` respectively,
139+
before registering a single key press.
140+
141+
## Output
142+
143+
The output will be a single integer, which is how many of the possible superpositions
144+
in the maze are *unreachable*.
145+
(The integer is to be given without spacing or commas in between.)
146+
147+
In the above example, there are 6 *reachable* superpositions:
148+
* `{aju, bkv, dmx}`
149+
* `{bkv, clw, dmx}`
150+
* `{aju, bkv, clw, dmx}`
151+
* `{bkv, dmx, eny}`
152+
* `{aju, bkv, dmx, eny}`
153+
* `{bkv, clw, dmx, eny}`
154+
155+
Therefore, in this example, there are 26 *unreachable* superpositions, and the output should be
156+
```
157+
26
158+
```

0 commit comments

Comments
 (0)