summaryrefslogtreecommitdiffstats
path: root/2015
diff options
context:
space:
mode:
authoralyx <alyx@aleteoryx.me>2023-11-19 18:09:01 -0500
committeralyx <alyx@aleteoryx.me>2023-11-19 18:09:01 -0500
commit4e158659f8b222e8815d06fcbbd34f1e7cbc1d46 (patch)
treecbac78ef60260867b459dbc7d797bf875311fc05 /2015
parent2d12f6ec2294e36ae090fdd1e10025452ec1a480 (diff)
downloadadventofcode-4e158659f8b222e8815d06fcbbd34f1e7cbc1d46.tar.gz
adventofcode-4e158659f8b222e8815d06fcbbd34f1e7cbc1d46.tar.bz2
adventofcode-4e158659f8b222e8815d06fcbbd34f1e7cbc1d46.zip
2015.8
Diffstat (limited to '2015')
-rw-r--r--2015/rs/Cargo.toml4
-rw-r--r--2015/rs/src/eight.rs55
-rw-r--r--2015/rs/src/eight.txt300
3 files changed, 359 insertions, 0 deletions
diff --git a/2015/rs/Cargo.toml b/2015/rs/Cargo.toml
index 7f6f71f..e50e704 100644
--- a/2015/rs/Cargo.toml
+++ b/2015/rs/Cargo.toml
@@ -31,5 +31,9 @@ path = "src/six.rs"
name = "seven"
path = "src/seven.rs"
+[[bin]]
+name = "eight"
+path = "src/eight.rs"
+
[dependencies]
md-5 = "0.10.6"
diff --git a/2015/rs/src/eight.rs b/2015/rs/src/eight.rs
new file mode 100644
index 0000000..ce9a8a7
--- /dev/null
+++ b/2015/rs/src/eight.rs
@@ -0,0 +1,55 @@
+static INPUT: &'static str = include_str!("eight.txt");
+
+#[derive(Copy, Clone)]
+enum ParseState {
+ Verbatim,
+ Esc,
+ Hex1,
+ Hex2(u32)
+}
+
+fn main() {
+ let valueified = INPUT.split('\n')
+ .filter(|s| !s.is_empty());
+
+ let (oglen, parsedlen) = valueified.clone()
+ .map(|s| {
+ let rs = s.strip_prefix('"').and_then(|s| s.strip_suffix('"')).unwrap();
+ let mut buf = String::with_capacity(s.len());
+ let mut state = ParseState::Verbatim;
+ for c in rs.chars() {
+ match (state, c) {
+ (ParseState::Verbatim, '\\') => { state = ParseState::Esc; },
+ (ParseState::Verbatim, c) => { buf.push(c); },
+
+ (ParseState::Esc, 'x') => { state = ParseState::Hex1; },
+ (ParseState::Esc, c) => { buf.push(c); state = ParseState::Verbatim; },
+
+ (ParseState::Hex1, c) => { state = ParseState::Hex2(c.to_digit(16).unwrap() * 16); },
+ (ParseState::Hex2(n), c) => { buf.push(/*char::from_u32(n + c.to_digit(16).unwrap()).unwrap()*/'?'); state = ParseState::Verbatim; },
+ }
+ }
+ (s, buf)
+ })
+ .fold((0, 0), |(a1, b1), (a2, b2)| (a1 + a2.len(), b1 + b2.len()));
+ let lendiff = oglen - parsedlen;
+ println!("Literal Length - Parsed Length: {lendiff}");
+
+ let (oglen, enclen) = valueified
+ .map(|s| {
+ let mut buf = String::with_capacity(s.len() * 2);
+ buf.push('"');
+ for c in s.chars() {
+ match c {
+ '\\' => { buf += "\\\\" },
+ '"' => { buf += "\\\"" },
+ c => { buf.push(c) },
+ }
+ }
+ buf.push('"');
+ (s, buf)
+ })
+ .fold((0, 0), |(a1, b1), (a2, b2)| (a1 + a2.len(), b1 + b2.len()));
+ let lendiff = enclen - oglen;
+ println!("Encoded Length - Literal Length: {lendiff}");
+}
diff --git a/2015/rs/src/eight.txt b/2015/rs/src/eight.txt
new file mode 100644
index 0000000..0e80d0f
--- /dev/null
+++ b/2015/rs/src/eight.txt
@@ -0,0 +1,300 @@
+"azlgxdbljwygyttzkfwuxv"
+"v\xfb\"lgs\"kvjfywmut\x9cr"
+"merxdhj"
+"dwz"
+"d\\gkbqo\\fwukyxab\"u"
+"k\xd4cfixejvkicryipucwurq\x7eq"
+"nvtidemacj\"hppfopvpr"
+"kbngyfvvsdismznhar\\p\"\"gpryt\"jaeh"
+"khre\"o\x0elqfrbktzn"
+"nugkdmqwdq\x50amallrskmrxoyo"
+"jcrkptrsasjp\\\"cwigzynjgspxxv\\vyb"
+"ramf\"skhcmenhbpujbqwkltmplxygfcy"
+"aqjqgbfqaxga\\fkdcahlfi\"pvods"
+"pcrtfb"
+"\x83qg\"nwgugfmfpzlrvty\"ryoxm"
+"fvhvvokdnl\\eap"
+"kugdkrat"
+"seuxwc"
+"vhioftcosshaqtnz"
+"gzkxqrdq\\uko\"mrtst"
+"znjcomvy\x16hhsenmroswr"
+"clowmtra"
+"\xc4"
+"jpavsevmziklydtqqm"
+"egxjqytcttr\\ecfedmmovkyn\"m"
+"mjulrvqgmsvmwf"
+"o\\prxtlfbatxerhev\xf9hcl\x44rzmvklviv"
+"lregjexqaqgwloydxdsc\\o\"dnjfmjcu"
+"lnxluajtk\x8desue\\k\x7abhwokfhh"
+"wrssfvzzn\"llrysjgiu\"npjtdli"
+"\x67lwkks"
+"bifw\"ybvmwiyi\"vhol\"vol\xd4"
+"aywdqhvtvcpvbewtwuyxrix"
+"gc\xd3\"caukdgfdywj"
+"uczy\\fk"
+"bnlxkjvl\x7docehufkj\\\"qoyhag"
+"bidsptalmoicyorbv\\"
+"jorscv\"mufcvvfmcv\"ga"
+"sofpwfal\\a"
+"kcuqtbboaly\"uj\"k"
+"n\\c"
+"x\"\xcaj\\xwwvpdldz"
+"eyukphh"
+"wcyjq"
+"vjx\"\"hjroj\"l\x4cjwbr"
+"xcodsxzfqw\\rowqtuwvjnxupjnrh"
+"yc"
+"fpvzldgbdtca\"hqwa"
+"ymjq\x8ahohvafubra\"hgqoknkuyph"
+"kx\\mkaaklvcup"
+"belddrzegcsxsyfhzyz"
+"fuyswi"
+"\\hubzebo\"ha\\qyr\"dv\\"
+"mxvlz\"fwuvx\"cyk\""
+"ftbh\"ro\\tmcpnpvh\"xx"
+"ygi"
+"rw\"\"wwn\\fgbjumq\"vgvoh\xd0\"mm"
+"\"pat\"\x63kpfc\"\x2ckhfvxk\"uwqzlx"
+"o"
+"d\"hqtsfp\xceaswe\"\xc0lw"
+"zajpvfawqntvoveal\"\"trcdarjua"
+"xzapq"
+"rkmhm"
+"byuq"
+"rwwmt\xe8jg\xc2\"omt"
+"nfljgdmgefvlh\"x"
+"rpjxcexisualz"
+"doxcycmgaiptvd"
+"rq\\\"mohnjdf\\xv\\hrnosdtmvxot"
+"oqvbcenib\"uhy\\npjxg"
+"pkvgnm\\ruayuvpbpd"
+"kknmzpxqfbcdgng"
+"piduhbmaympxdexz"
+"vapczawekhoa\\or"
+"tlwn\"avc\"bycg\"\"xuxea"
+"\xcdvryveteqzxrgopmdmihkcgsuozips"
+"kpzziqt"
+"sdy\\s\"cjq"
+"yujs"
+"qte\"q"
+"qyvpnkhjcqjv\"cclvv\"pclgtg\xeak\"tno"
+"xwx"
+"vibuvv"
+"qq\""
+"wwjduomtbkbdtorhpyalxswisq\"r"
+"afuw\\mfjzctcivwesutxbk\"lk"
+"e\xcef\\hkiu"
+"ftdrgzvygcw\"jwsrcmgxj"
+"zrddqfkx\x21dr\"ju\"elybk\"powj\"\"kpryz"
+"dttdkfvbodkma\""
+"lzygktugpqw"
+"qu\x83tes\\u\"tnid\"ryuz"
+"\\o\"pe\\vqwlsizjklwrjofg\xe2oau\\rd"
+"mikevjzhnwgx\"fozrj\"h\""
+"ligxmxznzvtachvvbahnff"
+"d\\kq"
+"tnbkxpzmcakqhaa"
+"g\\yeakebeyv"
+"cqkcnd\"sxjxfnawy\x31zax\x6ceha"
+"m\x0dtqotffzdnetujtsgjqgwddc"
+"masnugb\"etgmxul\x3bqd\\tmtddnvcy"
+"floediikodfgre\x23wyoxlswxflwecdjpt"
+"zu"
+"r"
+"\"ashzdbd\"pdvba\xeeumkr\\amnj"
+"ckslmuwbtfouwpfwtuiqmeozgspwnhx"
+"t\\qjsjek\xf9gjcxsyco\"r"
+"hoed\x1b\\tcmaqch\"epdy"
+"mgjiojwzc\\ypqcn\xb1njmp\"aeeblxt"
+"\xdf\"h\x5enfracj"
+"\x6fpbpocrb"
+"jbmhrswyyq\\"
+"wtyqtenfwatji\"ls\\"
+"voy"
+"awj"
+"rtbj\"j"
+"hynl"
+"orqqeuaat\\xu\\havsgr\xc5qdk"
+"g\"npyzjfq\"rjefwsk"
+"rk\\kkcirjbixr\\zelndx\"bsnqvqj\""
+"tecoz"
+"dn\"uswngbdk\""
+"qb\\"
+"wpyis\\ebq"
+"ppwue\\airoxzjjdqbvyurhaabetv"
+"fxlvt"
+"ql\"oqsmsvpxcg\"k"
+"vqlhuec\\adw"
+"qzmi\xffberakqqkk"
+"tisjqff\"wf"
+"yhnpudoaybwucvppj"
+"xhfuf\\ehsrhsnfxcwtibd\"ubfpz"
+"ihgjquzhf\""
+"ff\x66dsupesrnusrtqnywoqcn\\"
+"z\x77zpubbjmd"
+"\"vhzlbwq\"xeimjt\\xe\x85umho\"m\"\"bmy"
+"mmuvkioocmzjjysi\"mkfbec\""
+"rpgghowbduw\x2fayslubajinoik\xd0hcfy"
+"xrkyjqul\xdexlojgdphczp\"jfk"
+"mg\x07cnr\x8b\x67xdgszmgiktpjhawho"
+"kdgufhaoab"
+"rlhela\"nldr"
+"wzye\x87u"
+"yif\x75bjhnitgoarmfgqwpmopu"
+"pvlbyez\"wyy\x3dpgr"
+"ezdm\"ovkruthkvdwtqwr\"ibdoawzgu"
+"qubp"
+"b\\kcpegcn\\zgdemgorjnk"
+"gjsva\\kzaor\"\"gtpd"
+"\"kt"
+"rlymwlcodix"
+"qqtmswowxca\"jvv"
+"jni\xebwhozb"
+"zhino\"kzjtmgxpi\"zzexijg"
+"tyrbat\\mejgzplufxixkyg"
+"lhmopxiao\x09\"p\xebl"
+"xefioorxvate"
+"nmcgd\x46xfujt\"w"
+"\xe3wnwpat\"gtimrb"
+"wpq\"xkjuw\xebbohgcagppb"
+"fmvpwaca"
+"mlsw"
+"fdan\\\x9e"
+"\"f\"fmdlzc"
+"nyuj\\jnnfzdnrqmhvjrahlvzl"
+"zn\"f\xcfsshcdaukkimfwk"
+"uayugezzo\\\"e\"blnrgjaupqhik"
+"efd\"apkndelkuvfvwyyatyttkehc"
+"ufxq\\\"m\"bwkh\x93kapbqrvxxzbzp\\"
+"fgypsbgjak\x79qblbeidavqtddfacq\\i\"h"
+"kcfgpiysdxlgejjvgndb\\dovfpqodw"
+"\"onpqnssmighipuqgwx\"nrokzgvg"
+"vhjrrhfrba\"jebdanzsrdusut\\wbs"
+"o\xdakymbaxakys"
+"uwxhhzz\\mtmhghjn\\\\tnhzbejj"
+"yd\\"
+"bpgztp\\lzwpdqju\"it\x35qjhihjv"
+"\\my\\b\"klnnto\\\xb3mbtsh"
+"ezyvknv\"l\x2bdhhfjcvwzhjgmhwbqd\"\\"
+"ftkz\"amoncbsohtaumhl\"wsodemopodq"
+"ifv"
+"dmzfxvzq"
+"sped\"bvmf\"mmevl\"zydannpfny"
+"fjxcjwlv\"pnqyrzatsjwsqfidb"
+"muc\xfdqouwwnmuixru\\zlhjintplvtee"
+"mraqgvmj"
+"njopq\"ftcsryo"
+"enoh\"n"
+"t\"ntjhjc\"nzqh\xf7dcohhlsja\x7dtr"
+"flbqcmcoun"
+"dxkiysrn\\dyuqoaig"
+"nehkzi\"h\"syktzfufotng\xdafqo"
+"dzkjg\\hqjk\\\"zfegssjhn"
+"sadlsjv"
+"vmfnrdb\""
+"ac\\bdp\"n"
+"qt\x89h"
+"lsndeugwvijwde\\vjapbm\\k\\nljuva"
+"twpmltdzyynqt\\z\\tnund\x64hm"
+"hpcyata\"ocylbkzdnhujh"
+"hskzq\"knntuhscex\"q\\y\\vqj\x3an"
+"eekwyufvji\\mqgeroekxeyrmymq"
+"hl\"durthetvri\xebw\\jxu\"rcmiuy"
+"\"fxdnmvnftxwesmvvq\"sjnf\xaabpg\"iary"
+"\"\"nksqso"
+"ruq\xbezugge\"d\"hwvoxmy\"iawikddxn\"x"
+"rxxnlfay"
+"stcu\"mv\xabcqts\\fasff"
+"yrnvwfkfuzuoysfdzl\x02bk"
+"qbdsmlwdbfknivtwijbwtatqfe"
+"\"erqh\\csjph"
+"ikfv"
+"\xd2cuhowmtsxepzsivsvnvsb"
+"vj"
+"d"
+"\\g"
+"porvg\x62qghorthnc\"\\"
+"tiks\\kr\"\x0fuejvuxzswnwdjscrk"
+"xmgfel\"atma\\zaxmlgfjx\"ajmqf"
+"oz\\rnxwljc\\\"umhymtwh"
+"wlsxxhm\x7fqx\\gjoyrvccfiner\\qloluqv"
+"k\\ieq"
+"xidjj\"ksnlgnwxlddf\\s\\kuuleb"
+"wjpnzgprzv\\maub\x0cj"
+"r"
+"y"
+"\"yecqiei\"ire\\jdhlnnlde\xc5u"
+"drvdiycqib"
+"egnrbefezcrhgldrtb"
+"plqodxv\\zm\"uodwjdocri\x55ucaezutm"
+"f\"wexcw\x02ekewx\"alyzn"
+"pqajwuk\\\\oatkfqdyspnrupo"
+"rkczj\"fzntabpnygrhamk\\km\x68xfkmr"
+"wejam\xbac\x37kns"
+"qqmlwjk\"gh"
+"fdcjsxlgx"
+"\\cxvxy\"kb\"\"unubvrsq\\y\\awfhbmarj\\"
+"geunceaqr"
+"tpkg\"svvngk\\sizlsyaqwf"
+"\"pa\\x\x18od\\emgje\\"
+"ffiizogjjptubzqfuh\"cctieqcdh"
+"yikhiyyrpgglpos"
+"h\\"
+"jotqojodcv"
+"ervsz\x87ade\"fevq\\tcqowt"
+"\\y\"fgrxtppkcseeg\\onxjarx\\hyhfn\x5fi"
+"kxndlabn\\wwumctuzdcfiitrbnn"
+"eoosynwhwm"
+"\"c\x04"
+"ny\xf6vuwlec"
+"ubgxxcvnltzaucrzg\\xcez"
+"pnocjvo\\yt"
+"fcabrtqog\"a\"zj"
+"o\\bha\\mzxmrfltnflv\xea"
+"tbfvzwhexsdxjmxejwqqngzixcx"
+"wdptrakok\"rgymturdmwfiwu"
+"reffmj"
+"lqm"
+"\\oc"
+"p\""
+"ygkdnhcuehlx"
+"vsqmv\"bqay\"olimtkewedzm"
+"isos\x6azbnkojhxoopzetbj\xe1yd"
+"yo\\pgayjcyhshztnbdv"
+"fg\"h"
+"vcmcojolfcf\\\\oxveua"
+"w\"vyszhbrr\"jpeddpnrjlca\x69bdbopd\\z"
+"jikeqv"
+"\"dkjdfrtj"
+"is"
+"hgzx"
+"z\""
+"woubquq\\ag\""
+"xvclriqa\xe6ltt"
+"tfxinifmd"
+"mvywzf\"jz"
+"vlle"
+"c\"rf\"wynhye\x25vccvb\""
+"zvuxm"
+"\xf2\"jdstiwqer\"h"
+"kyogyogcknbzv\x9f\\\\e"
+"kspodj\"edpeqgypc"
+"oh\\x\\h"
+"julb"
+"bmcfkidxyilgoy\\xmu\"ig\\qg"
+"veqww\"ea"
+"fkdbemtgtkpqisrwlxutllxc\"mbelhs"
+"e"
+"ecn\x50ooprbstnq"
+"\"\xe8\"ec\xeah\"qo\\g\"iuqxy\"e\"y\xe7xk\xc6d"
+"lwj\"aftrcqj"
+"jduij\x97zk\"rftjrixzgscxxllpqx\"bwwb"
+"fqcditz"
+"f\x19azclj\"rsvaokgvty\"aeq"
+"erse\x9etmzhlmhy\x67yftoti"
+"lsdw\xb3dmiy\\od"
+"x\x6fxbljsjdgd\xaau"
+"hjg\\w\"\x78uoqbsdikbjxpip\"w\"jnhzec"
+"gk"
+"\\zrs\\syur"