day19: added

This commit is contained in:
Ishan Jain 2023-12-19 13:13:23 +05:30
parent 72b1f346b9
commit e156c2d7aa
Signed by: ishan
GPG Key ID: 0506DB2A1CC75C27
4 changed files with 1209 additions and 2 deletions

View File

@ -1 +1,165 @@
const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")];
#![feature(slice_split_once)]
#![feature(test)]
use std::collections::{hash_map::Keys, HashMap};
extern crate test;
const INPUTS: [&str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")];
#[derive(Debug)]
struct Rule {
variable: Option<char>,
condition: Option<char>,
match_against: Option<i64>,
jump_to: String,
}
fn process(data: &str) -> i64 {
let mut answer = 0;
let mut data = data.split("\n\n");
let mut workflows = HashMap::new();
for workflow in data.next().unwrap().lines() {
let (name, remain) = workflow.split_once(|x| x == '{').unwrap();
let mut rules = vec![];
for branch in remain.split(',') {
let rule = if branch.contains(|x| x == '<' || x == '>') {
let branch: Vec<char> = branch.chars().collect();
let variable = branch[0];
let condition = branch[1];
let num: String = branch[2..]
.iter()
.take_while(|&x| x.is_ascii_digit())
.collect();
let num: i64 = num.parse::<i64>().unwrap();
let mut jump_to = String::new();
for &c in branch.iter().rev() {
if c == '}' {
continue;
}
if c == ':' {
break;
}
jump_to.push(c);
}
let jump_to: String = jump_to.chars().rev().collect();
Rule {
variable: Some(variable),
condition: Some(condition),
match_against: Some(num),
jump_to,
}
} else {
let branch: Vec<char> = branch.chars().collect();
let mut jump_to = String::new();
for &c in branch.iter().rev() {
if c == '}' {
continue;
}
if c == ':' {
break;
}
jump_to.push(c);
}
let jump_to: String = jump_to.chars().rev().collect();
Rule {
variable: None,
condition: None,
match_against: None,
jump_to,
}
};
rules.push(rule);
}
workflows.insert(name, rules);
}
for input in data.next().unwrap().lines() {
let input: Vec<char> = input
.chars()
.filter(|&x| x.is_ascii_alphabetic() || x.is_ascii_digit() || x == ',')
.collect();
let mut vars = HashMap::new();
for set in input.split(|&x| x == ',') {
let variable = set[0];
let value: String = set[1..].iter().collect();
let value: i64 = value.parse::<i64>().unwrap();
vars.insert(variable, value);
}
let mut wname = "in";
let mut accepted = false;
loop {
if wname == "A" {
accepted = true;
break;
} else if wname == "R" {
accepted = false;
break;
}
let rules = workflows.get(&wname).unwrap();
for rule in rules {
if let Some(variable) = rule.variable {
let var_value = *vars.get(&variable).unwrap();
let check_against = rule.match_against.unwrap();
let result = match rule.condition.unwrap() {
'>' => var_value > check_against,
'<' => var_value < check_against,
_ => unreachable!(),
};
if result {
wname = &rule.jump_to;
break;
}
} else {
wname = &rule.jump_to;
break;
}
}
}
if accepted {
for v in vars.values() {
answer += v;
}
}
}
answer
}
fn main() {
for input in INPUTS.iter() {
println!("answer = {}", process(input));
}
}
#[bench]
fn part1(b: &mut test::Bencher) {
b.iter(|| {
let v = process(INPUTS[INPUTS.len() - 1]);
test::black_box(v);
});
}

View File

@ -1 +1,256 @@
const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")];
#![feature(extract_if)]
#![feature(slice_split_once)]
#![feature(test)]
use std::collections::HashMap;
extern crate test;
const INPUTS: [&str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")];
#[derive(Debug)]
struct Rule {
jump_to: String,
variable: char,
condition: char,
num: u64,
}
fn process(data: &str) -> u64 {
let mut data = data.split("\n\n");
let mut workflows = HashMap::new();
for workflow in data.next().unwrap().lines() {
let (name, remain) = workflow.split_once(|x| x == '{').unwrap();
let mut rules = vec![];
for branch in remain.split(',') {
let rule = if branch.contains(|x| x == '<' || x == '>') {
let branch: Vec<char> = branch.chars().collect();
let variable = branch[0];
let condition = branch[1];
let num: String = branch[2..]
.iter()
.take_while(|&x| x.is_ascii_digit())
.collect();
let num: u64 = num.parse::<u64>().unwrap();
let mut jump_to = String::new();
for &c in branch.iter().rev() {
if c == '}' {
continue;
}
if c == ':' {
break;
}
jump_to.push(c);
}
let jump_to: String = jump_to.chars().rev().collect();
Rule {
jump_to,
variable,
condition,
num,
}
} else {
let branch: Vec<char> = branch.chars().collect();
let mut jump_to = String::new();
for &c in branch.iter().rev() {
if c == '}' {
continue;
}
if c == ':' {
break;
}
jump_to.push(c);
}
let jump_to: String = jump_to.chars().rev().collect();
Rule {
jump_to,
condition: ' ',
num: 0,
variable: ' ',
}
};
rules.push(rule);
}
workflows.insert(name, rules);
}
let mut answer = 0;
let mut set = Vec::new();
set.push(("in".to_string(), 1..=4000, 1..=4000, 1..=4000, 1..=4000));
while !set.is_empty() {
let mut next = Vec::new();
for set_ip in set.drain(..) {
let (ref wname, mut x, mut m, mut a, mut s) = set_ip.clone();
let rules = workflows.get(wname.as_str()).unwrap();
for rule in rules {
match (rule.variable, rule.condition) {
('x', '>') if x.contains(&rule.num) => {
let new_x = rule.num + 1..=*x.end();
let remain_x = *x.start()..=rule.num;
x = remain_x;
if !new_x.is_empty() {
next.push((
rule.jump_to.clone(),
new_x,
m.clone(),
a.clone(),
s.clone(),
));
}
}
('x', '<') if x.contains(&rule.num) => {
let new_x = *x.start()..=rule.num - 1;
x = rule.num..=*x.end();
if !new_x.is_empty() {
next.push((
rule.jump_to.clone(),
new_x,
m.clone(),
a.clone(),
s.clone(),
));
}
}
('m', '>') if m.contains(&rule.num) => {
let new_m = rule.num + 1..=*m.end();
m = *m.start()..=rule.num;
if !new_m.is_empty() {
next.push((
rule.jump_to.clone(),
x.clone(),
new_m,
a.clone(),
s.clone(),
));
}
}
('m', '<') if m.contains(&rule.num) => {
let new_m = *m.start()..=rule.num - 1;
m = rule.num..=*m.end();
if !new_m.is_empty() {
next.push((
rule.jump_to.clone(),
x.clone(),
new_m,
a.clone(),
s.clone(),
));
}
}
('a', '>') if a.contains(&rule.num) => {
let new_a = rule.num + 1..=*a.end();
a = *a.start()..=rule.num;
if !new_a.is_empty() {
next.push((
rule.jump_to.clone(),
x.clone(),
m.clone(),
new_a,
s.clone(),
));
}
}
('a', '<') if a.contains(&rule.num) => {
let new_a = *a.start()..=rule.num - 1;
a = rule.num..=*a.end();
if !new_a.is_empty() {
next.push((
rule.jump_to.clone(),
x.clone(),
m.clone(),
new_a,
s.clone(),
));
}
}
('s', '<') if s.contains(&rule.num) => {
let new_s = *s.start()..=rule.num - 1;
s = rule.num..=*s.end();
if !new_s.is_empty() {
next.push((
rule.jump_to.clone(),
x.clone(),
m.clone(),
a.clone(),
new_s,
));
}
}
('s', '>') if s.contains(&rule.num) => {
let new_s = rule.num + 1..=*s.end();
s = *s.start()..=rule.num;
if !new_s.is_empty() {
next.push((
rule.jump_to.clone(),
x.clone(),
m.clone(),
a.clone(),
new_s,
));
}
}
(' ', ' ') => {
next.push((
rule.jump_to.clone(),
x.clone(),
m.clone(),
a.clone(),
s.clone(),
));
}
_ => unreachable!(),
}
}
}
next.retain(|(wname, _, _, _, _)| wname != "R");
for (_, x, m, a, s) in next.extract_if(|(wname, _, _, _, _)| wname == "A") {
answer += (x.end() - x.start() + 1)
* (m.end() - m.start() + 1)
* (a.end() - a.start() + 1)
* (s.end() - s.start() + 1);
}
set = next;
}
answer
}
fn main() {
for input in INPUTS.iter() {
println!("answer = {}", process(input));
}
}
#[bench]
fn part2(b: &mut test::Bencher) {
b.iter(|| {
let v = process(INPUTS[INPUTS.len() - 1]);
test::black_box(v);
});
}

771
src/day19/input.txt Normal file
View File

@ -0,0 +1,771 @@
vm{a>1183:zz,s>1553:A,s<827:xc,hls}
rvv{m<3430:A,m>3663:A,a<1488:mnf,prg}
px{s>1361:cfv,x>2479:R,R}
pz{x<2570:R,s>1531:ccq,x<2716:dgp,R}
sh{m>1073:A,s>1756:R,m<1022:A,A}
nvd{x>3561:sc,x<3455:R,R}
nv{x>2977:A,a>1201:ddc,gvm}
hg{x<2434:bss,s<2928:pcd,s<3292:A,A}
ptn{m>3660:A,x<2351:R,A}
hr{m>733:A,a<2380:A,A}
qmg{m>478:R,m<435:A,x<2220:R,A}
sjd{s<1082:A,m>261:A,m<97:R,A}
zqn{x<2073:A,m<171:A,x<2097:R,A}
gl{a>1924:nl,zt}
lbc{x<1142:A,R}
fmk{a>503:A,R}
gml{s<3380:A,m>798:R,s<3503:R,A}
ch{a>934:zl,A}
qx{x<234:rrc,s<2612:bcl,fs}
vl{m<2660:R,R}
rb{s>2378:cgs,s>835:xh,dp}
lvp{s>2739:A,m<2881:R,x<705:R,R}
fd{s<364:R,a>1385:R,R}
qv{m<2401:R,x>2123:R,m>2587:bgv,R}
tkh{x<1920:R,A}
hk{x<1278:hbd,x>1387:rbc,s>3396:htd,R}
mlt{a<853:R,a>1390:R,a<1171:A,R}
ks{a>368:A,a<191:R,zhk}
nzx{s<3853:R,m>857:R,R}
vc{m>487:vmt,a>1749:A,x<3155:A,R}
cv{m<2152:R,m<2644:pqq,lf}
xkn{s>3660:plx,x>2238:clg,qbj}
knc{x<1239:R,m>1199:R,a<1317:R,knt}
klx{s>1488:R,s<1387:R,s<1441:R,R}
lhr{s<2678:A,x>1197:R,x>1073:R,R}
bzn{s>2287:xfj,hvz}
qgz{x>3207:R,A}
xh{s<1439:A,m<2009:R,s>2021:A,A}
dq{x>2175:xp,s<2001:scq,s>2748:ls,ss}
tx{x>2096:R,x<2032:R,R}
zhk{m>1188:A,s<1078:R,s>1244:A,R}
vlb{s<2427:A,m>3316:A,m>3139:R,R}
qgx{m>3370:A,a>2737:A,ddh}
cqj{s>3593:A,zcg}
svf{s>3136:R,A}
sk{s<1016:bc,m>1282:px,a>2249:jnb,gm}
dz{s>3505:R,R}
zgf{m<3013:dz,A}
vgl{a<1054:A,a<1111:A,s>2907:A,R}
rrv{a<865:R,m>681:R,x>2331:A,A}
mls{s<2648:vmh,s>3421:gnh,R}
hkl{m>728:A,s<3565:A,s>3802:A,R}
kv{x>644:rfc,a<810:jq,vm}
xss{m>1261:A,s<3798:A,R}
gp{s>2747:A,a>1724:A,R}
sl{m>845:A,m<821:A,s>2336:pjd,R}
tvd{m<3152:R,A}
ncj{a<2018:A,x<732:jhj,a<2302:R,A}
fkp{m>3388:A,x>114:A,R}
hq{s<846:ppv,a<748:ks,jtf}
jz{m>1069:gv,m<692:tkb,lgk}
qmb{x<116:A,m>2882:ptf,sx}
vnp{x>2434:kl,pb}
smd{s>1917:lzh,a<2664:A,a<3135:bvn,lm}
pqq{a>2069:A,m<2333:R,x>3449:A,R}
jl{m>841:cn,A}
flz{a<3586:A,m<1136:zq,s<3271:A,lsn}
bc{a<1970:A,x<2521:A,s<391:gmf,A}
tpz{s<3618:A,s<3784:A,A}
xpl{s>1239:R,a>3100:A,a<2896:grn,hsc}
hks{x>1594:R,x<1522:R,R}
dgp{x>2643:R,A}
hn{a>1185:ppk,fmk}
ppv{s<287:R,x>3713:jn,s<491:mlt,nt}
ddc{a>1682:R,x<2940:R,s>468:A,A}
pfq{m<1280:R,A}
xm{s>699:A,m<987:A,R}
zh{a<1072:tvj,s<1394:rvv,a<1577:frl,lvd}
tdv{s<2492:dv,s>3179:ggn,m<1376:A,R}
jzh{a<2595:A,A}
rj{x>1288:R,a>2896:A,a>2479:A,R}
cgs{a>2023:A,a<1265:A,R}
xvh{m<3313:R,m>3757:R,a<1952:R,A}
qnx{a<525:zrf,xt}
cnh{a<2840:A,x<3210:A,x>3254:R,R}
kf{x>3868:sbg,m<2812:nss,lh}
jn{m<1080:A,x>3835:A,R}
rfc{s<1719:mj,s<2762:snr,s>3274:vcv,R}
bbg{x>2282:vmk,x>2004:pn,tl}
nt{m>1057:A,R}
qh{s<1994:knc,hn}
dn{s<3789:R,A}
pqx{x>3271:rz,x<3064:mcg,a<2631:djn,mz}
bvn{s<1222:A,a>2934:A,R}
lr{a<1053:A,R}
jtf{s<1212:R,A}
bgv{a>3165:R,R}
bmf{a>3882:R,s>1650:R,mf}
tc{s>3049:A,s<2766:A,A}
gv{m>1595:cnl,a>1396:lmt,drc}
lgl{m<351:ngf,m<488:dgx,vnc}
jnb{m<1097:R,a<3213:cq,A}
pnq{a>2281:R,m<669:A,R}
gmg{m>351:qmg,R}
clb{s<2215:A,m<2837:R,A}
gg{x>2538:nvf,cl}
tl{m>206:fsb,x<1719:zf,rlr}
gzx{m>3489:R,a>2713:A,A}
fg{x<3619:mpx,x<3748:mls,x>3874:gbx,khk}
pvm{m>1085:A,s>3172:nz,A}
tfn{s<543:R,x<3543:A,A}
sbg{m<2660:R,m>3416:A,A}
mrg{x>2964:R,R}
bhr{m>865:A,x<2244:A,R}
dgx{m<417:A,s<2739:R,m<459:A,R}
xhn{x<3057:gjm,vc}
fbb{m>1288:dx,s<2068:jm,jjm}
sgz{m>984:A,x>3081:A,a>3217:A,A}
vs{m<1169:hs,m<1297:R,A}
xrj{m>732:R,sdv}
xbl{m<1272:A,x>3628:R,x<3496:A,R}
mdr{m<332:A,R}
chd{a<2048:A,x<2482:A,x>2562:A,A}
jvk{a<920:rzv,a<1584:cmf,a<1836:gt,xl}
br{a<2910:R,a<3507:A,lvp}
lgc{s<992:nlh,a<2694:tkx,m>3224:gjj,bz}
zj{m>663:gmv,dnz}
lgd{x>816:R,pjm}
bjn{m>3391:A,s<3081:R,s<3246:A,A}
krh{x<1915:R,A}
nhb{m<614:dj,m>792:nj,m<690:zj,fg}
mnr{m>1255:skp,nfj}
rlr{x>1819:R,a>1962:gs,A}
xv{x<3300:vld,s<1489:gb,m>993:tsz,nhb}
gvm{a<623:R,R}
fsb{m<461:R,a>1433:A,kjk}
mbv{s<960:tp,s>1175:kk,s<1082:pfq,tfq}
hp{x>2431:A,m<3181:R,s>3240:A,R}
bb{a<3627:fr,m<466:R,A}
xzx{m>1383:sv,a<1170:A,m<1358:R,R}
pb{x<2284:A,m<714:R,R}
kp{a>1357:A,A}
qtd{s<3267:A,A}
hcm{a>467:dfj,s<1620:R,s<2873:nf,A}
jjm{s<2290:nhx,a>2252:R,A}
pcd{s<2424:R,A}
tp{s<469:R,a<2234:A,x<3742:A,R}
kjk{a<851:R,m<513:A,R}
mmz{x<2004:qlm,x<2254:mtl,s<1751:qd,zvs}
ptr{a<2461:km,m>447:R,a<3348:cnh,R}
zm{s>1606:klz,ftg}
xrt{a<1550:A,R}
sbr{x>2483:R,a<2075:A,m<2816:A,R}
pf{m<791:hts,jsv}
tkx{s>1199:R,s<1125:A,A}
grn{s>547:R,m<3017:R,a>2775:A,A}
vg{x>1792:tm,qc}
hf{s>2773:R,m<438:R,s<2146:R,A}
hsp{m<2717:A,x>717:R,s>3727:A,A}
gt{s<2890:lhr,s>3010:A,A}
ls{a>1437:sn,s<3562:A,A}
ngj{s>2864:R,m<2775:bx,m<2871:sbr,ck}
hdk{x>541:R,s>1511:R,R}
jmt{s<3094:A,s<3556:A,a>2207:xmf,R}
hvm{a>2514:A,A}
kgt{x>1454:R,s<534:A,m>885:A,A}
hls{s<1144:A,A}
njb{x<2719:A,x>2762:R,R}
jh{x<2545:xb,A}
mfd{m>532:R,R}
bd{s<3072:br,m<3111:zct,a>3044:cqj,fjz}
ntr{a>2878:sgv,m<753:bct,m>1139:mbv,xzz}
kh{x<1051:A,s<773:qr,lg}
kms{m<2988:A,s<3703:R,a<1450:R,R}
vkn{m<806:R,R}
hvz{m<2944:A,s>1175:R,x>859:A,A}
pq{m>205:R,x>3470:gk,R}
km{x>3174:A,R}
vld{s>2339:qg,m>889:bmd,s<826:bl,xhn}
lgk{m>824:smd,a>1947:rmj,m<769:ch,drt}
gs{s>2360:A,s<1232:R,A}
dnz{s<2401:xf,a>1632:A,A}
xs{m<2759:R,x<2870:A,m>2954:A,R}
cp{s<1351:qmx,x>1976:jdt,pqm}
xr{m>1671:R,a<3533:A,R}
sm{m<793:R,s<3293:A,R}
qcg{s>2887:R,x<3151:R,A}
tjx{x<493:A,a<2355:R,s>1009:R,R}
nqn{x<1222:kh,x<1385:pmz,bm}
rm{x>887:R,R}
nf{x<99:A,m<3351:A,A}
ftg{m<3250:R,s>1018:A,m<3737:A,R}
kn{x>356:A,m>1185:A,x<155:R,R}
dl{x>2699:pqx,m>2924:fq,mmz}
gx{x>1208:A,s>967:A,m<2304:A,R}
lv{a>1763:R,A}
ht{m<3647:A,s<3831:A,x>725:A,A}
sv{x>2597:A,A}
vkj{s<3644:R,x<2404:vx,A}
vqq{a>2275:A,x<3463:A,a>1986:A,R}
psg{a>1028:tfn,m<618:psh,x<3573:A,R}
fjz{s>3639:ht,a<2488:xbh,A}
cc{s<2864:A,A}
ssc{x>1119:A,m>1524:R,A}
kb{x<3670:djj,m>1409:R,a<2198:mn,lqp}
df{a<2596:tc,a<2848:cx,m>2658:cbf,mkv}
ltq{m>625:R,x>1441:A,A}
xf{m<641:A,R}
lp{x<291:R,m<3178:A,A}
dk{s<2625:R,R}
kgn{m>1510:A,s>3502:R,a>2501:A,R}
qq{m<1360:A,s<3310:R,m<2845:R,R}
klz{m>3112:A,R}
jdv{x<381:R,R}
lh{s<1341:R,m<3461:A,R}
cb{x>2942:R,m>3790:R,R}
tsz{s>2445:gz,x>3605:fbf,x<3482:fbb,mnr}
qbj{m<802:R,A}
cd{m<1141:A,s<2515:R,a<1422:R,A}
sgp{m>1145:ssc,x<1161:R,A}
cm{x<1933:qpn,a<2777:dg,cnf}
znt{a<2290:A,a<3190:vk,R}
mtt{m>376:A,R}
mf{m<806:R,A}
prg{x<1294:R,a>1707:A,m>3543:R,A}
ft{m<2422:gp,a<1183:qgz,xvh}
mz{s<2575:xpl,s>3077:zgf,a<3313:qcg,pvs}
bct{x<3600:vqq,s<618:mdr,x>3764:sjd,fmq}
gf{s<2503:R,a>3285:qtd,m<1374:A,vmp}
tz{s>3190:nqf,jvk}
lg{m>1143:R,a<982:R,R}
drc{a>536:rn,x<529:R,lxh}
nm{a<1427:R,x>3408:R,A}
hts{s>1487:A,m>698:xrt,A}
qtz{s<1011:R,R}
ddm{x>340:A,x<319:R,s<1599:bzj,lv}
jc{x>280:A,a<3299:A,A}
qng{s<3634:A,m>1302:A,s>3812:A,R}
qpn{m<1140:R,fmd}
kvb{a<3114:A,tbm}
ljr{x>3534:tpz,m<1068:bp,zn}
sg{x>1747:R,x<1703:R,a>1489:A,R}
sfq{a<1072:fkp,x<105:hc,A}
cl{a<934:A,A}
dfj{m<3096:R,s>2013:A,m>3595:R,A}
drt{s>1882:R,jdv}
pv{s>504:A,m<63:R,a<984:A,R}
nl{s<1832:A,s>2094:A,m<1134:R,A}
nss{x>3801:A,s>2588:R,a>2373:R,R}
pbt{m>1307:R,s<699:A,A}
pk{a<1744:R,x<2428:A,R}
zcg{x>828:A,A}
rbc{s<3400:A,s>3544:A,A}
bcl{x>372:zm,x<306:lks,ddm}
bss{x<2328:R,m>1938:A,R}
ptf{a>1421:R,R}
nvf{m<780:A,R}
qjn{x<2397:A,a<2150:R,s<1868:R,A}
xb{a>2372:R,m<2025:A,R}
zkq{a>1940:R,m>1247:R,R}
hc{m<3117:A,A}
sr{m>1431:jj,a>2656:gf,tdv}
qr{a<1147:A,A}
hm{m<2306:jz,x<568:qx,a>1672:zxr,lmb}
vmk{x>2620:fvj,fzf}
psd{s>2121:A,A}
xbh{a<2203:A,s>3321:A,m<3557:A,R}
jj{m>1493:R,m>1472:A,fx}
bg{x<2490:A,A}
zcz{s>3084:xkn,rq}
jm{a<2179:R,m>1166:nq,x>3379:A,sh}
lks{x<270:A,a<1938:R,s<1528:lp,A}
vfq{a<2089:R,x<2357:tkh,R}
dp{m>1990:R,a>2297:R,a<1258:A,R}
qnm{s>659:A,A}
qhl{x>3591:R,x<3472:A,A}
cr{m>3504:R,x>3188:R,R}
gz{s<3304:cc,m<1189:ljr,spj}
tzh{x<2173:A,gff}
kkt{m>310:A,R}
db{a<3485:R,a<3571:A,fz}
fkl{m<2901:A,m<3404:A,A}
frl{m<2991:kp,s<2098:dkj,A}
rxb{m<1119:sgz,rl}
fm{a>2340:A,s<3674:A,s>3741:mnz,kms}
bq{x<2441:R,s<2799:R,a<2466:R,A}
zz{m<3050:A,A}
fz{x<2421:A,m>810:A,m<673:A,R}
fx{m>1457:R,x>2635:A,a>2974:R,R}
gmv{m>677:R,s>2519:A,R}
fsl{s<2287:R,x>1621:sg,cd}
xfj{a>475:R,R}
sc{s>375:R,A}
lpv{m>2792:R,x<1424:R,A}
hfs{x<3611:A,A}
rn{x>399:R,m<1316:A,R}
hsf{a>3327:R,s>673:R,R}
mnz{a<1010:A,A}
bz{s>1309:vl,nkb}
fk{a>3497:R,x>3195:R,m>2635:A,A}
rmj{x<448:jc,a>2879:R,s<1459:ghd,rlq}
zl{a>1306:A,s<2659:A,A}
fs{s<3482:zr,m>3392:jpk,s>3818:nct,fm}
zrf{a<217:krh,A}
rq{m<773:hz,s<2769:vfq,a>2363:tzh,vt}
lt{m>1537:dl,x>2911:xv,m<931:sjt,xnc}
hz{a>1416:pnq,s<2889:rrv,A}
nz{m>984:A,A}
pjm{m<3046:R,m<3388:R,s>3134:R,R}
np{m>2392:A,m<1859:R,A}
vk{x<3036:R,s<3439:A,x<3072:R,R}
rr{s<1000:rm,x<859:ntc,a<1317:rng,vff}
rz{x>3717:kf,m<2922:cv,pnh}
lf{m>2756:A,R}
fc{m>1411:R,s>1886:R,x<3815:R,R}
lqb{s>3856:A,qt}
qt{m<1592:R,R}
kc{s>3452:A,R}
pvs{a<3647:fk,s<2816:R,m<2857:A,cr}
lmt{m<1365:kn,m>1472:rvm,a>2599:hdk,vzp}
gff{s<2924:A,A}
gjm{x<3003:mrg,m<497:A,A}
hsc{m<2903:R,a<3017:A,R}
jb{s<694:A,x>1926:R,A}
tfq{m>1282:A,x<3709:A,m<1207:A,R}
vzp{x<527:R,s>2182:A,x>715:R,A}
nb{x<1132:R,x<1280:A,R}
cxm{a<898:bzn,s<2217:rr,x<887:lgd,nlx}
vff{s<1676:R,A}
gnh{x<3684:R,A}
qb{x<1997:A,x<2553:R,s>2813:A,A}
tzj{s>3107:A,s>2405:R,R}
bf{x>1824:dcs,a>1601:ksd,s<2725:fsl,gxr}
qqf{s>1514:A,x<2599:R,A}
dx{s>2083:R,m>1379:R,nm}
ldm{s>2150:A,rrd}
djn{x<3161:ps,s>1898:ft,jlv}
gmf{x>2723:A,s<133:R,x<2640:R,R}
dcs{s<2769:vd,x>2068:xds,s>3238:qng,A}
qmx{a<1480:A,x<2123:bzl,a<3156:bg,A}
kk{s<1335:R,m<1297:R,A}
dkj{a>1343:A,A}
xlk{m<2836:A,A}
scq{a<1548:A,m<3765:mq,A}
znm{x>1594:A,R}
ps{a>1003:xlk,m<3138:lpp,A}
dbf{s>3195:R,R}
gk{m<181:A,A}
nct{m<3020:A,A}
gbx{x>3944:A,s>3134:hkl,R}
jsk{s>1677:A,x>2026:A,R}
dr{x<3945:R,a<2776:A,A}
bzl{x>1868:A,a<2821:A,R}
cx{m>2455:dnb,a>2709:R,s<3070:htj,R}
xd{m>858:A,s<2961:R,R}
ggn{a>2227:R,x>2639:A,m<1390:A,R}
vxm{m>2289:zh,s>1653:qh,nqn}
fvj{m<219:A,a<2272:A,tfc}
sx{m>2596:R,A}
lxh{a>331:A,x>683:A,x>610:R,R}
rl{m<1357:A,x<3087:R,R}
grp{s>3855:A,m<667:A,x<2245:A,A}
zv{m>1791:A,m<1531:A,m>1696:R,A}
mn{s>2065:R,a<1406:A,R}
mcg{m<3079:dc,m>3425:krs,nmz}
psh{m<500:R,x>3445:A,A}
qrv{x<2470:A,m>2371:A,A}
srj{a>1381:R,R}
kjz{x<1232:A,m>3405:A,R}
tg{s<844:R,R}
htj{s<2911:R,a<2642:A,x>1183:R,R}
lzh{s<3174:A,A}
qbm{x>2058:hf,m>452:mfd,R}
kl{m<785:fd,A}
cpk{s<2729:A,s<3205:kkt,A}
ltm{s<1409:R,m<1291:R,s>1745:R,A}
mmg{s<1940:A,A}
tqv{x<426:R,s>3679:R,a<2066:A,A}
cn{a<858:R,a<1615:A,R}
pqm{a>2076:A,xk}
nj{m>881:jmt,a>2289:sl,s<2968:jl,vf}
zfz{a>1671:R,x>2079:A,a>738:A,R}
qlm{m<2271:rb,s>2626:gc,s>1558:ldm,nfg}
bl{x>3102:ptr,a<2210:nv,a<3345:sxk,bb}
lm{s>758:R,A}
nhx{m>1155:A,a>2450:A,a<1634:A,A}
kdr{m>1489:svf,x<2511:lr,x<2711:R,R}
lqp{m<1376:R,m>1391:A,x>3728:A,A}
nfg{x<1690:A,qtz}
xk{s>2763:A,A}
knt{s<1778:A,s<1896:A,m<555:A,R}
dd{a>3081:R,a>3002:A,m>1086:R,R}
pmz{x>1281:R,x>1256:sjq,m>1448:R,R}
xzz{m>958:R,s>522:R,A}
crx{x>1234:A,s<3890:zb,s<3952:A,jzh}
zn{m>1110:R,s<3768:A,A}
nfj{s>1843:bcs,R}
nkb{m<2760:R,x>769:A,x>670:R,A}
vnc{x>3752:A,R}
qg{x>3131:vkn,znt}
zvs{m<2143:hg,m<2504:qrv,ngj}
tm{s<1271:tg,m<1275:R,s<1644:klx,A}
xp{a<1360:R,a<2766:ptn,A}
spj{m>1327:A,a>1995:xbl,s<3584:kc,xss}
mv{a>1916:A,s<2719:A,R}
ts{a>1676:R,qq}
mg{s>3771:crx,xhh}
drx{x<1283:R,x<1400:R,m<1865:ltq,lpv}
pns{m>3601:rj,R}
mqm{x>3879:dr,A}
fr{m>581:R,a<3478:R,a<3558:A,R}
zr{m>2904:bjn,m>2621:lmz,a>1654:A,A}
vt{s>2877:xd,m<845:pj,a<1087:qb,R}
ntc{x<814:A,x>834:A,x>824:A,R}
lvd{s<2101:A,s<2272:kjz,s<2403:A,R}
pvh{a<769:A,s<1303:R,A}
sdv{a<3863:R,s>448:R,R}
svq{m<2132:ql,m>3275:pns,s>1529:tns,cmx}
pjd{x<3585:A,x<3803:A,a<3099:A,R}
mkv{m<1309:qrh,a>2958:A,zv}
hs{m<1061:R,s>1300:R,s<1181:A,A}
lmb{x>757:cxm,kv}
fzf{m>295:chd,s>1576:bq,x>2441:vp,A}
tfc{s>1764:R,A}
tpp{a>2579:A,x<817:R,x<896:A,A}
vcv{x>692:A,A}
zq{a>3737:A,s>3315:R,A}
jhm{s<753:mtt,btf}
dh{s<1380:A,x>2431:qqf,R}
mm{x>958:jfr,hm}
in{x>1468:lt,mm}
cj{s<1434:A,s<1468:A,x>3841:R,A}
clg{a<2125:gml,sm}
cmx{m>2629:nb,m>2435:A,gx}
jdt{s>2329:hp,qjn}
btf{s<1196:A,s>1347:cj,A}
vx{s<3857:A,R}
xhh{x<1190:A,s<3588:kgn,R}
mpx{s>2502:hr,m<734:A,s<1960:R,R}
gm{s>1278:R,x<2660:A,x>2820:A,njb}
vd{x>2103:A,s<2409:A,R}
vp{m>186:R,m>70:R,A}
snr{s<2254:R,A}
cfv{a<2487:R,a<3371:R,A}
jhn{m<98:A,m>138:R,s>1549:A,R}
mj{m>2942:A,x<716:R,R}
vmt{m>700:A,m>602:A,x<3154:A,A}
mnf{a>1311:A,a>1172:A,a<1121:R,R}
htd{s>3523:A,s>3444:R,R}
plx{m<772:grp,a>2125:bhr,dn}
dj{a<2182:jd,a<3303:lgl,a<3650:cpk,nzs}
cz{x<2157:pf,a>2249:khs,s<971:vnp,gg}
njp{s<1698:sk,m<1332:js,a<1778:ggr,sr}
znl{s>2440:pk,R}
cbf{s>3110:A,a<2954:A,a>3014:tb,hx}
cnl{s<1898:R,m>2017:A,A}
js{x>2592:pvm,s>3023:vkj,znl}
jhj{a<2334:R,R}
jq{m>3177:A,R}
nqf{s>3639:lqb,a<1075:hk,s>3378:drx,ts}
nzs{x>3683:A,a<3814:R,a<3937:A,A}
sd{m<2871:R,m>3062:A,m>2981:R,R}
qd{s<1038:jh,a<1520:dh,pg}
xnc{x>2260:njp,a>2033:gpk,jhr}
kfj{m>3248:R,a<1183:A,A}
dc{m>2235:xs,R}
jvf{s>2962:R,A}
xmf{m>941:A,A}
gxr{s>3171:cfx,A}
bm{s>1096:pvh,x>1440:kgt,s>409:xm,R}
rvm{s>2200:A,s>1370:R,A}
ql{s>1394:R,a<2894:A,a<3546:hsf,qnm}
sjq{s>975:A,s<482:A,A}
sn{a<2975:R,x<1713:A,A}
gpk{s>1665:cm,kx}
djj{s<1816:R,x>3636:R,s<2080:A,A}
ddh{m<3011:A,x<129:R,R}
jd{m<355:A,a>1437:pd,m<446:qhl,A}
pcj{a<2496:A,x<3528:R,x<3561:R,R}
skp{m>1392:R,pcj}
qc{a>1672:pbt,znm}
ck{s<2421:R,m>2906:R,x>2403:R,A}
xt{m<1246:R,R}
gc{a<1810:R,s>3306:R,a>2598:jvf,A}
hbd{x>1075:A,R}
vmp{m<1408:A,a>2961:A,R}
hx{a>2974:R,A}
fbg{a<2593:A,x<1659:A,R}
pd{s<3029:A,m>503:A,a<1805:R,R}
bcs{s>2192:R,a<1510:R,x<3543:R,A}
vf{m<833:R,s>3564:nzx,hfs}
zxr{s<1570:lgc,s>2450:bd,rv}
ghd{m<769:A,R}
bp{a<2190:A,R}
zb{m>1363:A,R}
pg{m<2433:A,A}
dcm{s<2128:np,R}
cfx{s<3624:R,a<1417:R,A}
mq{a<2916:A,R}
pn{x>2123:gmg,m<324:zqn,s<1528:zfz,qbm}
ksd{a>1863:tzj,A}
zct{s>3424:hsp,dbf}
rv{a<2499:ncj,kvb}
tmf{s<2608:svq,a>3115:mp,s<3396:df,mg}
sxk{s>530:R,A}
pnh{a>2058:R,vlb}
dv{m>1366:A,s>2165:A,s<2008:R,R}
bzj{s<900:A,A}
pj{s>2824:A,R}
jpk{m>3607:tqv,a<1558:A,A}
gjj{a>3205:R,A}
fmd{a>2949:R,m>1342:R,A}
zs{x<1660:A,a<2612:R,a<3456:R,R}
dg{s>2654:R,m>1232:R,tx}
nlx{a>1408:R,A}
bx{s>2249:R,R}
fmq{m<360:A,s>1052:A,m>545:A,A}
zf{x>1620:zs,jhn}
tb{a>3066:R,m>3310:R,x<1247:R,R}
rrd{a<1418:A,A}
tns{x>1214:clb,psd}
khs{a<3264:pz,a<3659:db,s<914:xrj,bmf}
ngf{s>2856:R,R}
ppk{x>1182:R,x<1100:A,m>984:A,R}
xl{m>2189:fkl,zkq}
rlq{x<641:A,m<750:R,R}
rrc{a>1660:qgx,a<993:hcm,a<1223:sfq,qmb}
qrh{m<576:R,R}
hlx{a>813:A,x>3893:R,a>288:fc,A}
rng{x>916:A,a<1114:R,A}
jhr{a<1276:qnx,s<1919:vg,bf}
jsv{x>1807:jsk,s>969:fbg,x<1588:A,R}
lpp{a<514:A,R}
jlv{m<2542:R,R}
fbf{m<1322:gl,x<3764:kb,a<1952:hlx,mqm}
mtl{a>1942:qv,dcm}
zt{s<2098:R,x<3787:R,A}
jfr{a>2035:tmf,s>2525:tz,vxm}
tbm{x>766:R,a>3513:A,A}
lsn{a<3774:A,s>3552:A,A}
sgv{m<784:A,a>3308:R,x>3600:dd,R}
cq{a>2578:R,x>2509:A,a>2365:R,R}
nlh{m<3231:sd,m>3657:tpp,s<642:gzx,R}
lmz{x>381:A,A}
sjt{m<600:bbg,s<2568:cz,zcz}
fqs{m>432:R,A}
xds{x<2137:R,m<1156:A,s>3293:A,A}
bmd{a>1928:rxb,jg}
ggr{m>1415:kdr,xzx}
gb{a>1826:ntr,m>789:hq,x>3731:jhm,lsd}
vmh{s<1951:R,s<2191:R,s<2408:A,R}
jg{a<1031:ltm,s>938:R,m<1260:R,A}
lsd{m>298:psg,m<157:rvc,s>641:pq,nvd}
khk{m<734:mv,x>3800:dk,m<766:srj,R}
rzv{s>2836:R,lbc}
cmf{a>1180:R,vgl}
nmz{s>2289:A,a<1807:kfj,A}
kx{s<1079:jb,vs}
fq{m>3433:dq,cp}
krs{x<2865:hvm,s<2397:R,a<1859:cb,A}
xc{s>321:R,R}
cnf{s<2854:R,R}
ccq{a>2840:A,a>2588:A,A}
dnb{m>3126:R,x>1135:R,R}
rvc{x<3541:pv,s<560:R,A}
mp{x>1208:xr,m>1849:tvd,x<1070:flz,sgp}
tvj{s>1313:mmg,R}
nq{x>3404:A,x<3355:A,A}
tkb{s<2166:tjx,fqs}
ss{x<1714:hks,s>2485:A,R}
{x=172,m=2372,a=1091,s=1657}
{x=1402,m=280,a=391,s=12}
{x=942,m=1181,a=23,s=1229}
{x=16,m=1535,a=2044,s=1887}
{x=2254,m=532,a=197,s=2575}
{x=179,m=438,a=761,s=551}
{x=717,m=92,a=326,s=60}
{x=146,m=854,a=390,s=1349}
{x=605,m=416,a=1148,s=194}
{x=213,m=290,a=15,s=708}
{x=137,m=2082,a=554,s=1532}
{x=147,m=150,a=2659,s=1613}
{x=390,m=2455,a=146,s=3}
{x=3276,m=1513,a=1317,s=138}
{x=1081,m=430,a=150,s=2846}
{x=410,m=2044,a=2944,s=182}
{x=1510,m=268,a=640,s=1584}
{x=31,m=1343,a=294,s=93}
{x=2289,m=511,a=901,s=3105}
{x=484,m=190,a=121,s=72}
{x=487,m=261,a=3542,s=160}
{x=597,m=520,a=495,s=621}
{x=425,m=1480,a=11,s=2400}
{x=43,m=611,a=3895,s=317}
{x=1579,m=55,a=689,s=1774}
{x=616,m=2362,a=264,s=368}
{x=694,m=987,a=1156,s=381}
{x=884,m=2008,a=1870,s=198}
{x=1009,m=929,a=2932,s=1452}
{x=3194,m=47,a=2301,s=444}
{x=21,m=3254,a=263,s=641}
{x=2885,m=2911,a=282,s=638}
{x=1069,m=569,a=2718,s=129}
{x=2526,m=356,a=681,s=661}
{x=1246,m=1481,a=308,s=1692}
{x=2170,m=491,a=284,s=3017}
{x=378,m=1564,a=615,s=723}
{x=2800,m=566,a=210,s=248}
{x=2582,m=453,a=2197,s=557}
{x=11,m=10,a=616,s=1062}
{x=338,m=888,a=292,s=261}
{x=667,m=5,a=1358,s=1198}
{x=2104,m=875,a=1449,s=517}
{x=1656,m=2017,a=2787,s=988}
{x=140,m=766,a=1804,s=3514}
{x=1365,m=1238,a=465,s=584}
{x=47,m=2865,a=123,s=1223}
{x=139,m=2197,a=1619,s=703}
{x=105,m=812,a=21,s=2232}
{x=1182,m=1171,a=2518,s=95}
{x=1072,m=215,a=1448,s=1520}
{x=986,m=203,a=5,s=847}
{x=3825,m=768,a=86,s=502}
{x=97,m=1893,a=895,s=1317}
{x=1387,m=731,a=286,s=2547}
{x=579,m=611,a=255,s=2335}
{x=1041,m=1601,a=447,s=3044}
{x=2357,m=408,a=272,s=1119}
{x=2002,m=346,a=1288,s=1425}
{x=2970,m=288,a=412,s=450}
{x=251,m=2316,a=3,s=1011}
{x=3261,m=748,a=1232,s=2373}
{x=1060,m=449,a=3108,s=2579}
{x=160,m=970,a=363,s=1336}
{x=1619,m=2194,a=2472,s=1893}
{x=306,m=367,a=105,s=780}
{x=1206,m=34,a=153,s=537}
{x=203,m=30,a=566,s=1080}
{x=2198,m=1171,a=1559,s=1094}
{x=2112,m=389,a=309,s=1384}
{x=2614,m=41,a=280,s=1051}
{x=1114,m=656,a=2538,s=983}
{x=179,m=111,a=579,s=48}
{x=506,m=456,a=703,s=2537}
{x=1042,m=2522,a=495,s=1146}
{x=465,m=75,a=1416,s=2374}
{x=1453,m=277,a=1729,s=1777}
{x=152,m=528,a=318,s=929}
{x=912,m=780,a=942,s=318}
{x=2621,m=345,a=348,s=45}
{x=241,m=2682,a=621,s=1422}
{x=931,m=261,a=781,s=1088}
{x=1852,m=1551,a=1614,s=77}
{x=596,m=3,a=521,s=2196}
{x=474,m=122,a=1449,s=241}
{x=951,m=1589,a=2209,s=1327}
{x=270,m=1945,a=1202,s=106}
{x=472,m=860,a=295,s=656}
{x=770,m=437,a=518,s=573}
{x=3241,m=1288,a=254,s=3937}
{x=548,m=3,a=54,s=366}
{x=1990,m=199,a=2311,s=3004}
{x=151,m=2999,a=48,s=523}
{x=38,m=1108,a=924,s=1562}
{x=2711,m=2118,a=2563,s=328}
{x=124,m=1086,a=451,s=164}
{x=1600,m=1301,a=10,s=1997}
{x=517,m=1194,a=1328,s=3193}
{x=1321,m=70,a=356,s=54}
{x=3295,m=207,a=347,s=1513}
{x=129,m=17,a=1846,s=1152}
{x=272,m=388,a=1146,s=387}
{x=1132,m=1709,a=284,s=369}
{x=1223,m=923,a=435,s=573}
{x=3840,m=2389,a=492,s=1224}
{x=280,m=3516,a=1175,s=424}
{x=34,m=296,a=261,s=724}
{x=49,m=183,a=2318,s=215}
{x=1352,m=147,a=786,s=407}
{x=719,m=2783,a=59,s=804}
{x=350,m=372,a=1791,s=1003}
{x=691,m=940,a=1405,s=1427}
{x=3049,m=1732,a=1397,s=2526}
{x=2951,m=132,a=492,s=2146}
{x=488,m=1311,a=2542,s=1184}
{x=530,m=308,a=2010,s=486}
{x=137,m=172,a=380,s=1063}
{x=1428,m=1048,a=1757,s=1064}
{x=941,m=439,a=1833,s=939}
{x=2372,m=273,a=1551,s=95}
{x=1602,m=2660,a=2193,s=1021}
{x=642,m=843,a=2398,s=1104}
{x=1003,m=708,a=1786,s=2422}
{x=655,m=1470,a=225,s=482}
{x=226,m=29,a=745,s=607}
{x=987,m=398,a=1100,s=613}
{x=659,m=1639,a=744,s=1069}
{x=362,m=1828,a=790,s=1391}
{x=1235,m=748,a=60,s=1862}
{x=110,m=433,a=336,s=432}
{x=1511,m=844,a=899,s=347}
{x=234,m=1081,a=1194,s=471}
{x=1192,m=1337,a=13,s=272}
{x=767,m=853,a=230,s=30}
{x=655,m=1229,a=124,s=219}
{x=16,m=239,a=3083,s=1006}
{x=1833,m=683,a=3193,s=434}
{x=19,m=426,a=1599,s=608}
{x=1043,m=978,a=61,s=524}
{x=177,m=35,a=237,s=1360}
{x=1230,m=1379,a=2644,s=16}
{x=229,m=963,a=197,s=1029}
{x=297,m=725,a=1565,s=123}
{x=2757,m=40,a=1236,s=309}
{x=1040,m=625,a=56,s=531}
{x=367,m=344,a=1240,s=388}
{x=687,m=2690,a=388,s=740}
{x=31,m=88,a=920,s=209}
{x=1394,m=3132,a=22,s=444}
{x=1937,m=1102,a=765,s=175}
{x=47,m=1091,a=155,s=808}
{x=19,m=604,a=474,s=1621}
{x=1508,m=805,a=1476,s=2622}
{x=1592,m=194,a=91,s=1226}
{x=819,m=262,a=2076,s=329}
{x=1319,m=858,a=1617,s=93}
{x=1018,m=22,a=2450,s=100}
{x=442,m=249,a=472,s=3367}
{x=468,m=844,a=1657,s=193}
{x=1884,m=1698,a=1139,s=1317}
{x=3199,m=441,a=1731,s=2192}
{x=494,m=1841,a=92,s=375}
{x=997,m=1494,a=1392,s=61}
{x=1373,m=376,a=1346,s=364}
{x=3243,m=21,a=358,s=2343}
{x=1109,m=2180,a=143,s=1450}
{x=669,m=1637,a=180,s=1996}
{x=378,m=37,a=282,s=325}
{x=1113,m=848,a=799,s=504}
{x=1331,m=2998,a=225,s=1206}
{x=348,m=1572,a=842,s=1597}
{x=2523,m=2371,a=1315,s=404}
{x=1530,m=517,a=1836,s=1274}
{x=1174,m=79,a=1840,s=1768}
{x=20,m=1602,a=2258,s=371}
{x=576,m=9,a=185,s=365}
{x=1592,m=130,a=2019,s=849}
{x=642,m=217,a=207,s=508}
{x=346,m=2993,a=3198,s=842}
{x=1396,m=397,a=1061,s=759}
{x=2383,m=28,a=1098,s=261}
{x=199,m=666,a=215,s=203}
{x=2053,m=1089,a=853,s=1982}
{x=675,m=2902,a=26,s=958}
{x=552,m=1064,a=319,s=858}
{x=3264,m=1458,a=40,s=1584}
{x=79,m=2884,a=501,s=3584}
{x=178,m=1273,a=608,s=2577}
{x=1937,m=1190,a=158,s=2404}
{x=997,m=1754,a=1575,s=1494}
{x=2525,m=704,a=218,s=718}
{x=589,m=243,a=1226,s=486}
{x=80,m=147,a=1711,s=1315}
{x=915,m=337,a=1163,s=947}
{x=1772,m=2171,a=574,s=1801}
{x=69,m=818,a=1813,s=175}
{x=1144,m=52,a=2809,s=752}
{x=2290,m=2094,a=1071,s=1688}
{x=183,m=1041,a=579,s=1039}
{x=315,m=165,a=862,s=242}

17
src/day19/sample.txt Normal file
View File

@ -0,0 +1,17 @@
px{a<2006:qkq,m>2090:A,rfg}
pv{a>1716:R,A}
lnx{m>1548:A,A}
rfg{s<537:gd,x>2440:R,A}
qs{s>3448:A,lnx}
qkq{x<1416:A,crn}
crn{x>2662:A,R}
in{s<1351:px,qqz}
qqz{s>2770:qs,m<1801:hdj,R}
gd{a>3333:R,R}
hdj{m>838:A,pv}
{x=787,m=2655,a=1222,s=2876}
{x=1679,m=44,a=2067,s=496}
{x=2036,m=264,a=79,s=2244}
{x=2461,m=1339,a=466,s=291}
{x=2127,m=1623,a=2188,s=1013}