[2024][ruby][7.2]

main
Alpha Chen 5 days ago
parent 485fe6be3b
commit cd7ed1621b
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -6,9 +6,11 @@ input = DATA.readlines
pp input.filter_map {|val, vars| pp input.filter_map {|val, vars|
vals = vars.inject {|n,x| vals = vars.inject {|n,x|
%i[ + * ].flat_map {|op| Array(n).flat_map {[
Array(n).map { _1.send(op, x) } _1 + x,
} _1 * x,
"#{_1}#{x}".to_i,
]}
} }
vals.include?(val) && val vals.include?(val) && val
}.sum }.sum

Loading…
Cancel
Save