about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2018-12-03 18:10:24 +0100
committerLeah Neukirchen <leah@vuxu.org>2018-12-03 18:10:24 +0100
commit7d95cb7cef2105f441e3e18248b389928b62c7f9 (patch)
tree49ba139a1836fb41e5b543368c7d6c53c6e352e9
parent89d878ebfdd90a540f4a93329c14db56d77be229 (diff)
downloadadventofcode2018-7d95cb7cef2105f441e3e18248b389928b62c7f9.tar.gz
adventofcode2018-7d95cb7cef2105f441e3e18248b389928b62c7f9.tar.xz
adventofcode2018-7d95cb7cef2105f441e3e18248b389928b62c7f9.zip
day02
-rw-r--r--day02250
-rw-r--r--day02.k4
-rw-r--r--day02.rs33
3 files changed, 287 insertions, 0 deletions
diff --git a/day02 b/day02
new file mode 100644
index 0000000..2049121
--- /dev/null
+++ b/day02
@@ -0,0 +1,250 @@
+mgdsdwqulhrinkatfjoyzxcbvq
+megsdwpulhrinkasfjdyzxcbvk
+megsdwpulhmibkatfjoyzccbvq
+megsdwtuohrinkatfjoyzecbvq
+megsdwpulhdinkatfyoyzxcbvb
+megszwpulhrirkatfjoyexcbvq
+eegsdwpulhzinkatfjoyzxdbvq
+megsdwpulhginkatfjoyqucbvq
+leqsdwpulhrinkatfeoyzxcbvq
+megsdwpblhrandatfjoyzxcbvq
+megrdwpudhrinvatfjoyzxcbvq
+mlgsdwpulhrinkatfuoyzxcbyq
+mensdwpunhrinsatfjoyzxcbvq
+megsdwpnlhrinqatfjoyzxcbuq
+megsdwpnlhrinkatfqoysxcbvq
+megsdwpulhrinkjtfjoywxobvq
+megsdwpclhbinkaffjoyzxcbvq
+mersdwpulhrinkattjoyzxcbdq
+megsddpwohrinkatfjoyzxcbvq
+mejsdwpulhrinratfjoyzxcbvl
+megsdwpujhrinkatfjkbzxcbvq
+megsdwpujhrinkatfjoyircbvq
+megsdwgulhrinkatojoyzxcbvm
+qegsdwpulhrinkatfjoyzxggvq
+megsdwpflhrinkatfjsazxcbvq
+megsdwpulhridkagfjoyzzcbvq
+mejsdwpulhriykatfjoyyxcbvq
+measdwpulhriakatfjoyzacbvq
+mebsdwpulhrinkatfjoyzxmyvq
+megsdwpflnrinkatfjoyzxcbxq
+megsdwpulhxinuatfjoytxcbvq
+megsdwsflhrinkatfjoyzxcmvq
+megsdwpuuhritkarfjoyzxcbvq
+megsdwpulhrinkazfjoyexcjvq
+megsdwpulhrifkatfjokzxcbvc
+megsdwmulvrinkatfjoyzxcblq
+meggdwpulhrfnkatfjoybxcbvq
+megsdwptlhrindatyjoyzxcbvq
+megsdwpulhrinkauqjoyzxibvq
+megsdwddlhrifkatfjoyzxcbvq
+megddwpulhrinkagfjoyzxcbva
+messdupulhrinkatfjoyzxqbvq
+megsdwpuahrinkatfjotzxchvq
+megsewpulhrankathjoyzxcbvq
+megsdwpulhrinkatfjoynqcbvv
+megsdwpulhrifkatfjotzxcbtq
+megsdjpulcrinkitfjoyzxcbvq
+fefsowpulhrinkatfjoyzxcbvq
+megsdwpulapinkatfjoyzvcbvq
+mejsdwpularinkatfjonzxcbvq
+megsxwpllrrinkatfjoyzxcbvq
+megsdlpulxvinkatfjoyzxcbvq
+megsdwpulhriekztfjoyzxxbvq
+megspwpulhrinuatfjoyzxcgvq
+megqdwpulhrinkatfjoyzujbvq
+megsdtpuehrinkatfjoyzxtbvq
+megsdwjulhrmnmatfjoyzxcbvq
+megjdwpulhrinkztfjoyzpcbvq
+megsdwpuljrinkawfjlyzxcbvq
+mewsdwpulhtinkatfjodzxcbvq
+megsdwpulhrinkatfcoizxcmvq
+meisdwpulhrinkatawoyzxcbvq
+megshwpulhrinkatfjoyzxcbtz
+megsdwpulhfinkatfjowzxcbvj
+megodwpulhrcskatfjoyzxcbvq
+megydxpulhrinkatfjofzxcbvq
+megsdwpulhrinkatljoytxdbvq
+mwgsdwpulyrinkatfjoyzxvbvq
+meesdwpulhrinkatfjcwzxcbvq
+cegsdwpwlhrinkatfioyzxcbvq
+megsdwpulhrinkatfqhyxxcbvq
+megsrrpulhrxnkatfjoyzxcbvq
+megsdgpulhrinkatfjoypxcbnq
+xegsdwpulhrinkaxkjoyzxcbvq
+mngsdwpulhrenkatfjofzxcbvq
+mecsdwpulhrinkabfjoozxcbvq
+pegsdkpulhrinkatfuoyzxcbvq
+megpdwpughrinkatfjoyzxzbvq
+mxgrdwpulhrinyatfjoyzxcbvq
+megsdwpulhpigkatfjoyzxcbfq
+mhgsdwpulhrinkagfjoxzxcbvq
+megsdwpblhtinkatfjqyzxcbvq
+megsawvulhrinkatfjoyzxcfvq
+metsuwpulhrinkatfjowzxcbvq
+mexsdwpulhrinkatsjoyzxvbvq
+megtdwpulhrinkatfjoizxcpvq
+megidwpjlhrinkatfdoyzxcbvq
+megsdwpuljrivkatfjoyqxcbvq
+mespdppulhrinkatfjoyzxcbvq
+megsdcpulhminkatftoyzxcbvq
+megsdwpulhriskatfjayzlcbvq
+mejsdwpulhrinkatfvoyzxibvq
+megfdwputhriykatfjoyzxcbvq
+megsdwparhrinkbtfjoyzxcbvq
+mtgsdwpulhmingatfjoyzxcbvq
+megsdwjulhrinkatfjtyzxtbvq
+megsvwpulhrinkatfjoyzecbvf
+megsdwpulprinkatyqoyzxcbvq
+zegsdwpulhwinkatfjoyzxcfvq
+megsdwiulhrinkatfjoyzxcjcq
+aegsdwpulirinkatfjoyvxcbvq
+mepsdwculbrinkatfjoyzxcbvq
+msgsdcpulhrinkctfjoyzxcbvq
+megsdwpulhrinkatfjoozxfevq
+megscwpulhrinkatmjoyzxcbsq
+megsdwpulhrinkltfjoyzxtmvq
+megsddpulhrixkatfjyyzxcbvq
+megsdwpulhrinkctfjoqzhcbvq
+megsbapblhrinkatfjoyzxcbvq
+megsdwpulhrinkatfjoyyxgpvq
+mwpsdwpulhrinkutfjoyzxcbvq
+megsdwpulhrinvnlfjoyzxcbvq
+megsdwsulorinkakfjoyzxcbvq
+mbgsdwpulhrinkktfjoyzxcbvg
+megddwpulhrindatfjoyzxcbvr
+memsdwpulhrinkatqjoyzxcbvo
+megsdwpulbrinkarfjoyzxcbxq
+megsdwpulhrilkatfjoynxcgvq
+mxgsdzpulhrinkatfjoydxcbvq
+megsawpulhrinkotfjoyzacbvq
+measdwpulhrinkctvjoyzxcbvq
+medsdwpulhtinkaqfjoyzxcbvq
+megsdwsulhrknkatfjoylxcbvq
+megadwpulhrinkatfjkyzxcbvh
+mygsdwpulhrinkatfboyzxcavq
+megsdwpulhrinkaufjxyzccbvq
+mtgsdwpulhrunkatfkoyzxcbvq
+megsdwpulhrinkamfwryzxcbvq
+meesdwpulhrgnkatnjoyzxcbvq
+megddwpolhrinkatfjoyixcbvq
+megsdwpulhrinsatfjoyzicwvq
+mmgsdwpulhrinkltfjoyzxcgvq
+meisdwpulhhinkatfjoyzxubvq
+megpdwpulhrinkatfroyzxcbkq
+megszwpuhhrinkatfjoyzxcbzq
+mersdwpulhrikcatfjoyzxcbvq
+mjgsdwpulhrinratfjoyzxcbvl
+megsdwnulkxinkatfjoyzxcbvq
+megsdwpulhrinkatlaoyzxpbvq
+megsdwpulhribkitfjjyzxcbvq
+megsdwpzlhrinkalfjoyzkcbvq
+megsdwpulhrinkutfjoyzxcdnq
+mfgpdwputhrinkatfjoyzxcbvq
+oegshwpclhrinkatfjoyzxcbvq
+megvdwxulhrinkatfjowzxcbvq
+mrgydwpulhrinkatfjoyzxcbvl
+megsdwpuqhrinkaxfjoyzxcbfq
+megsdwpughrinixtfjoyzxcbvq
+megsdwpslxrinkatfjoyzxcbvl
+megsdwpukhrinkatfjovzxnbvq
+megsdwpulnrinkrtojoyzxcbvq
+megsdwpuvhrinkatfjjyzxclvq
+vegrdwpulhrinzatfjoyzxcbvq
+melsdwwulvrinkatfjoyzxcbvq
+megsdwpulhrizkbtfjoyzjcbvq
+megsdwpulhrinlatfjoyzkcbvr
+megsdweulhrinkaofqoyzxcbvq
+megsdcpulhrifkatfdoyzxcbvq
+negsdwpulhainkztfjoyzxcbvq
+megsdwpklhrinkttfjoyzxvbvq
+megsdwpothrdnkatfjoyzxcbvq
+megsdwpulvrinkatfaoyzxcbvr
+mewsdwpulhrinkatfooyzxtbvq
+megtdwpulhrinkatfxoyzxcbvy
+zegsdwpulhrinkamljoyzxcbvq
+mkgodwpulhrcnkatfjoyzxcbvq
+megsdepularinkatfjoyzxybvq
+segsdwpulhrinkatfmoyzycbvq
+mbgsdwpulhrsnkztfjoyzxcbvq
+megsdwpmlhrinkatfjxyzhcbvq
+megsdwpulhrinkatfboyqxmbvq
+megsdwpulhrinkadtpoyzxcbvq
+megsdmpulhrjnkatfjoyzxwbvq
+megsdwpulhrivkatfroywxcbvq
+megsdwdulhrinkatpjwyzxcbvq
+megsdwpylhrdrkatfjoyzxcbvq
+megsdwpulhrvnkptfjoyzlcbvq
+megsdwpuihridkatfjuyzxcbvq
+megsdwpulhbiikatfjxyzxcbvq
+meggdwpulurinkatfjoyaxcbvq
+mehsnwpulcrinkatfjoyzxcbvq
+megsdwpulhrinkatfjoczdclvq
+megsdwjulhrinkatfhkyzxcbvq
+megsdwpulhrinoatfjoyzxcwvy
+megpdwpelhrfnkatfjoyzxcbvq
+megsjwpulhrwnkatfjdyzxcbvq
+megsdwpulhrbniatfjoyzxcbpq
+megsdwpulhrwnkatfjoydxcpvq
+megsdwrulhrinkatfjvyixcbvq
+yegvdwpulhtinkatfjoyzxcbvq
+meosdwpulhrinkatfjhyzxsbvq
+mjgsdwpulhrinkatfjoyyxcjvq
+megsdwpulhrinkatfnoyzlmbvq
+mehsdfkulhrinkatfjoyzxcbvq
+megsdwpuahrinkatfyoyzxcwvq
+megsdwpulhyinkatfjobzkcbvq
+megsdwpjlhrinkatfnoyzscbvq
+megsdwiulhrinqatfjoyzxcavq
+megsdwpulurinkatfjoykxcbmq
+megsdwpmlhvinkatfjotzxcbvq
+megswwpulhrinfatfjoytxcbvq
+mxgsdwpulhrrnkatfjoyhxcbvq
+megubwpulhrinkaafjoyzxcbvq
+megsdwpulhrdnsztfjoyzxcbvq
+megsdwpulhronkgtfjhyzxcbvq
+megsdwzulhfinratfjoyzxcbvq
+megsdwpulhrinkrtfjqyixcbvq
+megspwpulhrinkatfjoywxcavq
+megmfjpulhrinkatfjoyzxcbvq
+lelsdwpulhrinsatfjoyzxcbvq
+megsdwnultrinkatfjoyzxybvq
+megsdwpulhdnnkatfjpyzxcbvq
+megsdwpulhzinkatfjoyzhcpvq
+megoddpulhrilkatfjoyzxcbvq
+megsdvpulhrwnkatfjoyzxcbdq
+megsdwpulhmikkatfjoyzxcbvr
+meesdwpulhrinkaofjoazxcbvq
+megndwhulhrinfatfjoyzxcbvq
+megsdwpulhjihkatfjoyzxcbvb
+jegsdwpulhrinkattjoszxcbvq
+megsdwpulhrenkatfjodzxcbvp
+mefsdwpulhrinkatfjoyzxcczq
+megsdwpulhrknkatfjovzxcbvb
+megytwpulhrinkatfjoyzxcbvo
+csgsdwpulhrinkatdjoyzxcbvq
+megsbwpulhrinkazfjtyzxcbvq
+mrgsdwpulhjinkatfjoyzxcbvm
+megsywzulhrinkatfjofzxcbvq
+megxdwpulhrndkatfjoyzxcbvq
+mcgsdwpuphrixkatfjoyzxcbvq
+megsdlpulxvinkatfvoyzxcbvq
+megsdwpulhrinfatfjoyzicbvo
+megwgwpulhrinpatfjoyzxcbvq
+mggsdwpulhrinkatfjtrzxcbvq
+msgsdwpulirinkatfjoyzxcbaq
+megsdwpulhrineatfeoyzxcbvl
+megsdnpulhrinkatojoyzxcbvb
+mfgsdwpulhdinkatmjoyzxcbvq
+megsdwpulhrinkawfjuyzxcbvg
+megsdwpulhrincatfjoyzxcxvu
+mevsdwzplhrinkatfjoyzxcbvq
+megskweulhfinkatfjoyzxcbvq
+mebsdvpulhrinkatfjoyzxcbkq
+megddwiulhrinkatfioyzxcbvq
+mygsdwpulhqinkatfooyzxcbvq
+megsdweulhrfnkatfjoybxcbvq
+mrgsdhpulmrinkatfjoyzxcbvq
+megsdwkukhrinkatftoyzxcbvq
+megsqwpulhrinfatfjoyzxebvq
+megsdwpulhriskanfjoyzxctvq
diff --git a/day02.k b/day02.k
new file mode 100644
index 0000000..35fa402
--- /dev/null
+++ b/day02.k
@@ -0,0 +1,4 @@
+v:1:`day02
+*/{+/(0<#(x=#:)#=:)'v}'2 3  / 5456
+(*r)@&=/r:v@,/(&1=+/')'~v=\:/:v  / megsdlpulxvinkatfoyzxcbvq
+\\
diff --git a/day02.rs b/day02.rs
new file mode 100644
index 0000000..3c5b9b5
--- /dev/null
+++ b/day02.rs
@@ -0,0 +1,33 @@
+use std::fs::File;
+use std::io::{BufRead, BufReader};
+
+fn appears(s: &str, n: usize) -> bool {
+    s.chars().any(|c| s.matches(c).count() == n)
+}
+
+fn same_but_one(s: &str, t: &str) -> Option<String> {
+    let mut x = s.chars().zip(t.chars()).enumerate().filter(|(_, (a,b))| a != b);
+    match (x.next(), x.next()) {
+        (Some(m), None) => Some(format!("{}{}", &s[..m.0], &s[m.0+1..])),
+        _ => None
+    }
+}
+
+fn main() {
+    let f = File::open("day02").unwrap();
+
+    let v: Vec<_> = BufReader::new(&f).lines().map(|l| l.unwrap()).collect();
+
+    println!("{}",
+             v.iter().filter(|s| appears(s, 2)).count() *
+             v.iter().filter(|s| appears(s, 3)).count());
+
+    'outer: for x in &v {
+        for y in &v {
+            if let Some(s) = same_but_one(&x, &y) {
+                println!("{}", s);
+                break 'outer;
+            }
+        }
+    }
+}