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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { expect } from "https://esm.town/v/karfau/chai";
// expect(firstStar(`turn on 0,0 through 999,999`), "*1 sample 1").to.equal(1_000_000);
// expect(firstStar(`toggle 0,0 through 999,0`), "*1 sample 2").to.equal(1_000);
// expect(firstStar(`turn off 499,499 through 500,500`), "*1 sample 3").to.equal(0);
// expect(firstStar(``), "*1 sample 2").to.equal("?");
function firstStar(input: string) {
return "expected output"; // implement :)
}
// as as soon as the assertions pass, the solution is calculated
console.log("solution *1:", firstStar(input()));
expect(secondStar(``), "*2 sample 1").to.equal("?");
// expect(secondStar(``), "*1 sample 2").to.equal("?");
function secondStar(input: string) {
return "?";
}
console.log("solution *2:", secondStar(input()));
function input() {
return `turn on 887,9 through 959,629
turn on 454,398 through 844,448
turn off 539,243 through 559,965
turn off 370,819 through 676,868
turn off 145,40 through 370,997
turn off 301,3 through 808,453
turn on 351,678 through 951,908
toggle 720,196 through 897,994
toggle 831,394 through 904,860
toggle 753,664 through 970,926
turn off 150,300 through 213,740
turn on 141,242 through 932,871
toggle 294,259 through 474,326
toggle 678,333 through 752,957
toggle 393,804 through 510,976
turn off 6,964 through 411,976
turn off 33,572 through 978,590
turn on 579,693 through 650,978
turn on 150,20 through 652,719
turn off 782,143 through 808,802
turn off 240,377 through 761,468
turn off 899,828 through 958,967
turn on 613,565 through 952,659
turn on 295,36 through 964,978
toggle 846,296 through 969,528
turn off 211,254 through 529,491
turn off 231,594 through 406,794
turn off 169,791 through 758,942
turn on 955,440 through 980,477
toggle 944,498 through 995,928
turn on 519,391 through 605,718
toggle 521,303 through 617,366
turn off 524,349 through 694,791
toggle 391,87 through 499,792
toggle 562,527 through 668,935
turn off 68,358 through 857,453
toggle 815,811 through 889,828
turn off 666,61 through 768,87
turn on 27,501 through 921,952
turn on 953,102 through 983,471
turn on 277,552 through 451,723
turn off 64,253 through 655,960
turn on 47,485 through 734,977
turn off 59,119 through 699,734
toggle 407,898 through 493,955
toggle 912,966 through 949,991
turn on 479,990 through 895,990
toggle 390,589 through 869,766
toggle 593,903 through 926,943
toggle 358,439 through 870,528
turn off 649,410 through 652,875
turn on 629,834 through 712,895
toggle 254,555 through 770,901
toggle 641,832 through 947,850
turn on 268,448 through 743,777
turn off 512,123 through 625,874
turn off 498,262 through 930,811
turn off 835,158 through 886,242
toggle 546,310 through 607,773
turn on 501,505 through 896,909
turn off 666,796 through 817,924
toggle 987,789 through 993,809
toggle 745,8 through 860,693
toggle 181,983 through 731,988
turn on 826,174 through 924,883
turn on 239,228 through 843,993
turn on 205,613 through 891,667
toggle 867,873 through 984,896
turn on 628,251 through 677,681
toggle 276,956 through 631,964
turn on 78,358 through 974,713
turn on 521,360 through 773,597
turn off 963,52 through 979,502
turn on 117,151 through 934,622
toggle 237,91 through 528,164
turn on 944,269 through 975,453
toggle 979,460 through 988,964
turn off 440,254 through 681,507
toggle 347,100 through 896,785
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
December 5, 2023