From 79ad34fc6a037348a0f543fb8e4be382573e2256 Mon Sep 17 00:00:00 2001 From: Burnus Date: Mon, 3 Apr 2023 17:04:47 +0200 Subject: [PATCH] Added Solution for 2020 day 02 --- 2020/day02_password_philosophy/Cargo.toml | 8 + 2020/day02_password_philosophy/challenge.txt | 49 + 2020/day02_password_philosophy/src/lib.rs | 87 ++ .../tests/challenge_input | 1000 +++++++++++++++++ .../tests/sample_input | 3 + 5 files changed, 1147 insertions(+) create mode 100644 2020/day02_password_philosophy/Cargo.toml create mode 100644 2020/day02_password_philosophy/challenge.txt create mode 100644 2020/day02_password_philosophy/src/lib.rs create mode 100644 2020/day02_password_philosophy/tests/challenge_input create mode 100644 2020/day02_password_philosophy/tests/sample_input diff --git a/2020/day02_password_philosophy/Cargo.toml b/2020/day02_password_philosophy/Cargo.toml new file mode 100644 index 0000000..bf05710 --- /dev/null +++ b/2020/day02_password_philosophy/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "day02_password_philosophy" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/2020/day02_password_philosophy/challenge.txt b/2020/day02_password_philosophy/challenge.txt new file mode 100644 index 0000000..639147b --- /dev/null +++ b/2020/day02_password_philosophy/challenge.txt @@ -0,0 +1,49 @@ +Your flight departs in a few days from the coastal airport; the easiest way down to the coast from here is via [toboggan](https://en.wikipedia.org/wiki/Toboggan). + +The shopkeeper at the North Pole Toboggan Rental Shop is having a bad day. "Something's wrong with our computers; we can't log in!" You ask if you can take a look. + +Their password database seems to be a little corrupted: some of the passwords wouldn't have been allowed by the Official Toboggan Corporate Policy that was in effect when they were chosen. + +To try to debug the problem, they have created a list (your puzzle input) of *passwords* (according to the corrupted database) and *the corporate policy when that password was set*. + +For example, suppose you have the following list: + +``` +1-3 a: abcde +1-3 b: cdefg +2-9 c: ccccccccc + +``` + +Each line gives the password policy and then the password. The password policy indicates the lowest and highest number of times a given letter must appear for the password to be valid. For example, `1-3 a` means that the password must contain `a` at least `1` time and at most `3` times. + +In the above example, `*2*` passwords are valid. The middle password, `cdefg`, is not; it contains no instances of `b`, but needs at least `1`. The first and third passwords are valid: they contain one `a` or nine `c`, both within the limits of their respective policies. + +*How many passwords are valid* according to their policies? + +Your puzzle answer was `517`. + +\--- Part Two --- +---------- + +While it appears you validated the passwords correctly, they don't seem to be what the Official Toboggan Corporate Authentication System is expecting. + +The shopkeeper suddenly realizes that he just accidentally explained the password policy rules from his old job at the sled rental place down the street! The Official Toboggan Corporate Policy actually works a little differently. + +Each policy actually describes two *positions in the password*, where `1` means the first character, `2` means the second character, and so on. (Be careful; Toboggan Corporate Policies have no concept of "index zero"!) *Exactly one of these positions* must contain the given letter. Other occurrences of the letter are irrelevant for the purposes of policy enforcement. + +Given the same example list from above: + +* `1-3 a: *a*b*c*de` is *valid*: position `1` contains `a` and position `3` does not. +* `1-3 b: *c*d*e*fg` is *invalid*: neither position `1` nor position `3` contains `b`. +* `2-9 c: c*c*cccccc*c*` is *invalid*: both position `2` and position `9` contain `c`. + +*How many passwords are valid* according to the new interpretation of the policies? + +Your puzzle answer was `284`. + +Both parts of this puzzle are complete! They provide two gold stars: \*\* + +At this point, you should [return to your Advent calendar](/2020) and try another puzzle. + +If you still want to see it, you can [get your puzzle input](2/input). \ No newline at end of file diff --git a/2020/day02_password_philosophy/src/lib.rs b/2020/day02_password_philosophy/src/lib.rs new file mode 100644 index 0000000..baa06ad --- /dev/null +++ b/2020/day02_password_philosophy/src/lib.rs @@ -0,0 +1,87 @@ +use core::fmt::Display; +use std::num::ParseIntError; + +#[derive(Debug, PartialEq, Eq)] +pub enum ParseError { + ParseIntError(std::num::ParseIntError), + LineMalformed(String), +} + +impl From for ParseError { + fn from(value: ParseIntError) -> Self { + Self::ParseIntError(value) + } +} + +impl Display for ParseError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::ParseIntError(e) => write!(f, "Unable to parse into integer: {e}"), + Self::LineMalformed(v) => write!(f, "Line is malformed: {v}"), + } + } +} + +struct Entry { + left: usize, + right: usize, + letter: char, + password: String, +} + +impl TryFrom<&str> for Entry { + type Error = ParseError; + + fn try_from(value: &str) -> Result { + let components: Vec<_> = value.split(&['-', ' ']).collect(); + if components.len() != 4 { + return Err(ParseError::LineMalformed(value.to_string())); + } + + Ok(Self { + left: components[0].parse()?, + right: components[1].parse()?, + letter: components[2].chars().next().unwrap(), + password: components[3].to_string(), + }) + } +} + +impl Entry { + fn is_valid_1(&self) -> bool { + (self.left..=self.right).contains(&self.password.chars().filter(|&c| c == self.letter).count()) + } + + fn is_valid_2(&self) -> bool { + (self.password.chars().nth(self.left-1) == Some(self.letter)) ^ (self.password.chars().nth(self.right-1) == Some(self.letter)) + } +} + +pub fn run(input: &str) -> Result<(usize, usize), ParseError> { + let entries: Vec<_> = input.lines().map(Entry::try_from).collect::, _>>()?; + let first = entries.iter().filter(|e| e.is_valid_1()).count(); + let second = entries.iter().filter(|e| e.is_valid_2()).count(); + Ok((first, second)) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::fs::read_to_string; + + fn read_file(name: &str) -> String { + read_to_string(name).expect(&format!("Unable to read file: {name}")[..]).trim().to_string() + } + + #[test] + fn test_sample() { + let sample_input = read_file("tests/sample_input"); + assert_eq!(run(&sample_input), Ok((2, 1))); + } + + #[test] + fn test_challenge() { + let challenge_input = read_file("tests/challenge_input"); + assert_eq!(run(&challenge_input), Ok((517, 0))); + } +} diff --git a/2020/day02_password_philosophy/tests/challenge_input b/2020/day02_password_philosophy/tests/challenge_input new file mode 100644 index 0000000..8903fa4 --- /dev/null +++ b/2020/day02_password_philosophy/tests/challenge_input @@ -0,0 +1,1000 @@ +13-16 k: kkkkkgmkbvkkrskhd +5-6 p: qpppvzp +3-4 p: psppxhlfpvkh +3-10 w: wwwwwwwwwwdwww +4-5 r: rcgrrcr +3-4 c: clvccc +1-5 x: xfsfxmctb +9-14 k: kpkmkkckhkkkkvkk +5-6 s: gsfsss +4-8 c: cccdcqdcr +2-5 k: kmkpkkfgkkkkdkkk +9-11 f: pfnsfffwxsn +8-9 w: wjwnwcwxc +7-8 q: rrxhplqs +5-10 n: gpnkqnxnbjzgjnb +18-19 p: fvpkgfkfjgwllqwhrjd +12-13 v: kvvvbmdvvvvvvcvvvv +3-5 m: mdmkmvhszpjcxl +2-7 v: qjmvzdwxc +1-4 b: bbbbbbbb +2-5 c: fzcdccfkcsjhckccrcx +2-10 d: fhdwdbdddrsldrtdjdr +1-7 z: ztszzfzztcqzrz +4-6 j: mmjjjrj +11-12 b: smbgkbbmbpbbmkbbbb +3-5 r: jxzrk +13-15 d: fppsvgqrdgrbddd +12-14 w: wwwwkcwwwpwzwzwwsz +5-6 v: lmcvvv +12-14 x: xxxxxxvxxmxbjnx +1-2 p: hpgpt +10-11 k: qmktzklkgkcknfwkh +6-7 r: ntcrrrjrznk +7-8 v: vshxvzxw +9-13 c: cncccccclcdwccwmc +5-6 r: srrrgv +6-9 w: bwfswqthk +5-7 f: hfvsfjf +11-14 v: zbksgqcrclvvwpfvfr +8-9 v: vvvvvmvvvkv +1-12 n: gnnnnnnndnqnd +10-11 j: jtjjjvbjjhj +3-10 x: vgxxxwqxkxn +5-6 z: zzzztr +2-4 z: rzdhz +10-11 m: mmmmmmmmmmvj +2-4 z: jzczpvzzs +1-4 k: rkkhk +4-8 n: nwcwmnflpbnnl +2-4 w: dwwgwwssf +1-3 m: smzm +2-6 d: dsddwwljd +13-15 w: wwwwrwwwdvwwpwg +7-10 f: bhsfffzfjdbfmf +6-7 w: wwwwtwww +3-6 b: bbbbbbxb +7-9 d: dvwdxjgdhf +12-14 n: znnnnnnnnlnfnrn +1-7 v: qvkvvvgv +2-15 x: xsxxxxxxxxxxxxbx +5-11 n: nckpwnmmnzg +4-13 d: dzdddcdkxgqddqdp +5-17 m: mkxmzbmmmmvfvmmjvmmm +11-13 p: pppzppppswhqhpppp +4-5 b: bbbgg +5-8 v: vvvvvvsv +9-10 j: jnlkmhmvjvnbjcsvlwb +2-4 x: zxxxxv +1-17 r: drrrrrrrrrrrrrrrcr +11-17 w: wqmwlszsnnwwwzwwwww +2-3 m: mmmmmmmmm +9-10 n: nrnngngnvr +4-8 z: bxjtzkdzwkzz +5-8 g: vjtvqtgqjgtggggmj +2-5 q: qfgcqw +6-11 c: cgccccchcccvc +6-8 t: tpjgfjpr +5-10 h: hhhnhbhhczhh +11-14 d: gdddddddddwdddr +1-2 l: twngrmgrckmlmh +10-12 r: rrrrrrfprfrr +7-8 m: bmmmmsrhqm +2-11 w: wlwwwwdnqsvw +10-13 j: jjjjjjtjzjjjj +4-16 f: fdvgffxfzcffffff +2-6 q: wbfvkm +4-6 d: ddddddd +2-4 p: jpxprdpn +5-6 s: tgssrrpbvsgs +3-10 j: spjgjjjcbjsjxj +5-10 w: wwqrdvwwwpwwwr +3-4 x: hpxxxzf +4-8 d: dxcpddddddrddddddqj +15-16 z: zhfxlzzkzzgzhzzz +3-5 s: ssslsnc +2-3 j: rrjrwg +7-13 x: xxxxxxpxxxxxtxx +5-8 x: xxxxxxxrxxxxxxxgx +4-10 g: dmhcmbwnwwggcw +6-8 s: qtsxflsfshzvsgpxg +7-9 c: cbvccckcwc +15-16 r: rlrrrrrrnrrrrrsx +8-10 r: kjrbrrrbrnvrrx +6-7 q: zpsmcjmmr +5-10 p: ppgpsppppkpp +3-4 k: kbkkk +1-2 b: bbbbb +8-11 s: sssvssssbsw +5-7 m: lmwrmmmmgmfhd +16-18 j: jjjjjjjjjjjjjljsjt +1-14 b: bcjlbbcwbjbxbbvbf +2-5 z: qzzrfv +4-17 t: tttrtzttttttttttxttt +5-6 w: kwwwjw +7-9 l: bclgtbghdtd +1-8 h: mqhbhhhhhhh +5-6 j: zznjjfvvjwcths +5-7 t: tttbmttd +5-14 v: vvvvpjvvvvvvhm +2-4 x: vxlx +5-15 g: gfgfnnqkbgngpdpp +1-8 n: jnnnnpnvntrp +3-4 b: bbbb +6-7 z: frszzzfz +6-9 f: pbbmlvfpwvw +4-15 g: gbjgggfgvggggdgbq +1-9 w: tgwljtgwlm +14-15 k: kkkkkkkkkkkkkzk +11-12 p: ppppppppppklp +4-8 n: nnnvpkzsn +13-16 m: fmjsqwtmwbdxmnwmlmb +2-7 c: qccgccczcc +8-11 x: xxxxkxxbxxx +1-4 g: gcgb +6-7 l: pkjllll +2-3 n: mnntpwsrlqkxkgnlb +9-10 s: sssssssscss +6-16 n: rtthnbsrfvndnsnnj +1-2 h: hjdhh +1-3 f: ffff +6-9 l: xqtvlllllpmlxtl +6-11 r: rrrrrrrrrrr +1-6 z: fzzzzzzzzzz +2-7 q: qqdqqqgqqqqtxqqqq +9-13 k: dbfkszjjmkkkfkdkklxk +5-6 j: mdjjljdfzjvqd +5-10 s: tsbskgsbtsqdd +12-14 j: tjjsjdjfjtjjfjj +9-10 x: xxxxxxxxgx +8-11 r: rrgrrrrbrrcrrr +6-18 m: vmnmhmbmmmmmmmmmmz +6-8 k: llkkqrkc +1-2 c: cccc +2-8 x: xxxxxxxxxx +7-10 p: ppzppppppwp +9-17 v: cdjwncwrbcgkfvwzvkf +6-11 w: wwftwjwwwcwwvwwvw +12-16 g: gggggggggxggggggggh +1-4 z: kzxzcdnpgczhn +3-5 t: tttmtttvxtd +4-5 h: hhhwh +4-8 d: dvddddln +8-15 l: lvllfllllxllllwmpl +7-9 s: dbsksbwtj +8-15 q: qkbqmqqqqqqqccqhq +2-6 r: grcsrrqz +14-18 s: sssssssssssssssssss +7-10 r: ffrrttnrrrrs +2-11 c: csccccccfdgccgcccccc +3-5 r: rrrrr +3-4 h: qrhh +7-9 k: kkzqkrkwk +1-5 k: khkkfgkj +3-6 l: pplnxl +10-13 k: chsxfrtrkkjgq +6-9 b: lbbblnbrbbb +3-5 n: hqnlfpnj +5-8 f: shffkcnfdmswfrnsfrpg +2-7 j: jjjjcdcnwxnbr +4-13 z: dvxnzpcbfkngk +11-13 h: hwzpzbphjhrhk +1-10 v: vqptqpbbtq +1-4 b: bdfpt +13-18 p: pppppppppppppppppp +14-15 h: hhhfhhhhhhhhhnmhh +4-14 x: wxsbxxxjvxxbxx +9-10 m: mmdmmxsrjdmpdmzsmm +11-16 s: szsbssssssszsxss +9-13 h: hhhhbhvhthhvnh +5-6 q: qqqqqq +1-3 d: ddldcqrdmd +11-17 f: ffcfkfffffpwfqffm +3-6 m: rmmmqm +9-11 l: vlblgszllwbvpn +13-15 z: ghzvdlzrvrzzcnz +3-5 l: bglllcll +1-8 h: hhhhhhhhhh +2-7 j: qjsgtjjt +1-2 d: ddbctlvpdf +11-14 v: vvvbvvvvvvtvvvvv +14-15 g: ggzgggggggswgrjggm +9-13 v: hqtcqvnbvqnmv +12-13 b: bbbbbbbbbbbjzbbbbb +5-6 r: rrfrcv +4-6 p: pppppppppppp +6-12 d: fdddddddddddrd +12-17 g: ggghgggggggxggggfgp +2-7 h: hqhhhhjhh +8-12 v: vvvlvvvvvvvv +4-5 n: nnkpg +3-12 m: mmzmmmmmmmmmmmm +11-14 b: bbbbbpbbbbbbdbbbb +6-7 z: zzzzzzr +4-7 n: snnnnfnkn +1-2 h: hnshhqvmjpghntx +15-16 b: bbbbbbbbbbbrbbbb +4-6 n: nxnnpnnnh +2-9 v: sdghvmxtkz +5-7 j: jjjjjjj +4-10 l: plbhsmlllrl +12-18 g: ggtggdlghcjwqwggggg +5-7 b: bzbxrbxgwcdbb +5-15 m: mmmmmmmmmmmmmmmmm +4-13 j: jjjjjjjjjjjjjjj +4-11 k: kshkkwlkkkkkdkbk +1-15 w: bwwwzbwwwnwwwmcww +19-20 l: pblvxmgslllnnsplldnv +3-4 z: skzx +1-5 x: xxqdxgb +2-3 g: wgggc +5-9 d: dgcddwrdf +3-6 m: mfkzjg +5-8 s: hmssmgwxhssg +10-11 s: ssssshqssll +17-19 v: vvsvfvvvvxvvvgvvvbv +11-12 t: cwssdtfqkdttjv +1-5 b: hcptprhlpbwkg +2-8 j: ljjxjjjljp +2-5 q: qqqlqr +2-8 r: jrcwdbhrcltrnsgswpm +3-4 f: ffvff +5-10 h: hhhhhhhhhhzph +5-6 z: mzzmctzz +10-13 w: wwwwwjwqwwwwwwwwww +1-4 m: mmtm +11-12 z: tddzcrptcnlmbjj +3-6 l: llmllpl +2-4 f: ffsf +5-11 g: gggrvgggggg +2-10 k: zbmpktfnddfs +5-9 l: lsbblgpjlms +1-12 s: sssssssssssss +5-7 f: fffdrsc +9-11 z: rzzzzkfzzwqzrz +3-6 z: zwzrbzv +17-18 r: rrrrrrrrrrrrrrrrrg +2-4 n: nnnrgnnn +3-4 n: nfqq +2-3 h: khhc +9-10 x: xxxffbxxxnr +5-6 d: mtgnrjdnmzhddks +3-4 b: bbbb +11-15 p: kppxppppppppppppp +13-18 t: tttdtttttttttttttttt +1-7 p: frjpppwgdpzvvfwds +1-6 k: qkzkkvpk +4-15 n: nnnxnnnnnnnnnnpqn +6-7 l: ndlrqrl +4-5 r: rchrwr +11-12 f: ffffffffhfff +1-3 j: xjjjj +9-10 z: zzzzlzzzgn +6-17 g: tgrhpggcqbjwjggmgql +11-15 v: vvvvvvvvvvlvvvhv +10-13 w: wwwwwwwtwwwwswwfwww +1-2 l: plllllllllllpll +8-9 k: kkckklwkc +2-4 b: bvbp +1-6 r: rrrnqrrrrrrrrrrrrr +8-10 d: pwnvkxddpddd +3-6 k: kkkwkf +8-15 v: vvvvvvvvvvvvvvvvvvv +13-17 g: lhqgggcxlgcvgwgdg +6-13 x: kxxxxsxxxmxxxx +3-4 r: rrrqr +2-3 r: kvrsxjrmtvtr +1-2 h: jtbh +8-9 w: wwwwwdfckw +13-18 v: vvqwvvvnvvvvvvvsvv +6-14 t: mpfthffdnmtxmx +4-5 d: dddcsd +6-7 m: mlmmmnfmmh +5-7 x: xhxpkpqxqnx +9-11 v: vgvvqgvvwmkpfvvlv +15-18 l: jlxqvmjgrrnbhccpdl +2-9 k: kkkkznkkbf +14-15 w: wwwwwwwwwwwwwbwww +9-10 k: wkkvvmkkvgfkkk +10-15 g: bfggggggggggggg +7-8 x: xxxxxxxx +12-14 t: dmtmwtztltfsthtb +6-7 k: kkkkkwk +4-5 c: ccvsz +3-4 c: mclvcfjcqh +16-17 k: skkpknhxxsrqmcvkj +12-13 v: vvvvrfdfsdtvf +1-2 q: fpqp +7-8 b: bwbbbqbbb +5-6 h: hhhhhh +5-7 z: zzvzdzzxzwz +17-18 w: wwwwjhggnwbwwwwwzb +6-8 g: gggggtggg +4-8 n: lnnnzhbn +17-18 g: lggggggggcggglgggg +2-8 v: vbvvvvvkv +1-9 v: vvxvrvvtvvvvv +13-15 j: fhvxdngcrjdqxmnz +5-17 n: nnnnnnnznnnnnnwnnn +1-4 f: fnxdmjdsqbfffnjsnkf +3-8 q: dqqgbnbrpxqclq +4-6 b: xkpbbbk +11-12 l: llqllllllldjll +9-10 c: cwvlcdnmzr +6-8 l: zkjlllvlgvlnlblspm +4-9 b: lbbbbbbbbbwbbbw +9-12 g: gfgrggvgbggg +16-17 r: rrrrrrrrrrprrrrtc +2-16 r: mrbmrrxgrrbzrrmrrj +16-17 v: vnsvvczmjwfkvjvvvsrv +2-11 l: lglrllnlllqlll +2-8 t: sllgjrxkthl +3-7 d: ddldddk +8-13 c: ccckchmcdxccccccsf +8-9 t: cttbtztttfqdqh +4-5 b: tbbxh +12-17 w: wwwwwwwwlwwtwwwvtww +1-5 t: krfwxtzxcwphw +3-10 w: wwwwwwwwwwwww +1-2 n: nnjqqkspswql +9-13 w: wwwwwwwwfwwwwww +1-3 s: ssss +13-14 x: xfxxxxxtxxxxnx +4-5 x: xxxcj +5-15 k: kkkktkkkkkkkkkf +14-16 l: lrlzjxlllpqltlblvlll +5-6 t: ttttfct +11-14 z: zzzzzzrczdkzzz +6-8 f: ffffftfj +9-11 d: ljdngglsdvdsv +10-15 c: ccrqhcqzccnnjvcfcj +11-15 w: jwvwnccwwxzcwwww +9-10 s: ssssssssss +2-4 r: vzfmrr +5-8 l: blhlnlsqb +6-7 c: ccxxcfxldckpcc +2-4 j: czjkj +2-14 d: rlxksvpqsnhhpkds +16-19 k: kkkkkkkkkkkckvkjkkwp +3-9 j: kcjcbjjjjjjjjgljml +2-7 l: ljjzdll +4-8 r: fqnqjbsssqrrwrrrrr +5-15 t: xtnvhtttdsrhtttt +1-3 l: xlzl +6-10 g: ggggncchghgggghgg +10-11 m: msmmmmmcmgj +4-6 c: mcnprhmcfcclcl +12-13 s: ssssswssssstsss +13-14 m: mmmmmmmmmmmmmmmmm +9-11 p: kqvrdbpppcpgqh +6-7 q: qqqqqqq +9-10 b: bpbbnbbbkdbbsbblqrfb +12-13 b: bbbbbbbbbbstsb +8-11 g: ggbbfrsgdxhldnt +7-8 d: dddwddssdbd +6-7 b: bbbbkbfj +3-5 z: jtdklzthgz +5-6 l: hlnlllltmvhmlmq +3-6 q: qqpxqvqp +1-3 z: zskzmzzzhzzzhzvzrzzq +2-8 h: sskhzhlhkht +2-9 r: rltcgrrrrrrr +3-16 f: zrxffkfcvffffncffgff +1-2 r: rrcrhkns +14-17 b: bbbbbbbbbbbhjbgbdblb +4-15 c: cccccccwcckclccrcc +13-14 l: lkzlclbnlhlcnk +13-14 r: rrrrrrrrrrbrrr +4-5 k: cvhkkkbj +2-5 m: kmfnmzh +14-15 n: nnnnfnnnxnnnnnnndnnn +7-10 t: wttwkbhtpf +3-9 n: qjgzpnkpn +6-7 n: nhnnnzn +5-10 n: nngtndngcn +2-5 x: rdxnp +10-13 s: sssssssssxssssssss +6-8 n: mnjnnxnnvckn +2-10 p: gpxpglqwpppp +5-7 t: twtktdts +18-20 c: cccccccccccccccccccc +6-7 d: dddddddw +10-11 x: xxxjxxxxxvzxxxx +4-7 z: zrphzzlzhgfwd +4-8 l: lllnlllkl +2-7 q: kkwsgndmdrmsvfqj +4-7 m: mmnmjfmm +2-5 s: flhkzzs +12-15 x: xxxxxlxxxxxmxxs +9-11 v: vvvvvhvkbndjvx +1-9 n: kpqgbxnkx +5-10 f: ffdfrpfffffwfffff +1-3 f: jsvqkff +5-7 j: jsjjjfxl +8-14 z: zzznrzzzzzqzzz +1-12 d: dzlbdzhgmrdddc +12-13 k: kkkkkkkkkkkbk +7-8 m: pmmmmmmmm +1-6 s: bsssssvslx +6-8 d: dddgdgrtbfdm +11-14 k: gkplwxkmskwmdpm +6-10 x: xxxxxkxxlr +4-10 l: lllxlllllklllll +1-2 t: ttstmpksrrp +10-12 s: ssssdsssshscs +10-12 z: zzzzzzzzpwjszzzz +2-4 r: grrrctkzmw +1-2 l: fspl +3-5 k: kkkkk +5-12 b: bcbbbbjbbbbb +8-9 c: ccccccctcc +3-8 p: pmplmhpp +6-7 b: bjhfsbbx +16-19 d: dddddddddwdvddddkdg +5-6 j: sjrzcj +5-8 f: mfdffdgf +1-3 q: qcqqq +9-10 s: sbsssssspm +2-4 f: dffl +3-4 n: nnnn +4-10 t: wttthjpdmtlthttgwtkt +9-10 d: jpxdmbnddddd +10-19 q: sqhswtjrpqbxwjqzfqmr +2-6 w: swwzvgwbww +1-2 m: cfmmsl +9-14 w: pwdbjwwhbnpwllm +4-5 q: qqqqqqqqk +8-15 m: mmkdmwzkrvlmpmnmmmmf +17-18 q: qqqqqqqqqqqqgqqqnvq +3-6 g: gkkngh +1-8 g: gghdzwkg +3-11 j: vxdspqtvkpj +5-7 q: qqtqgpmqdq +6-8 d: bdmddddvd +5-6 w: zwwwwwvwxfw +2-11 n: bnplrmpvbpn +7-14 k: kkktbkkkkkkkkk +3-11 b: fmkqvvbztnxzqvjc +3-6 q: sscqqq +4-7 c: cfrrdrzbjmvpk +6-9 w: pwrtzwrww +2-5 v: vvcvv +2-4 f: ffmf +8-10 k: kkkkkkkpkd +6-7 v: mvjvvvv +8-11 c: vccvcckccfk +7-8 b: bbbbbbbsr +2-3 x: xxxmvx +6-7 l: llbllwsl +8-10 r: rrrrrbrrgrrrrnrb +12-16 g: ggggggzsggmwgggv +18-19 p: pprppppppppppppppppp +3-6 s: ssssssss +2-6 x: lwxkdx +2-3 n: xgbnf +2-4 p: dzrk +2-4 h: hlhpjhh +4-5 b: bmnbb +1-7 z: zczvzczsxmxpzznp +2-9 l: nlwxdwlblzl +1-4 r: xbtcqrfkv +13-16 k: skkkkkkvkkjkxrkfqk +9-14 b: bbbfcbwfjbbcbg +1-13 r: frrrrrrrrrrrfr +1-4 w: hwwxwnvvt +2-6 l: zzhlrx +3-8 v: vmzvggqtslnlqrj +15-16 s: dhssknsjztzssssssss +2-6 q: qqqqqqqq +2-3 t: mkktlt +7-17 b: bbbbbbbbbbbbbbbbdb +11-17 s: sssssszfssxssssskj +2-7 h: hnhkhshhhhhhhh +2-15 x: xzxjxnxxpxxkzxxxxj +15-16 p: pmcmpclzphppxplp +8-9 k: kkkkkkkdpkks +2-4 r: vrwt +8-12 r: qrrrhhwjrrrhrrr +3-4 j: vjjzq +8-10 q: qqqqqqqqgs +6-7 j: zjjjjjjj +1-11 m: mdgkdkmqzmmsrhxxmmj +1-7 x: pxxxrbq +3-4 z: zrhkzz +4-5 s: ssqlss +5-8 f: vtrfffffff +7-13 j: jjjjjjdjjjjjtj +1-7 n: dnnfxwz +2-11 n: nzgnqncnnnjg +4-5 x: xxxxx +5-7 v: rhbvvvvhvxvpz +10-11 z: zlbbddzlzwzv +10-13 v: vvvvvvvvvvvvvv +3-4 s: ssrs +11-12 m: mmmcmmfdmmsmmmmnm +5-7 s: sdstsssssrs +1-3 w: bwzw +3-4 h: hphq +7-16 q: qqqfqqdwksqlfcqjxq +6-7 x: kndcxfv +10-11 m: mmmmmmmmmmm +1-4 n: fvsvnfhgwcgcnp +13-14 s: ssssssssrssswrss +5-9 x: xmvkxwgrxrtwxmrxhxx +3-5 q: jdbvvxvdg +3-15 w: zlzcksssjbwcvgp +16-19 x: bxxxxxxxxxxxxxxxxxx +3-5 z: rzzhz +4-10 f: hpttvbtjmq +3-6 n: wsngjn +4-5 p: ppphg +10-12 c: bqlccfctmchqbchhcg +9-10 z: zzzzdzzzzhzzvz +7-9 w: nwgwcvdcxqqwmzq +14-19 x: pxtxxlbrxdpvspwmxxx +2-8 t: ssktwbft +8-9 j: jjjjjgjsjzjj +7-9 v: vvvvvvdvlvvwv +4-6 x: qxxkssx +11-13 g: ggggggggkgvgg +8-9 t: tttttvttjttwt +2-8 b: pfbbcsbwbbbb +8-16 r: mkrcrtsrrrrbxmprftvx +9-10 k: hvwlqvktkkb +1-6 w: wsbwwvjwwrwh +10-19 f: nfftfffrdhjffjsnffd +13-16 h: hhzghvhhhfhhhhhhhhh +14-16 x: kskxbwrwrvjxfvfg +1-4 k: rflk +6-7 b: bbbbbbgb +4-17 v: vvvvvvvvvvvvvvvvv +12-13 s: sdstmsspfwsssscqf +9-11 z: zzwzvmrzzczzzz +4-8 s: skslmgsqtszbswsssscs +4-12 h: bdshxnpgvwhktdwgdp +3-5 t: tltst +4-5 h: hhhhh +9-11 w: wwwwwnwxxwwwwwww +6-7 n: dcnngffnnzn +1-3 l: clflll +6-7 x: xxxzxxgx +6-7 n: nnnnnkgnnnnnn +1-6 m: mmmmmmmm +5-7 t: tktttpt +4-8 v: zpcvqvzvrvgttntrbl +6-7 d: dddrddd +3-5 k: jskdkswqjfftgkfr +5-6 f: ffffgrffn +6-8 l: lwlkllgl +10-13 p: ppppkpppppppd +4-5 d: hbjdd +9-15 r: rrxrrrrrrrrrrrrrgr +4-5 b: bbbbtbx +8-11 b: brbbtlvvlbdbbbqjsb +6-8 g: zgzqgwmg +4-9 r: qstrmxrtr +5-8 m: mbmjmmmmmr +5-7 v: tvvzqvgrvqvmvncshv +17-18 g: fgggggggggggggggwr +2-12 t: nttpgcjtkdjt +6-10 k: kkkkklkkkk +2-7 q: qqqmtgqq +3-6 n: npccknvnn +5-16 k: rtlhkbtdkmmntdbl +2-3 b: wwkb +7-17 q: qqqqqqqqqqqqqqqqqq +1-4 g: ltgc +2-6 l: lxlnln +13-15 q: qqqqqqqqqqqqqqxq +3-4 j: jvjj +5-15 c: cpmzlhcckwlnhwmwgzw +3-8 b: qvblmmchbcc +5-8 b: fqhdwtcxb +4-15 k: kkvkkkcwgkkbkkdkkkkn +11-12 f: fnffffffffffffff +9-10 t: tttttttpfvt +4-10 f: nfffpftfffffffnf +2-4 m: scgxnm +7-8 z: zzzzzzxhbz +6-9 z: vznwkzzzz +3-5 k: hkcdn +3-10 k: kkskkkkkkz +2-3 p: pbdf +1-4 m: mdhmm +6-10 b: lfbbwdbbtv +8-10 g: gggggggggggg +2-3 t: qgthtztbwtppb +15-17 n: nnnnnnnnnnnnnnbnjn +8-17 v: vvvvvvgkvfvvzvvvpv +4-5 f: vwffff +8-15 w: wwbvwwwwdwwkzwwwwwwf +7-13 n: srmzrmnvcgshljkchp +5-15 q: dqjvfqvpwqnmpwqzh +1-2 h: hhfs +2-6 h: jhqwhh +3-4 t: tthg +2-4 b: sxsqrrxkjb +6-8 q: qqqqqqqqqq +6-7 c: rqcxcclxccwqcgwq +4-5 v: vvmfv +6-7 m: mmmcmmmm +2-4 j: bqfj +2-12 k: kkkkvkkkkskkkkkk +5-9 q: xjtqqrnnkdplrnqq +1-6 k: bqkrfpkcrwwkk +1-4 r: mrblr +12-18 s: ssssbfdlqbbssplswpsl +8-9 b: bhbhhbbkbzbnbcbh +3-7 t: tsdtthx +12-15 f: xcmghffxtgfffjf +12-16 n: bxnnhnhnnzfnnnwrtgl +7-9 q: qqqcqmnqdq +2-3 m: rpbjgkxqtmjrzm +11-12 s: hssssssssshc +3-5 x: xxldx +3-4 k: kkkxt +7-9 k: wlgkqndkz +5-7 l: llmtllv +2-6 v: svzvfv +5-6 d: djdddvddd +5-6 k: mhkkkkkwvkkcfk +3-4 c: rjcc +4-8 t: ttttzfttc +10-11 g: ggzggngbzgg +14-16 w: qzqwdwbcwwwmllndzlsm +2-4 z: zzpz +12-13 g: gwxpwcbsvwgtthn +1-4 b: bbbbmzc +5-7 f: cnxlfdffmt +3-4 z: znsdz +10-13 c: mrckljhmrcmnc +2-9 m: dxmdhndrwpmpgc +7-16 z: zzzzzzzzzzzzzzzzz +1-3 j: jjjjjjjjjjjjjjjj +15-18 g: mmglvtgzggzgnggggg +4-10 c: cccncccccz +1-8 n: mnnnnnntn +10-13 l: llllllltzhlvvld +2-3 r: gnnd +3-7 v: vcnfzzbd +6-7 p: pprpctdp +5-8 g: gggggqgggg +1-13 f: wfffdfpbfjlfhb +3-8 j: dmjjkqwj +4-10 j: vfjhnswwwtzlfvmcdn +2-4 v: bnjd +4-7 w: btwwlfwkwzmzhhlsvs +14-15 g: gggggggggggggpgg +10-11 w: zwwwwwwpwgrww +2-3 b: dbbcgwqfzlhwcbs +1-9 f: qfpfvffffffmfxbcpf +9-10 t: tttbpttttmttcnt +2-3 l: lgll +8-9 s: vzgvjsnns +6-8 w: wwwdwsbtswrww +13-14 h: dhhhxhdjnvhrhrflhh +7-8 d: dddddvjd +14-15 l: lllqlllllllllnlxlh +12-13 d: ddddzdjdddhhkdd +9-14 p: pvtplhjvpzdvqjqvh +9-10 r: rjrrrrrtrrrr +6-8 g: gjjgfwgg +9-14 j: jjjjjjtjcjjjjhjjj +8-9 q: phxjqqnqq +5-6 k: lkkkkk +14-15 x: xxxxxgwxxxxxxtwxq +1-4 x: xqfxx +1-8 m: mmgmnmvm +2-3 n: hnwr +14-15 z: zzzzzzzzzzzzssz +2-6 p: pspppp +1-6 z: zzxzzx +9-18 z: zzzzzzgzzzzzzzzzzgz +6-11 z: wzhtdzzfxjz +3-4 v: vzvv +16-19 q: qqqqqqqlqqqqqxqqqqq +2-4 v: vvhvvvv +2-9 p: lpxppwppppgppspb +11-12 m: mmmmmmmmmmndm +8-9 v: vvvpjvvvpvv +16-19 k: kkkkkkkkkkkkkkfkkkk +9-10 z: zxlzfzczzzczrdn +12-18 p: ppppppppppbjpplpphp +1-3 p: pvpppx +1-2 x: vxlx +10-12 l: lllnlllllwlll +4-5 b: bphwg +7-10 c: gcjjpprxxjcwvk +6-9 l: llwqklmpxlszgzlvl +9-15 s: fsxsscswksvrmsh +15-16 q: lqxqqwqpqwptqqmg +10-13 r: xmpmqrdjkrzkpzc +3-5 c: kcbcclt +17-18 f: jffffsffffffffffbsff +1-3 t: vqcqdmmgc +1-2 n: qnnn +16-18 n: nnjzhnznnnxlrmmnsn +13-19 q: srxlcdznhbfxqtsqtsqx +2-7 m: vmmmnjmmmmz +6-7 v: vlvmjvg +7-15 k: xnpkbtzwgntptwkgmxm +15-19 g: wggggggggggsggkggxg +8-17 h: hhhhhhhwhhhhhhhhhh +2-5 w: kwwwww +4-12 k: kkkqkkkkkkkqkkkkkkk +7-11 d: hddcndsgddgz +2-7 t: tdzxnth +1-7 z: lzzcrvz +5-10 h: shvchmxxdh +12-13 f: kffwgtfsssfqnvff +1-9 b: mbbbbtxbrbbc +4-12 r: rnfvrprrrrzrrr +2-6 p: qzltppwqljg +2-4 w: hwdxwmmqphfkhthczx +3-4 r: rrwj +3-4 b: lbbbpldfj +4-12 g: gggggggggggggkv +4-5 r: rrqjtrrr +4-8 n: nnnrfhnfn +4-11 h: lrnxkwkbhgnhh +1-8 l: lvjlhbffl +6-10 g: ggtgghghghpfgg +1-2 s: szsss +3-6 s: dszxsdsssskssbs +11-14 x: xxxncxxxxxxxxq +5-10 m: mtmmmmmmmdmm +1-3 r: qrgr +2-7 m: gmhmmtd +1-3 c: cccswmjcmnm +2-9 x: qbcdsxxlx +6-7 s: nsswzssv +1-14 m: trmlzmsmgqmmmnfdsmtm +5-7 d: cdddzdtdd +3-4 k: tvczkxvvrw +2-8 s: slvmswvs +10-16 p: pppppppppgpptpptpp +2-11 l: jqxsjlvpzkgzjdmt +4-7 t: ttmtpttp +4-11 r: twbrxccwcrtffpnv +6-8 k: kkckkkkqkk +10-12 v: vvvvvvvvvvvv +4-6 k: gqzkkk +3-4 r: rrmxr +12-13 p: npgppsppppqnw +1-16 x: mxxxxxxxxxxxxxxv +5-6 l: llllll +1-4 k: bkkckkkkk +10-11 v: vkvtvkjltmlvtxlnlrsj +3-11 h: mzhrhlhhhhhwl +5-6 p: pppppp +1-17 m: mmmmmmmmmmmmmzmjmmmm +2-6 v: cvvcvfbgcvvvcq +4-7 n: nnsnnwj +2-3 k: xvkxkksvb +16-17 x: xxtxxxxxxxxxxxxxr +1-13 w: lwwwwwwwwwwwxw +3-14 d: ddjdddbddddddtdddd +4-10 g: jrxggnqmjg +1-3 b: bbfbbbbb +4-5 d: pdhdm +5-7 d: mvdsdnd +17-19 m: mlmmmmmmmmhmmmmmmmm +4-6 g: gtlgxggggsgc +6-7 m: mzvmhglmmmpmmxf +10-14 j: jrjjjxcjjtjjjhpljl +9-15 w: wwwwlwwwwwwwwwjwwdw +1-3 g: wtzgjgr +5-7 m: dmmmtmm +1-8 g: ggkdgpggg +5-6 x: xnjhmx +1-7 b: bbbbbbbfbbbb +3-11 n: mnnnngnnnvnnqnnvn +2-3 l: jglgdrczl +12-14 f: tffpffsmfffffg +10-13 d: mndmdwdxjdxpd +9-10 m: mlmmmmmmzvxm +6-8 l: ptpjwltl +7-8 r: rrdrprlqrr +8-9 n: nnnnnnnrc +6-7 p: ppppphn +4-8 t: smtptgwtmlttw +4-10 j: jsjjjjjjjj +15-18 k: kkhwkkkkkkkkkkkkkk +1-2 s: sksxb +2-10 g: sggchblktg +8-12 r: rrrrrrrrbwrr +13-14 v: vvvvvvvvzvcvvvvv +3-4 p: kppp +4-14 m: mmmsmmmmmmmmmzm +5-6 n: kndmnnnnpnznjqb +3-10 d: xlddcdbdlddpqdkdl +17-18 n: tnmcvdcznnnfnznldt +6-11 g: wgbgzgggggg +16-18 z: zzzzzttzzzzzzzzkzq +11-13 x: pxxlgmtvbjrlb +2-13 p: bmphpwxpsmmthppprdk +14-16 r: rmrrrrrdmrrrrztrjr +1-5 x: xdxxx +1-3 d: dgdddfzddfd +1-9 m: ddfmgwfgf +7-11 x: xwnqqtxdmns +5-6 v: ffvvvv +3-15 g: dggggggzggggggb +10-13 p: pptpppkdpwcngppf +11-12 x: xxngxbxxdxxxxnzxbxx +3-4 n: nxqc +1-2 x: dvxxx +4-5 h: zhvhh +3-5 j: jqpjj +2-7 f: ffffffpfz +8-10 k: kkkkkkkkkk +5-12 x: xxtxxxxxxxxxxx +12-14 c: cccccccccccccc +8-9 s: vhlssssws +1-4 k: dqkk +4-10 r: rrbrrrrrrdrr +1-3 r: hqljfr +8-12 c: qcccccszgjgcccddccw +6-14 m: mmmmmxmmpmmqmcmmdm +5-6 r: mwrrdtm +1-5 t: rdjtts +6-14 c: gpcbczvfbcbcckblzc +5-6 w: wxwwww +3-4 p: rjppp +10-13 t: ttttttctdtgtttts +3-14 c: cvlcpqscwgzgxzxvkmh +3-7 h: kxqfwfddhllhj +10-18 r: mdqrrmrdxkkvxftrrr +13-14 m: cmmmcgmmmmhvmm +2-7 h: khvhhjhhjbv +5-9 r: rrrzgrrrlr +1-8 c: gccccccsccc +15-17 v: vvvvvvvvvvvvvvdvn +9-13 v: vbvdgpvjvhvhwxv +6-9 z: zzxbqznzqjzh +3-6 r: rrrrrrrrrrrrrrrrrrrr +3-4 x: nxxxxst +7-10 q: qqqqqqfqqf +9-10 j: jjbjdjqcqw +9-13 z: dhzzzzzzzzzwxkzzzzjk +3-9 q: pqxgqqcqqjql +10-11 h: ljhgjwhzdrhhhh +18-19 v: vvvvvvvvvvvvvvvvvvvv +10-11 l: vgxrhvtfblwl +2-3 v: rvvvvpj +8-9 c: smchcscccdmf +2-3 n: nqmnn +15-17 x: xxxxxxxxxxxxxxqxrxk +11-14 j: jjjjjjjjjjljjvj +7-9 z: zvzzmzjkfbvzzczczlzm +2-6 z: zzzjzjzzmfzk +9-11 m: mvcmmbmlzrmmz +6-7 r: rrrrrrr +3-6 c: jtcfscccvvf +2-5 s: cssbntxggkwvwnchn +8-10 x: xxsxjzxqxx +6-7 n: ndnnnbg +9-16 j: jgzxxsmljbhbttqjw +3-4 k: gjsk +9-10 q: qqcrqqqpqq +2-4 t: thtt +3-4 w: wrfxww +9-14 v: vvsvvkqgzvmvvvvvlvvv +9-15 m: mmmmkmxdmdmmhmmwjw +3-9 b: bbbbwcwbb +3-6 c: ctdccs +7-8 k: kkqrkkkk +5-7 l: llmllcqjljlh +5-7 w: wnzbwgw +15-17 f: fcffffffffffffffpf +1-2 t: tttft +1-7 n: zctqhnxvbn +3-8 z: hdpqzzzlzsw +3-15 l: llslllllllllllml +8-19 w: rwtbwrwjwtwxcclthdw +4-5 g: zggggg +5-14 v: vvvvhvvvvvvvmlvv +1-7 l: mlgxllpgl +2-12 b: mvwbfjcddqjb +1-3 m: qmzm +2-3 r: rrrrrffr +1-7 x: xxsgxxv +8-10 d: tdrrqdzcdddddxddl +2-4 n: crnnfdcnnnzn +3-4 n: nnnz +9-10 z: zzzzqfzzzzz +10-16 n: nnnhmnnznsnntnnc +9-16 s: vssssbsscssssssjss +9-13 w: wwkwwwqqwvwwww +4-5 d: hkdhwddtdkqwvl +3-4 l: llll +4-5 f: ffzffftld +7-9 d: ddddddddgd +6-7 t: ttthptttqxlfddstsq +5-16 c: clhwccvlnmttjqcc +4-5 k: pkkkk +7-11 m: xwmmmmchmmt +16-17 n: nnnnnnnnnnhnnnnrm +5-8 b: bbbbbbbbb +1-4 s: jsss +3-4 h: rhhhtjwfvdhz +9-10 r: rrrprlrwrrw +1-6 n: nnnnnkn +18-19 p: ppppppppppppppppppp +4-5 l: ljlrcl +3-7 m: mmmmmjmdmtm +12-13 b: bbbbbbbbbbbvf +6-11 g: hcghdwfpcqk +4-6 q: krpfvw +10-13 j: jsjkvjjjjjzjjfj +5-6 n: lcnnnnzndqkfnsq +2-4 j: nvdj +2-5 p: hppnpmpq +2-4 w: wnwbw +2-7 f: fwfxfmfszmcxf +6-8 d: dqrdbsnjds +1-3 f: ffffffmff +5-8 s: lnbwqnkxws +10-12 n: nnnnnnjnnnnnjcn +9-12 c: pccvnbccxrncrcclccc +14-18 s: ssssssssslsssstsssss +3-6 l: lldllczl +6-11 g: gggggwgggghg +11-12 h: chhhmjhzhqfh +5-6 n: qhnvcw +6-7 k: nckkkkmnkkkzkkk +6-8 d: wddgbdpdzdqxrwddjlz +1-3 h: qghp +3-5 j: mnjjjxjkgnrdzjbtdr +1-9 g: gfgcgggxgjggggggf +8-20 b: vptprmjbwwtnbhwjtnjb +7-8 j: jjjjjjjj +3-4 t: tqtt +5-10 f: fffzbxxszjjvjfhn +3-4 t: tttttttbtt +4-7 p: wjrgpnj +1-9 g: pgzllxgfg +14-15 c: cccccccccccccqm +11-12 b: btmcbzbnzcbbxr +5-6 h: hhhhhhh +1-6 s: nssmsssss +11-12 d: ddddddbddthfdddd +11-13 j: jtjjjjjjpjjjjwfjj +2-4 j: gjjj +3-9 v: vvgvvvvvrv +1-2 l: tqjjljxcsl +5-6 q: nqqqqr +12-16 h: hkhhhhhjhhhhqxhhhhhh +2-6 p: lpppkpbpzg +2-7 v: vzvvvvfv +13-16 g: ggggggggggggwggb +3-14 j: ghsjjcgmkwsdchlslpf +1-3 s: ssplw +7-8 x: xxxnxxxxxxx +3-4 h: zghhvtwtmlplvxxhsbf +4-5 g: sqgsnf +14-17 z: zzzzzzzzzzzzzwczc +1-2 z: cpzzzzk +16-17 s: ssssssssssfsqssss +3-9 j: jvjjfjdjjjjjh +1-6 v: vtvrvvj +4-8 c: clzcccccccf +4-5 d: dwldw +2-4 l: lwlrllllllll +6-11 s: zxgcsdxkrcns +14-17 r: vrhvhrprrfrsrrrrr +3-6 p: mrcztppnl +4-6 w: wwwwwwwwww +1-6 w: zwjccrqpwmnthz +2-7 t: mnjntdcq +1-5 b: bbjbbbbb +10-11 w: wwwwwtwwwwww +4-6 d: dddxdfd +2-4 f: fjfff +13-15 b: vbbbbbbbbbbbbbb +8-9 n: ncbnnnnnn +2-6 d: hdfphnnmbbdt +1-4 f: wffz +7-15 f: ffsffffffffffvzff +8-10 c: zchrckkcqcr +2-6 h: thvbvh diff --git a/2020/day02_password_philosophy/tests/sample_input b/2020/day02_password_philosophy/tests/sample_input new file mode 100644 index 0000000..fe19c03 --- /dev/null +++ b/2020/day02_password_philosophy/tests/sample_input @@ -0,0 +1,3 @@ +1-3 a: abcde +1-3 b: cdefg +2-9 c: ccccccccc