You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deno.test("Day 5: If You Give A Seed A Fertilizer",async(t)=>{
5
+
awaitt.step("Part 1",async(t)=>{
6
+
awaitt.step("Example",async(t)=>{
7
+
awaitt.step("Map example",async(t)=>{
8
+
// Consider again the example seed-to-soil map:
9
+
constseedToSoil=seedMap([
10
+
/*
11
+
The first line has a destination range start of 50, a source range start of 98, and a range length of 2. This line means that the source range starts at 98 and contains two values: 98 and 99. The destination range is the same length, but it starts at 50, so its two values are 50 and 51.
12
+
*/
13
+
`50 98 2`,
14
+
/*
15
+
The second line means that the source range starts at 50 and contains 48 values: 50, 51, ..., 96, 97. This corresponds to a destination range starting at 52 and also containing 48 values: 52, 53, ..., 98, 99.
16
+
*/
17
+
`52 50 48`,
18
+
]);
19
+
for(const[seed,soil]of[
20
+
// With this information, you know that seed number 98 corresponds to soil number 50 and that seed number 99 corresponds to soil number 51.
21
+
[98,50],
22
+
[99,51],
23
+
// So, seed number 53 corresponds to soil number 55.
24
+
[53,55],
25
+
// Any source numbers that aren't mapped correspond to the same destination number. So, seed number 10 corresponds to soil number 10.
26
+
[10,10],
27
+
// With this map, you can look up the soil number required for each initial seed number:
28
+
[79,81],
29
+
[14,14],
30
+
[55,57],
31
+
[13,13],
32
+
]){
33
+
awaitt.step(
34
+
`Seed number ${seed} corresponds to soil number ${soil}`,
Using these maps, find the lowest location number that corresponds to any of the initial seeds. To do this, you'll need to convert each seed number through other categories until you can find its corresponding location number. In this example, the corresponding types are:
47
+
*/
48
+
assertEquals(example,newSet([82,43,86,35]));
49
+
50
+
// So, the lowest location number in this example is 35.
0 commit comments