-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path24-1.jq
34 lines (34 loc) · 960 Bytes
/
24-1.jq
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
reduce inputs as $cmd (
{input: ("99999999999999"/"" | map(tonumber)), w: 0, x: 0, y: 0, z: 0};
(
($cmd | match("inp (.*)").captures[].string) as $inp
| .[$inp] = .input[0] | .input[:1] = []
)
//
(
($cmd | match("add (.*) (.*)").captures | map(.string)) as [$a, $b]
| .[$a] += (.[$b | strings] // ($b | tonumber))
)
//
(
($cmd | match("mul (.*) (.*)").captures | map(.string)) as [$a, $b]
| .[$a] *= (.[$b | strings] // ($b | tonumber))
)
//
(
($cmd | match("div (.*) (.*)").captures | map(.string)) as [$a, $b]
| .[$a] = (.[$a] / (.[$b | strings] // ($b | tonumber)) | trunc)
)
//
(
($cmd | match("mod (.*) (.*)").captures | map(.string)) as [$a, $b]
| .[$a] %= (.[$b | strings] // ($b | tonumber))
)
//
(
($cmd | match("eql (.*) (.*)").captures | map(.string)) as [$a, $b]
| .[$a] = if .[$a] == (.[$b | strings] // ($b | tonumber)) then 1 else 0 end
)
//
error($cmd)
)