diff options
author | alyx <alyx@aleteoryx.me> | 2023-11-19 14:55:43 -0500 |
---|---|---|
committer | alyx <alyx@aleteoryx.me> | 2023-11-19 14:55:43 -0500 |
commit | 2d12f6ec2294e36ae090fdd1e10025452ec1a480 (patch) | |
tree | 9467466f8fb7daba9d76a6a956931eba51b5d865 /2015 | |
download | adventofcode-2d12f6ec2294e36ae090fdd1e10025452ec1a480.tar.gz adventofcode-2d12f6ec2294e36ae090fdd1e10025452ec1a480.tar.bz2 adventofcode-2d12f6ec2294e36ae090fdd1e10025452ec1a480.zip |
Initial commit, done up to 2015.7
Diffstat (limited to '2015')
-rw-r--r-- | 2015/rs/Cargo.lock | 77 | ||||
-rw-r--r-- | 2015/rs/Cargo.toml | 35 | ||||
-rw-r--r-- | 2015/rs/src/base.rs | 5 | ||||
-rw-r--r-- | 2015/rs/src/five.rs | 52 | ||||
-rw-r--r-- | 2015/rs/src/five.txt | 1000 | ||||
-rw-r--r-- | 2015/rs/src/four.rs | 46 | ||||
-rw-r--r-- | 2015/rs/src/one.rs | 11 | ||||
-rw-r--r-- | 2015/rs/src/one.txt | 1 | ||||
-rw-r--r-- | 2015/rs/src/seven.rs | 94 | ||||
-rw-r--r-- | 2015/rs/src/seven.txt | 339 | ||||
-rw-r--r-- | 2015/rs/src/six.rs | 57 | ||||
-rw-r--r-- | 2015/rs/src/six.txt | 300 | ||||
-rw-r--r-- | 2015/rs/src/three.rs | 29 | ||||
-rw-r--r-- | 2015/rs/src/three.txt | 1 | ||||
-rw-r--r-- | 2015/rs/src/two.rs | 31 | ||||
-rw-r--r-- | 2015/rs/src/two.txt | 1000 |
16 files changed, 3078 insertions, 0 deletions
diff --git a/2015/rs/Cargo.lock b/2015/rs/Cargo.lock new file mode 100644 index 0000000..fcc0eb5 --- /dev/null +++ b/2015/rs/Cargo.lock @@ -0,0 +1,77 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "rs" +version = "0.1.0" +dependencies = [ + "md-5", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" diff --git a/2015/rs/Cargo.toml b/2015/rs/Cargo.toml new file mode 100644 index 0000000..7f6f71f --- /dev/null +++ b/2015/rs/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "rs" +version = "0.1.0" +edition = "2021" + +[[bin]] +name = "one" +path = "src/one.rs" + +[[bin]] +name = "two" +path = "src/two.rs" + +[[bin]] +name = "three" +path = "src/three.rs" + +[[bin]] +name = "four" +path = "src/four.rs" + +[[bin]] +name = "five" +path = "src/five.rs" + +[[bin]] +name = "six" +path = "src/six.rs" + +[[bin]] +name = "seven" +path = "src/seven.rs" + +[dependencies] +md-5 = "0.10.6" diff --git a/2015/rs/src/base.rs b/2015/rs/src/base.rs new file mode 100644 index 0000000..44099ac --- /dev/null +++ b/2015/rs/src/base.rs @@ -0,0 +1,5 @@ +static INPUT: &'static str = include_str!("!!.txt"); + +fn main() { + let valueified = INPUT; +} diff --git a/2015/rs/src/five.rs b/2015/rs/src/five.rs new file mode 100644 index 0000000..804d38b --- /dev/null +++ b/2015/rs/src/five.rs @@ -0,0 +1,52 @@ +static INPUT: &'static str = include_str!("five.txt"); + +fn main() { + let valueified = INPUT.split('\n').filter(|s| !s.is_empty()); + + let nice_count = valueified.clone().filter(|s| { + let mut s2 = s.chars(); + let mut last_char = s2.next().unwrap(); + + let mut double_flag = false; + let mut abcdpqxy_flag = false; + for c in s2 { + if c == last_char { double_flag = true; } + if [('a','b'),('c','d'),('p','q'),('x','y')].contains(&(last_char, c)) { abcdpqxy_flag = true; } + if double_flag && abcdpqxy_flag { break; } + + last_char = c; + } + + s.chars().filter(|c| "aeiou".contains(*c)).count() >= 3 && double_flag && !abcdpqxy_flag + }).count(); + println!("Nice word count: {nice_count}"); + + let nice_count = valueified.filter(|s| { + let mut s = s.chars(); + let mut llc = s.next().unwrap(); + let mut lc = s.next().unwrap(); + + let mut dupeslist = Vec::with_capacity(32); + dupeslist.push((llc, lc)); + let mut pushed = true; + + let mut flag1 = false; + let mut flag2 = false; + + for c in s { + if !flag1 && (lc != c || (lc == c && (llc != lc || !pushed))) && dupeslist.contains(&(lc, c)) { flag1 = true; } + if !flag1 && !dupeslist.contains(&(lc, c)) { dupeslist.push((lc, c)); pushed = true; } else { pushed = false; } + + if c == llc { flag2 = true; } + + if flag1 && flag2 { break; } + + llc = lc; + lc = c; + } + + flag1 && flag2 + }).count(); + + println!("Nice word(v2) count: {nice_count}"); +} diff --git a/2015/rs/src/five.txt b/2015/rs/src/five.txt new file mode 100644 index 0000000..a9b6e77 --- /dev/null +++ b/2015/rs/src/five.txt @@ -0,0 +1,1000 @@ +sszojmmrrkwuftyv +isaljhemltsdzlum +fujcyucsrxgatisb +qiqqlmcgnhzparyg +oijbmduquhfactbc +jqzuvtggpdqcekgk +zwqadogmpjmmxijf +uilzxjythsqhwndh +gtssqejjknzkkpvw +wrggegukhhatygfi +vhtcgqzerxonhsye +tedlwzdjfppbmtdx +iuvrelxiapllaxbg +feybgiimfthtplui +qxmmcnirvkzfrjwd +vfarmltinsriqxpu +oanqfyqirkraesfq +xilodxfuxphuiiii +yukhnchvjkfwcbiq +bdaibcbzeuxqplop +ivegnnpbiyxqsion +ybahkbzpditgwdgt +dmebdomwabxgtctu +ibtvimgfaeonknoh +jsqraroxudetmfyw +dqdbcwtpintfcvuz +tiyphjunlxddenpj +fgqwjgntxagidhah +nwenhxmakxqkeehg +zdoheaxqpcnlhnen +tfetfqojqcdzlpbm +qpnxkuldeiituggg +xwttlbdwxohahwar +hjkwzadmtrkegzye +koksqrqcfwcaxeof +wulwmrptktliyxeq +gyufbedqhhyqgqzj +txpunzodohikzlmj +jloqfuejfkemcrvu +amnflshcheuddqtc +pdvcsduggcogbiia +yrioavgfmeafjpcz +uyhbtmbutozzqfvq +mwhgfwsgyuwcdzik +auqylgxhmullxpaa +lgelzivplaeoivzh +uyvcepielfcmswoa +qhirixgwkkccuzlp +zoonniyosmkeejfg +iayfetpixkedyana +ictqeyzyqswdskiy +ejsgqteafvmorwxe +lhaiqrlqqwfbrqdx +ydjyboqwhfpqfydc +dwhttezyanrnbybv +edgzkqeqkyojowvr +rmjfdwsqamjqehdq +ozminkgnkwqctrxz +bztjhxpjthchhfcd +vrtioawyxkivrpiq +dpbcsznkpkaaclyy +vpoypksymdwttpvz +hhdlruwclartkyap +bqkrcbrksbzcggbo +jerbbbnxlwfvlaiw +dwkasufidwjrjfbf +kkfxtjhbnmqbmfwf +vmnfziwqxmioukmj +rqxvcultipkecdtu +fhmfdibhtjzkiqsd +hdpjbuzzbyafqrpd +emszboysjuvwwvts +msyigmwcuybfiooq +druyksfnbluvnwoh +fvgstvynnfbvxhsx +bmzalvducnqtuune +lzwkzfzttsvpllei +olmplpvjamynfyfd +padcwfkhystsvyfb +wjhbvxkwtbfqdilb +hruaqjwphonnterf +bufjobjtvxtzjpmj +oiedrjvmlbtwyyuy +sgiemafwfztwsyju +nsoqqfudrtwszyqf +vonbxquiiwxnazyl +yvnmjxtptujwqudn +rrnybqhvrcgwvrkq +taktoxzgotzxntfu +quffzywzpxyaepxa +rfvjebfiddcfgmwv +iaeozntougqwnzoh +scdqyrhoqmljhoil +bfmqticltmfhxwld +brbuktbyqlyfpsdl +oidnyhjkeqenjlhd +kujsaiqojopvrygg +vebzobmdbzvjnjtk +uunoygzqjopwgmbg +piljqxgicjzgifso +ikgptwcjzywswqnw +pujqsixoisvhdvwi +trtuxbgigogfsbbk +mplstsqclhhdyaqk +gzcwflvmstogdpvo +tfjywbkmimyyqcjd +gijutvhruqcsiznq +ibxkhjvzzxgavkha +btnxeqvznkxjsgmq +tjgofgauxaelmjoq +sokshvyhlkxerjrv +ltogbivktqmtezta +uduwytzvqvfluyuf +msuckpthtgzhdxan +fqmcglidvhvpirzr +gwztkqpcwnutvfga +bsjfgsrntdhlpqbx +xloczbqybxmiopwt +orvevzyjliomkkgu +mzjbhmfjjvaziget +tlsdxuhwdmghdyjb +atoecyjhwmznaewi +pyxpyvvipbqibiox +ajbfmpqqobfsmesj +siknbzefjblnohgd +eqfhgewbblwdfkmc +opylbscrotckkrbk +lbwxbofgjkzdxkle +ceixfjstaptdomvm +hnkrqxifjmmjktie +aqykzeuzvvetoygd +fouahjimfcisxima +prkzhutbqsyrhjzx +qqwliakathnsbzne +sayhgqtlcqqidqhj +ygduolbysehdudra +zricvxhdzznuxuce +ucvzakslykpgsixd +udirhgcttmyspgsb +yuwzppjzfsjhhdzi +gtqergjiuwookwre +xvxexbjyjkxovvwf +mlpaqhnnkqxrmwmm +ezuqbrjozwuqafhb +mcarusdthcbsonoq +weeguqeheeiigrue +pngtfugozxofaqxv +copphvbjcmfspenv +jiyahihykjjkdaya +gdqnmesvptuyrfwp +vbdscfywqmfxbohh +crtrfuxyjypzubrg +seihvevtxywxhflp +fvvpmgttnapklwou +qmqaqsajmqwhetpk +zetxvrgjmblxvakr +kpvwblrizaabmnhz +mwpvvzaaicntrkcp +clqyjiegtdsswqfm +ymrcnqgcpldgfwtm +nzyqpdenetncgnwq +cmkzevgacnmdkqro +kzfdsnamjqbeirhi +kpxrvgvvxapqlued +rzskbnfobevzrtqu +vjoahbfwtydugzap +ykbbldkoijlvicbl +mfdmroiztsgjlasb +quoigfyxwtwprmdr +ekxjqafwudgwfqjm +obtvyjkiycxfcdpb +lhoihfnbuqelthof +eydwzitgxryktddt +rxsihfybacnpoyny +bsncccxlplqgygtw +rvmlaudsifnzhcqh +huxwsyjyebckcsnn +gtuqzyihwhqvjtes +zreeyomtngvztveq +nwddzjingsarhkxb +nuqxqtctpoldrlsh +wkvnrwqgjooovhpf +kwgueyiyffudtbyg +tpkzapnjxefqnmew +ludwccvkihagvxal +lfdtzhfadvabghna +njqmlsnrkcfhtvbb +cajzbqleghhnlgap +vmitdcozzvqvzatp +eelzefwqwjiywbcz +uyztcuptfqvymjpi +aorhnrpkjqqtgnfo +lfrxfdrduoeqmwwp +vszpjvbctblplinh +zexhadgpqfifcqrz +ueirfnshekpemqua +qfremlntihbwabtb +nwznunammfexltjc +zkyieokaaogjehwt +vlrxgkpclzeslqkq +xrqrwfsuacywczhs +olghlnfjdiwgdbqc +difnlxnedpqcsrdf +dgpuhiisybjpidsj +vlwmwrikmitmoxbt +sazpcmcnviynoktm +pratafauetiknhln +ilgteekhzwlsfwcn +ywvwhrwhkaubvkbl +qlaxivzwxyhvrxcf +hbtlwjdriizqvjfb +nrmsononytuwslsa +mpxqgdthpoipyhjc +mcdiwmiqeidwcglk +vfbaeavmjjemfrmo +qzcbzmisnynzibrc +shzmpgxhehhcejhb +wirtjadsqzydtyxd +qjlrnjfokkqvnpue +dxawdvjntlbxtuqc +wttfmnrievfestog +eamjfvsjhvzzaobg +pbvfcwzjgxahlrag +omvmjkqqnobvnzkn +lcwmeibxhhlxnkzv +uiaeroqfbvlazegs +twniyldyuonfyzqw +wgjkmsbwgfotdabi +hnomamxoxvrzvtew +ycrcfavikkrxxfgw +isieyodknagzhaxy +mgzdqwikzullzyco +mumezgtxjrrejtrs +nwmwjcgrqiwgfqel +wjgxmebfmyjnxyyp +durpspyljdykvzxf +zuslbrpooyetgafh +kuzrhcjwbdouhyme +wyxuvbciodscbvfm +kbnpvuqwmxwfqtqe +zddzercqogdpxmft +sigrdchxtgavzzjh +lznjolnorbuddgcs +ycnqabxlcajagwbt +bnaudeaexahdgxsj +rlnykxvoctfwanms +jngyetkoplrstfzt +tdpxknwacksotdub +yutqgssfoptvizgr +lzmqnxeqjfnsxmsa +iqpgfsfmukovsdgu +qywreehbidowtjyz +iozamtgusdctvnkw +ielmujhtmynlwcfd +hzxnhtbnmmejlkyf +ftbslbzmiqkzebtd +bcwdqgiiizmohack +dqhfkzeddjzbdlxu +mxopokqffisxosci +vciatxhtuechbylk +khtkhcvelidjdena +blatarwzfqcapkdt +elamngegnczctcck +xeicefdbwrxhuxuf +sawvdhjoeahlgcdr +kmdcimzsfkdfpnir +axjayzqlosrduajb +mfhzreuzzumvoggr +iqlbkbhrkptquldb +xcvztvlshiefuhgb +pkvwyqmyoazocrio +ajsxkdnerbmhyxaj +tudibgsbnpnizvsi +cxuiydkgdccrqvkh +cyztpjesdzmbcpot +nnazphxpanegwitx +uphymczbmjalmsct +yyxiwnlrogyzwqmg +gmqwnahjvvdyhnfa +utolskxpuoheugyl +mseszdhyzoyavepd +ycqknvbuvcjfgmlc +sknrxhxbfpvpeorn +zqxqjetooqcodwml +sesylkpvbndrdhsy +fryuxvjnsvnjrxlw +mfxusewqurscujnu +mbitdjjtgzchvkfv +ozwlyxtaalxofovd +wdqcduaykxbunpie +rlnhykxiraileysk +wgoqfrygttlamobg +kflxzgxvcblkpsbz +tmkisflhativzhde +owsdrfgkaamogjzd +gaupjkvkzavhfnes +wknkurddcknbdleg +lltviwincmbtduap +qwzvspgbcksyzzmb +ydzzkumecryfjgnk +jzvmwgjutxoysaam +icrwpyhxllbardkr +jdopyntshmvltrve +afgkigxcuvmdbqou +mfzzudntmvuyhjzt +duxhgtwafcgrpihc +tsnhrkvponudumeb +sqtvnbeiigdzbjgv +eczmkqwvnsrracuo +mhehsgqwiczaiaxv +kaudmfvifovrimpd +lupikgivechdbwfr +mwaaysrndiutuiqx +aacuiiwgaannunmm +tjqjbftaqitukwzp +lrcqyskykbjpaekn +lirrvofbcqpjzxmr +jurorvzpplyelfml +qonbllojmloykjqe +sllkzqujfnbauuqp +auexjwsvphvikali +usuelbssqmbrkxyc +wyuokkfjexikptvv +wmfedauwjgbrgytl +sfwvtlzzebxzmuvw +rdhqxuechjsjcvaf +kpavhqkukugocsxu +ovnjtumxowbxduts +zgerpjufauptxgat +pevvnzjfwhjxdoxq +pmmfwxajgfziszcs +difmeqvaghuitjhs +icpwjbzcmlcterwm +ngqpvhajttxuegyh +mosjlqswdngwqsmi +frlvgpxrjolgodlu +eazwgrpcxjgoszeg +bbtsthgkjrpkiiyk +tjonoglufuvsvabe +xhkbcrofytmbzrtk +kqftfzdmpbxjynps +kmeqpocbnikdtfyv +qjjymgqxhnjwxxhp +dmgicrhgbngdtmjt +zdxrhdhbdutlawnc +afvoekuhdboxghvx +hiipezngkqcnihty +bbmqgheidenweeov +suprgwxgxwfsgjnx +adeagikyamgqphrj +zzifqinoeqaorjxg +adhgppljizpaxzld +lvxyieypvvuqjiyc +nljoakatwwwoovzn +fcrkfxclcacshhmx +ownnxqtdhqbgthch +lmfylrcdmdkgpwnj +hlwjfbvlswbzpbjr +mkofhdtljdetcyvp +synyxhifbetzarpo +agnggugngadrcxoc +uhttadmdmhidpyjw +ohfwjfhunalbubpr +pzkkkkwrlvxiuysn +kmidbxmyzkjrwjhu +egtitdydwjxmajnw +civoeoiuwtwgbqqs +dfptsguzfinqoslk +tdfvkreormspprer +zvnvbrmthatzztwi +ffkyddccrrfikjde +hrrmraevdnztiwff +qaeygykcpbtjwjbr +purwhitkmrtybslh +qzziznlswjaussel +dfcxkvdpqccdqqxj +tuotforulrrytgyn +gmtgfofgucjywkev +wkyoxudvdkbgpwhd +qbvktvfvipftztnn +otckgmojziezmojb +inxhvzbtgkjxflay +qvxapbiatuudseno +krpvqosbesnjntut +oqeukkgjsfuqkjbb +prcjnyymnqwqksiz +vuortvjxgckresko +orqlyobvkuwgathr +qnpyxlnazyfuijox +zwlblfkoklqmqzkw +hmwurwtpwnrcsanl +jzvxohuakopuzgpf +sfcpnxrviphhvxmx +qtwdeadudtqhbely +dbmkmloasqphnlgj +olylnjtkxgrubmtk +nxsdbqjuvwrrdbpq +wbabpirnpcsmpipw +hjnkyiuxpqrlvims +enzpntcjnxdpuqch +vvvqhlstzcizyimn +triozhqndbttglhv +fukvgteitwaagpzx +uhcvukfbmrvskpen +tizcyupztftzxdmt +vtkpnbpdzsaluczz +wodfoyhoekidxttm +otqocljrmwfqbxzu +linfbsnfvixlwykn +vxsluutrwskslnye +zbshygtwugixjvsi +zdcqwxvwytmzhvoo +wrseozkkcyctrmei +fblgtvogvkpqzxiy +opueqnuyngegbtnf +qxbovietpacqqxok +zacrdrrkohfygddn +gbnnvjqmkdupwzpq +qgrgmsxeotozvcak +hnppukzvzfmlokid +dzbheurndscrrtcl +wbgdkadtszebbrcw +fdmzppzphhpzyuiz +bukomunhrjrypohj +ohodhelegxootqbj +rsplgzarlrknqjyh +punjjwpsxnhpzgvu +djdfahypfjvpvibm +mlgrqsmhaozatsvy +xwktrgyuhqiquxgn +wvfaoolwtkbrisvf +plttjdmguxjwmeqr +zlvvbwvlhauyjykw +cigwkbyjhmepikej +masmylenrusgtyxs +hviqzufwyetyznze +nzqfuhrooswxxhus +pdbdetaqcrqzzwxf +oehmvziiqwkzhzib +icgpyrukiokmytoy +ooixfvwtiafnwkce +rvnmgqggpjopkihs +wywualssrmaqigqk +pdbvflnwfswsrirl +jeaezptokkccpbuj +mbdwjntysntsaaby +ldlgcawkzcwuxzpz +lwktbgrzswbsweht +ecspepmzarzmgpjm +qmfyvulkmkxjncai +izftypvwngiukrns +zgmnyjfeqffbooww +nyrkhggnprhedows +yykzzrjmlevgffah +mavaemfxhlfejfki +cmegmfjbkvpncqwf +zxidlodrezztcrij +fseasudpgvgnysjv +fupcimjupywzpqzp +iqhgokavirrcvyys +wjmkcareucnmfhui +nftflsqnkgjaexhq +mgklahzlcbapntgw +kfbmeavfxtppnrxn +nuhyvhknlufdynvn +nviogjxbluwrcoec +tyozixxxaqiuvoys +kgwlvmvgtsvxojpr +moeektyhyonfdhrb +kahvevmmfsmiiqex +xcywnqzcdqtvhiwd +fnievhiyltbvtvem +jlmndqufirwgtdxd +muypbfttoeelsnbs +rypxzbnujitfwkou +ubmmjbznskildeoj +ofnmizdeicrmkjxp +rekvectjbmdnfcib +yohrojuvdexbctdh +gwfnfdeibynzjmhz +jfznhfcqdwlpjull +scrinzycfhwkmmso +mskutzossrwoqqsi +rygoebkzgyzushhr +jpjqiycflqkexemx +arbufysjqmgaapnl +dbjerflevtgweeoj +snybnnjlmwjvhois +fszuzplntraprmbj +mkvaatolvuggikvg +zpuzuqygoxesnuyc +wnpxvmxvllxalulm +eivuuafkvudeouwy +rvzckdyixetfuehr +qgmnicdoqhveahyx +miawwngyymshjmpj +pvckyoncpqeqkbmx +llninfenrfjqxurv +kzbjnlgsqjfuzqtp +rveqcmxomvpjcwte +bzotkawzbopkosnx +ktqvpiribpypaymu +wvlzkivbukhnvram +uohntlcoguvjqqdo +ajlsiksjrcnzepkt +xsqatbldqcykwusd +ihbivgzrwpmowkop +vfayesfojmibkjpb +uaqbnijtrhvqxjtb +hhovshsfmvkvymba +jerwmyxrfeyvxcgg +hncafjwrlvdcupma +qyvigggxfylbbrzt +hiiixcyohmvnkpgk +mmitpwopgxuftdfu +iaxderqpceboixoa +zodfmjhuzhnsqfcb +sthtcbadrclrazsi +bkkkkcwegvypbrio +wmpcofuvzemunlhj +gqwebiifvqoeynro +juupusqdsvxcpsgv +rbhdfhthxelolyse +kjimpwnjfrqlqhhz +rcuigrjzarzpjgfq +htxcejfyzhydinks +sxucpdxhvqjxxjwf +omsznfcimbcwaxal +gufmtdlhgrsvcosb +bssshaqujtmluerz +uukotwjkstgwijtr +kbqkneobbrdogrxk +ljqopjcjmelgrakz +rwtfnvnzryujwkfb +dedjjbrndqnilbeh +nzinsxnpptzagwlb +lwqanydfirhnhkxy +hrjuzfumbvfccxno +okismsadkbseumnp +sfkmiaiwlktxqvwa +hauwpjjwowbunbjj +nowkofejwvutcnui +bqzzppwoslaeixro +urpfgufwbtzenkpj +xgeszvuqwxeykhef +yxoldvkyuikwqyeq +onbbhxrnmohzskgg +qcikuxakrqeugpoa +lnudcqbtyzhlpers +nxduvwfrgzaailgl +xniuwvxufzxjjrwz +ljwithcqmgvntjdj +awkftfagrfzywkhs +uedtpzxyubeveuek +bhcqdwidbjkqqhzl +iyneqjdmlhowwzxx +kvshzltcrrururty +zgfpiwajegwezupo +tkrvyanujjwmyyri +ercsefuihcmoaiep +ienjrxpmetinvbos +jnwfutjbgenlipzq +bgohjmrptfuamzbz +rtsyamajrhxbcncw +tfjdssnmztvbnscs +bgaychdlmchngqlp +kfjljiobynhwfkjo +owtdxzcpqleftbvn +ltjtimxwstvzwzjj +wbrvjjjajuombokf +zblpbpuaqbkvsxye +gwgdtbpnlhyqspdi +abipqjihjqfofmkx +nlqymnuvjpvvgova +avngotmhodpoufzn +qmdyivtzitnrjuae +xfwjmqtqdljuerxi +csuellnlcyqaaamq +slqyrcurcyuoxquo +dcjmxyzbzpohzprl +uqfnmjwniyqgsowb +rbmxpqoblyxdocqc +ebjclrdbqjhladem +ainnfhxnsgwqnmyo +eyytjjwhvodtzquf +iabjgmbbhilrcyyp +pqfnehkivuelyccc +xgjbyhfgmtseiimt +jwxyqhdbjiqqqeyy +gxsbrncqkmvaryln +vhjisxjkinaejytk +seexagcdmaedpcvh +lvudfgrcpjxzdpvd +fxtegyrqjzhmqean +dnoiseraqcoossmc +nwrhmwwbykvwmgep +udmzskejvizmtlce +hbzvqhvudfdlegaa +cghmlfqejbxewskv +bntcmjqfwomtbwsb +qezhowyopjdyhzng +todzsocdkgfxanbz +zgjkssrjlwxuhwbk +eibzljqsieriyrzr +wamxvzqyycrxotjp +epzvfkispwqynadu +dwlpfhtrafrxlyie +qhgzujhgdruowoug +girstvkahaemmxvh +baitcrqmxhazyhbl +xyanqcchbhkajdmc +gfvjmmcgfhvgnfdq +tdfdbslwncbnkzyz +jojuselkpmnnbcbb +hatdslkgxtqpmavj +dvelfeddvgjcyxkj +gnsofhkfepgwltse +mdngnobasfpewlno +qssnbcyjgmkyuoga +glvcmmjytmprqwvn +gwrixumjbcdffsdl +lozravlzvfqtsuiq +sicaflbqdxbmdlch +inwfjkyyqbwpmqlq +cuvszfotxywuzhzi +igfxyoaacoarlvay +ucjfhgdmnjvgvuni +rvvkzjsytqgiposh +jduinhjjntrmqroz +yparkxbgsfnueyll +lyeqqeisxzfsqzuj +woncskbibjnumydm +lltucklragtjmxtl +ubiyvmyhlesfxotj +uecjseeicldqrqww +xxlxkbcthufnjbnm +lhqijovvhlffpxga +fzdgqpzijitlogjz +efzzjqvwphomxdpd +jvgzvuyzobeazssc +hejfycgxywfjgbfw +yhjjmvkqfbnbliks +sffvfyywtlntsdsz +dwmxqudvxqdenrur +asnukgppdemxrzaz +nwqfnumblwvdpphx +kqsmkkspqvxzuket +cpnraovljzqiquaz +qrzgrdlyyzbyykhg +opoahcbiydyhsmqe +hjknnfdauidjeydr +hczdjjlygoezadow +rtflowzqycimllfv +sfsrgrerzlnychhq +bpahuvlblcolpjmj +albgnjkgmcrlaicl +pijyqdhfxpaxzdex +eeymiddvcwkpbpux +rqwkqoabywgggnln +vckbollyhgbgmgwh +ylzlgvnuvpynybkm +hpmbxtpfosbsjixt +ocebeihnhvkhjfqz +tvctyxoujdgwayze +efvhwxtuhapqxjen +rusksgefyidldmpo +nkmtjvddfmhirmzz +whvtsuadwofzmvrt +iiwjqvsdxudhdzzk +gucirgxaxgcassyo +rmhfasfzexeykwmr +hynlxcvsbgosjbis +huregszrcaocueen +pifezpoolrnbdqtv +unatnixzvdbqeyox +xtawlpduxgacchfe +bdvdbflqfphndduf +xtdsnjnmzccfptyt +nkhsdkhqtzqbphhg +aqcubmfkczlaxiyb +moziflxpsfubucmv +srdgnnjtfehiimqx +pwfalehdfyykrohf +sysxssmvewyfjrve +brsemdzosgqvvlxe +bimbjoshuvflkiat +hkgjasmljkpkwwku +sbnmwjvodygobpqc +bbbqycejueruihhd +corawswvlvneipyc +gcyhknmwsczcxedh +kppakbffdhntmcqp +ynulzwkfaemkcefp +pyroowjekeurlbii +iwksighrswdcnmxf +glokrdmugreygnsg +xkmvvumnfzckryop +aesviofpufygschi +csloawlirnegsssq +fkqdqqmlzuxbkzbc +uzlhzcfenxdfjdzp +poaaidrktteusvyf +zrlyfzmjzfvivcfr +qwjulskbniitgqtx +gjeszjksbfsuejki +vczdejdbfixbduaq +knjdrjthitjxluth +jweydeginrnicirl +bottrfgccqhyycsl +eiquffofoadmbuhk +lbqfutmzoksscswf +xfmdvnvfcnzjprba +uvugkjbkhlaoxmyx +wadlgtpczgvcaqqv +inzrszbtossflsxk +dbzbtashaartczrj +qbjiqpccefcfkvod +hluujmokjywotvzy +thwlliksfztcmwzh +arahybspdaqdexrq +nuojrmsgyipdvwyx +hnajdwjwmzattvst +sulcgaxezkprjbgu +rjowuugwdpkjtypw +oeugzwuhnrgiaqga +wvxnyymwftfoswij +pqxklzkjpcqscvde +tuymjzknntekglqj +odteewktugcwlhln +exsptotlfecmgehc +eeswfcijtvzgrqel +vjhrkiwmunuiwqau +zhlixepkeijoemne +pavfsmwesuvebzdd +jzovbklnngfdmyws +nbajyohtzfeoiixz +ciozmhrsjzrwxvhz +gwucrxieqbaqfjuv +uayrxrltnohexawc +flmrbhwsfbcquffm +gjyabmngkitawlxc +rwwtggvaygfbovhg +xquiegaisynictjq +oudzwuhexrwwdbyy +lengxmguyrwhrebb +uklxpglldbgqsjls +dbmvlfeyguydfsxq +zspdwdqcrmtmdtsc +mqfnzwbfqlauvrgc +amcrkzptgacywvhv +ndxmskrwrqysrndf +mwjyhsufeqhwisju +srlrukoaenyevykt +tnpjtpwawrxbikct +geczalxmgxejulcv +tvkcbqdhmuwcxqci +tiovluvwezwwgaox +zrjhtbgajkjqzmfo +vcrywduwsklepirs +lofequdigsszuioy +wxsdzomkjqymlzat +iabaczqtrfbmypuy +ibdlmudbajikcncr +rqcvkzsbwmavdwnv +ypxoyjelhllhbeog +fdnszbkezyjbttbg +uxnhrldastpdjkdz +xfrjbehtxnlyzcka +omjyfhbibqwgcpbv +eguucnoxaoprszmp +xfpypldgcmcllyzz +aypnmgqjxjqceelv +mgzharymejlafvgf +tzowgwsubbaigdok +ilsehjqpcjwmylxc +pfmouwntfhfnmrwk +csgokybgdqwnduwp +eaxwvxvvwbrovypz +nmluqvobbbmdiwwb +lnkminvfjjzqbmio +mjiiqzycqdhfietz +towlrzriicyraevq +obiloewdvbrsfwjo +lmeooaajlthsfltw +ichygipzpykkesrw +gfysloxmqdsfskvt +saqzntehjldvwtsx +pqddoemaufpfcaew +mjrxvbvwcreaybwe +ngfbrwfqnxqosoai +nesyewxreiqvhald +kqhqdlquywotcyfy +liliptyoqujensfi +nsahsaxvaepzneqq +zaickulfjajhctye +gxjzahtgbgbabtht +koxbuopaqhlsyhrp +jhzejdjidqqtjnwe +dekrkdvprfqpcqki +linwlombdqtdeyop +dvckqqbnigdcmwmx +yaxygbjpzkvnnebv +rlzkdkgaagmcpxah +cfzuyxivtknirqvt +obivkajhsjnrxxhn +lmjhayymgpseuynn +bbjyewkwadaipyju +lmzyhwomfypoftuu +gtzhqlgltvatxack +jfflcfaqqkrrltgq +txoummmnzfrlrmcg +ohemsbfuqqpucups +imsfvowcbieotlok +tcnsnccdszxfcyde +qkcdtkwuaquajazz +arcfnhmdjezdbqku +srnocgyqrlcvlhkb +mppbzvfmcdirbyfw +xiuarktilpldwgwd +ypufwmhrvzqmexpc +itpdnsfkwgrdujmj +cmpxnodtsswkyxkr +wayyxtjklfrmvbfp +mfaxphcnjczhbbwy +sjxhgwdnqcofbdra +pnxmujuylqccjvjm +ivamtjbvairwjqwl +deijtmzgpfxrclss +bzkqcaqagsynlaer +tycefobvxcvwaulz +ctbhnywezxkdsswf +urrxxebxrthtjvib +fpfelcigwqwdjucv +ngfcyyqpqulwcphb +rltkzsiipkpzlgpw +qfdsymzwhqqdkykc +balrhhxipoqzmihj +rnwalxgigswxomga +ghqnxeogckshphgr +lyyaentdizaumnla +exriodwfzosbeoib +speswfggibijfejk +yxmxgfhvmshqszrq +hcqhngvahzgawjga +qmhlsrfpesmeksur +eviafjejygakodla +kvcfeiqhynqadbzv +fusvyhowslfzqttg +girqmvwmcvntrwau +yuavizroykfkdekz +jmcwohvmzvowrhxf +kzimlcpavapynfue +wjudcdtrewfabppq +yqpteuxqgbmqfgxh +xdgiszbuhdognniu +jsguxfwhpftlcjoh +whakkvspssgjzxre +ggvnvjurlyhhijgm +krvbhjybnpemeptr +pqedgfojyjybfbzr +jzhcrsgmnkwwtpdo +yyscxoxwofslncmp +gzjhnxytmyntzths +iteigbnqbtpvqumi +zjevfzusnjukqpfw +xippcyhkfuounxqk +mcnhrcfonfdgpkyh +pinkcyuhjkexbmzj +lotxrswlxbxlxufs +fmqajrtoabpckbnu +wfkwsgmcffdgaqxg +qfrsiwnohoyfbidr +czfqbsbmiuyusaqs +ieknnjeecucghpoo +cevdgqnugupvmsge +gjkajcyjnxdrtuvr +udzhrargnujxiclq +zqqrhhmjwermjssg +ggdivtmgoqajydzz +wnpfsgtxowkjiivl +afbhqawjbotxnqpd +xjpkifkhfjeqifdn +oyfggzsstfhvticp +kercaetahymeawxy +khphblhcgmbupmzt +iggoqtqpvaebtiol +ofknifysuasshoya +qxuewroccsbogrbv +apsbnbkiopopytgu +zyahfroovfjlythh +bxhjwfgeuxlviydq +uvbhdtvaypasaswa +qamcjzrmesqgqdiz +hjnjyzrxntiycyel +wkcrwqwniczwdxgq +hibxlvkqakusswkx +mzjyuenepwdgrkty +tvywsoqslfsulses +jqwcwuuisrclircv +xanwaoebfrzhurct +ykriratovsvxxasf +qyebvtqqxbjuuwuo +telrvlwvriylnder +acksrrptgnhkeiaa +yemwfjhiqlzsvdxf +banrornfkcymmkcc +ytbhxvaeiigjpcgm +crepyazgxquposkn +xlqwdrytzwnxzwzv +xtrbfbwopxscftps +kwbytzukgseeyjla +qtfdvavvjogybxjg +ytbmvmrcxwfkgvzw +nbscbdskdeocnfzr +sqquwjbdxsxhcseg +ewqxhigqcgszfsuw +cvkyfcyfmubzwsee +dcoawetekigxgygd +ohgqnqhfimyuqhvi +otisopzzpvnhctte +bauieohjejamzien +ewnnopzkujbvhwce +aeyqlskpaehagdiv +pncudvivwnnqspxy +ytugesilgveokxcg +zoidxeelqdjesxpr +ducjccsuaygfchzj +smhgllqqqcjfubfc +nlbyyywergronmir +prdawpbjhrzsbsvj +nmgzhnjhlpcplmui +eflaogtjghdjmxxz +qolvpngucbkprrdc +ixywxcienveltgho +mwnpqtocagenkxut +iskrfbwxonkguywx +ouhtbvcaczqzmpua +srewprgddfgmdbao +dyufrltacelchlvu +czmzcbrkecixuwzz +dtbeojcztzauofuk +prrgoehpqhngfgmw +baolzvfrrevxsyke +zqadgxshwiarkzwh +vsackherluvurqqj +surbpxdulvcvgjbd +wqxytarcxzgxhvtx +vbcubqvejcfsgrac +zqnjfeapshjowzja +hekvbhtainkvbynx +knnugxoktxpvoxnh +knoaalcefpgtvlwm +qoakaunowmsuvkus +ypkvlzcduzlezqcb +ujhcagawtyepyogh +wsilcrxncnffaxjf +gbbycjuscquaycrk +aduojapeaqwivnly +ceafyxrakviagcjy +nntajnghicgnrlst +vdodpeherjmmvbje +wyyhrnegblwvdobn +xlfurpghkpbzhhif +xyppnjiljvirmqjo +kglzqahipnddanpi +omjateouxikwxowr +ocifnoopfglmndcx +emudcukfbadyijev +ooktviixetfddfmh +wtvrhloyjewdeycg +cgjncqykgutfjhvb +nkwvpswppeffmwad +hqbcmfhzkxmnrivg +mdskbvzguxvieilr +anjcvqpavhdloaqh +erksespdevjylenq +fadxwbmisazyegup +iyuiffjmcaahowhj +ygkdezmynmltodbv +fytneukxqkjattvh +woerxfadbfrvdcnz +iwsljvkyfastccoa +movylhjranlorofe +drdmicdaiwukemep +knfgtsmuhfcvvshg +ibstpbevqmdlhajn +tstwsswswrxlzrqs +estyydmzothggudf +jezogwvymvikszwa +izmqcwdyggibliet +nzpxbegurwnwrnca +kzkojelnvkwfublh +xqcssgozuxfqtiwi +tcdoigumjrgvczfv +ikcjyubjmylkwlwq +kqfivwystpqzvhan +bzukgvyoqewniivj +iduapzclhhyfladn +fbpyzxdfmkrtfaeg +yzsmlbnftftgwadz diff --git a/2015/rs/src/four.rs b/2015/rs/src/four.rs new file mode 100644 index 0000000..177ddc5 --- /dev/null +++ b/2015/rs/src/four.rs @@ -0,0 +1,46 @@ +use md5::{Digest, Md5}; +use std::fmt::Write; +use std::io::Write as WriteI; + +static INPUT: &'static [u8] = b"yzbqklnj"; + +fn main() { + let mut buf = Vec::with_capacity(INPUT.len() + 10); + buf.extend_from_slice(INPUT); + + for i in 0.. { + if i % 1000 == 0 { print!("{i}\r"); std::io::stdout().flush(); } + + let mut hasher = Md5::new(); + write!(&mut buf, "{i}"); + hasher.update(buf.as_slice()); + let hash = hasher.finalize(); + if hash.starts_with(&[0, 0]) && hash[2] < 16 { + let mut hexhash = String::with_capacity(32); + for digit in hash { + write!(&mut hexhash, "{digit:02x}"); + } + println!("Got 5 digit hash: {hexhash}, at {i}"); + break; + } + buf.truncate(INPUT.len()); + } + + for i in 0.. { + if i % 1000 == 0 { print!("{i}\r"); std::io::stdout().flush(); } + + let mut hasher = Md5::new(); + write!(&mut buf, "{i}"); + hasher.update(buf.as_slice()); + let hash = hasher.finalize(); + if hash.starts_with(&[0, 0, 0]) { + let mut hexhash = String::with_capacity(32); + for digit in hash { + write!(&mut hexhash, "{digit:02x}"); + } + println!("Got 6 digit hash: {hexhash}, at {i}"); + break; + } + buf.truncate(INPUT.len()); + } +} diff --git a/2015/rs/src/one.rs b/2015/rs/src/one.rs new file mode 100644 index 0000000..c23c1bd --- /dev/null +++ b/2015/rs/src/one.rs @@ -0,0 +1,11 @@ +static INPUT: &'static str = include_str!("one.txt"); + +fn main() { + let valueified = INPUT.chars().map(|c| match c { '(' => 1, ')' => -1, _ => 0}); + let floor_number: i32 = valueified.clone().sum(); + println!("Floor number: {floor_number}"); + + let mut floor = 0; + let basement_index = valueified.take_while(|i| {floor += i; floor >= 0}).count() + 1; + println!("First character in basement: {basement_index}"); +} diff --git a/2015/rs/src/one.txt b/2015/rs/src/one.txt new file mode 100644 index 0000000..2d4ad8f --- /dev/null +++ b/2015/rs/src/one.txt @@ -0,0 +1 @@ +()(((()))(()()()((((()(((())(()(()((((((()(()(((())))((()(((()))((())(()((()()()()(((())(((((((())))()()(()(()(())(((((()()()((())(((((()()))))()(())(((())(())((((((())())))(()())))()))))()())()())((()()((()()()()(()((((((((()()())((()()(((((()(((())((())(()))()((((()((((((((())()((()())(())((()))())((((()())(((((((((((()()(((((()(()))())(((()(()))())((()(()())())())(()(((())(())())()()(()(()((()))((()))))((((()(((()))))((((()(()(()())())()(((()((((())((((()(((()()(())()()()())((()((((((()((()()))()((()))()(()()((())))(((()(((()))((()((()(()))(((()()(()(()()()))))()()(((()(((())())))))((()(((())()(()(())((()())))((((())))(()(()(()())()((()())))(((()((()(())()()((()((())(()()((())(())()))()))((()(())()))())(((((((()(()()(()(())())))))))(()((((((())((((())((())())(()()))))()(())(()())()())((())(()))))(()))(()((()))()(()((((((()()()()((((((((()(()(())((()()(()()))(())()())()((())))()))()())(((()))(())()(())()))()((()((()(()()())(())()()()((())())))((()()(()()((()(())()()())(((()(()()))))(())))(()(()())()))()()))))))()))))((((((())))())))(()(())())(()())))))(()))()))))))()((()))))()))))(()(()((()())())(()()))))(((())()))())())())(((()(()()))(())()(())(())((((((()()))))((()(()))))))(()))())(((()()(()))()())()()()())))))))))))))(())(()))(()))((()(())(()())(())())(()())(())()()(()())))()()()))(())())()))())())(())((())))))))(())))(())))))()))))((())(()(((()))))(()))()((()(())))(()())(((((()))()())()()))))()))))()))())(()(()()()))()))))))((()))))))))))()((()))((()(())((())()()(()()))()(()))))()()(()))()))(((())))(())()((())(())(()())()())())))))))())))()((())))()))(()))()()))(((((((()))())(()()))(()()(()))()(()((()())()))))))(((()()()())))(())()))()())(()()))()()))))))))(())))()))()()))))))()))()())))()(())(())))))()(())()()(()()))))())((()))))()))))(()(((((()))))))))())))())()(())()()))))(())))())()()())()()())()(()))))()))()))))))))())))((()))()))()))())))()())()()())))())))(()((())()((()))())))))())()(())((())))))))))))())()())(())())())(()))(()))()))())(()(())())()())()()(()))))(()(())))))))(())))())(())))))))())()()(())())())))(())))))()))()(()())()(()))())())))))()()(()))()))))())))))))))()))))()))))))())()())()()))))()())))())))))))))))()()))))()()(((()))()()(())()))))((()))))(()))(())())))(())()))))))(()))()))))(())())))))()))(()())))))))))))))())))))))))()((()())(()())))))))((()))))(())(())))()(()())())))())())(()()()())))()))))))())))))())()()())))))))))))()()(()))))()())()))((()())(()))))()(()))))))))))()())())(((())(()))))())()))()))()))))))()))))))(()))))()))))()(())))(())))(()))())()()(()()))()))(()()))))))))()))(()))())(()()(()(()())()()))()))))))))(())))))((()()(()))())())))))()))())(()())()()))())))()(()()()()))((())())))())()(()()))()))))))))(()))(())))()))))(()(()())(()))))()())())()))()()))())))))))))))())()))))))()))))))))())))))()))))())(()())))(())()))())())))))()()(()()())(()())))()()))(((()))(()()()))))()))))()))))((())))()((((((()()))))))())))))))))))(((()))))))))))))(())())))))())(()))))))(()))((()))())))()(()((()))()))()))))))))))())()))()(()()))))())))())(())()(()))()))())(()))()))))(()()))()()(())))))()))(())(()(()()))(()()())))))(((()))))))()))))))))))))(())(()))))()())())()()((()()))())))))(()))))())))))))()()()))))))))())))()(((()()))(())))))(((())())))))((()))()(()))(()))))(()())))(()))())))))()))))(())(())))()((()))(())())))()()))()))))))))()))(()()()(()()()(()))())(())()())(((()))(())))))))))(((()())))()()))))))))()(())(()))()((((())(())(()())))()))(((())()()()))((()))(()))())())))())))(()))())()())())(()(())())()()()(())))())(())))(())))(())()))()))(()((()))))))))())(()))))))())(()()))()()))()(()(()())))()()(()((()((((((()))(())))()()()))())()))((()()(()))())((()(()(()))(()()))))()())))()))()())))))))()()((()())(())))()))(()))(())(()))())(()(())))()()))))))(((()(((()()))()(()(())())((()()))()))()))()))()(()()()(()))((()())()(())))()()))(((())()()())(())()((()()()()(()(())(()()))()(((((()())))((())))))(()()()))))(((()(())))()))((()((()(())()(()((())))((()())()(()))(((()())()()(()))(())(((()((()())()((())()())(((()()))((()((())(()))(()())(()()()))((()))(())(()((()()())((()))(())))(())(())(())))(()())))(((((()(()(((((()())((((()(()())(())(()()(((())((()(((()()(((()()((((((())))())(()((((((()(()))()))()()((()((()))))()(()()(()((()()))))))(((((()(((((())()()()(())())))))))()))((()()(())))(())(()()()())))))(()((((())))))))()()(((()(()(()(()(()())()()()(((((((((()()())()(()))((()()()()()(((((((()())()((())()))((((((()(()(()(()())(((()(((((((()(((())(((((((((())(())())()))((()(()))(((()()())(())(()(()()(((()(())()))())))(())((((((())(()()())()()(((()(((())(()(((())(((((((()(((((((((()))(())(()(()(()))))((()))()(())())())((()(()((()()))((()()((()(())(())(()((())(((())(((()()()((((((()()(())((((())()))))(())((()(()((())))(((((()(()()())())((())())))((())((()((()()((((((())(((()()(()())())(()(()))(()(()))())())()(((((((()(((()(())()()((())((()(()()((()(()()(((((((((((())((())((((((())((()((((()(()((((()(((((((())()((()))))())()((()((((()(()(((()((()())))(())())(((()(((())((((((()(((((((((()()(())))(()(((((()((((()())))((()((()((()(()()(((())((((((((((((()(((())(()(((((()))(()()(()()()()()()((())(((((((())(((((())))))())()(()()(()(()(((()()(((((())(()((()((()(((()()((()((((())()))()((((())(())))()())(((())(())(()()((()(((()()((((((((((()()(()())())(((((((((())((((()))()()((((())(()((((()(((())())(((((((((((()((((())))(())(()(((()(((()((())(((((()((()()(()(()()((((((()((((()((()(()((()(()((((((()))))()()(((((()((()(()(())()))(())(((((((()((((()())(()((()((()(()))())))(())((()))))(((((((()()()())(()))(()()((()())()((()((()()()(()(()()))(()())(())(((((()(((((((((((()((()(((()(((((((()()((((((()(((((()(()((()(((((())((((((()))((((())((()()((())(((())()(((((()()(((((()((()(()(((((((()(((((()((()((()((())(())((())(()))()()))(()()(()(()()(((((((()(((()(((())()(((((()((((((()())((((())()((()((()(()()())(()))((((()()((((((()((()(()(()((((()((()((())((((((()(()(())((((((()((((((((((()((())()))()(()(()(((((()()()))((())))()(()((((((((((((((()(((()((((()((())((()((()(((()()(()(((()((())(()()())))()(()(()(((((()()(()(()((((()(((((())()(()(()))(((((()()(((()()(())((((((((((((((())((())(((((((((((())()()()(())()(()(()(((((((((())(((()))(()()())(()((((()(())(((((()())(())((((((((())()((((()((((((())(()((()(())(((()((((()))(((((((((()()))((((()(())()()()(())(()((())((()()))()(((())(((((())((((((()()))(((((((((()((((((())))(((((((()((()(()(())))())(()(()))()(((((()())(()))()(()(())(((()))))())()())))(((((()))())()((()(()))))((()()()((((((()))()()((((((((())((()(()(((()(()((())((()())(()((((())(()(((()()()(()(()()))())())((((((((((())())((()))()((())(())(())))())()(()()(())))())(()))(((()(()()(((()(((())))()(((()(())()((((((())()))()))()((((((()(()(((((()())))()))))())()()(((()(((((())((()()(()((()((()(()(()(())))(()()()()((()(())(((()((()))((((()))())(())))())(()))()()()())()))(((()()())()((())))(())(()()()()(()())((()(()()((((())))((()((()(())((()(()((())()(()()(((()())()()())((()))((())(((()()(())))()()))(((()((())()(((((()())(())((())()())())((((((()(()(((((()))(()( diff --git a/2015/rs/src/seven.rs b/2015/rs/src/seven.rs new file mode 100644 index 0000000..7d44f0e --- /dev/null +++ b/2015/rs/src/seven.rs @@ -0,0 +1,94 @@ +use std::collections::HashMap; + +static INPUT: &[u8] = include_bytes!("seven.txt"); + +#[derive(Debug, Copy, Clone)] +enum WireOrLiteral { + Wire([u8; 2]), + Literal(u16) +} + +#[derive(Debug, Copy, Clone)] +enum Connection { + Direct(WireOrLiteral), + Not (WireOrLiteral), + And (WireOrLiteral, WireOrLiteral), + Or (WireOrLiteral, WireOrLiteral), + LShift(WireOrLiteral, WireOrLiteral), + RShift(WireOrLiteral, WireOrLiteral), +} + +#[derive(Debug, Copy, Clone)] +enum Cache { + Cached(u16), + Uncached(Connection) +} + +fn main() { + let valueified = INPUT + .split(|b| *b == b'\n').filter(|b| !b.is_empty()) + .map(|line| { + let mut bits = line.split(|b| *b == b'-'); + let (rhs, lhs) = (bits.next().unwrap().strip_suffix(b" ").unwrap(), bits.next().unwrap().strip_prefix(b"> ").unwrap()); + let mut cmdbits = rhs.split(|b| *b == b' '); + let cmdbits = (cmdbits.next().unwrap(), cmdbits.next().unwrap_or(&[]), cmdbits.next().unwrap_or(&[])); + + let connection = match cmdbits { + (wol, &[], &[]) => Connection::Direct(parse_wol(wol)), + (b"NOT", wol, &[]) => Connection::Not(parse_wol(wol)), + (wol1, b"AND", wol2) => Connection::And(parse_wol(wol1), parse_wol(wol2)), + (wol1, b"OR", wol2) => Connection::Or(parse_wol(wol1), parse_wol(wol2)), + (wol1, b"LSHIFT", wol2) => Connection::LShift(parse_wol(wol1), parse_wol(wol2)), + (wol1, b"RSHIFT", wol2) => Connection::RShift(parse_wol(wol1), parse_wol(wol2)), + _ => unreachable!() + }; + + let wire = [lhs[0], *lhs.get(1).unwrap_or(&0)]; + + (wire, Cache::Uncached(connection)) + }) + .collect::<HashMap<[u8; 2], Cache>>(); + + let mut part1 = valueified.clone(); + let a_val = walk(*b"a\0", &mut part1); + println!("a: {a_val}"); + + + let mut part2 = valueified.clone(); + part2.insert(*b"b\0", Cache::Uncached(Connection::Direct(WireOrLiteral::Literal(a_val)))); + let a_val_2 = walk(*b"a\0", &mut part2); + println!("a with b={a_val}: {a_val_2}"); +} + +fn parse_wol(bytes: &[u8]) -> WireOrLiteral { + if bytes.iter().all(u8::is_ascii_digit) { + WireOrLiteral::Literal(std::str::from_utf8(bytes).unwrap().parse().unwrap()) + } else { + WireOrLiteral::Wire([bytes[0], *bytes.get(1).unwrap_or(&0)]) + } +} + +fn walk(key: [u8; 2], map: &mut HashMap<[u8; 2], Cache>) -> u16 { + match map[&key] { + Cache::Cached(val) => val, + Cache::Uncached(conn) => { + let val = match conn { + Connection::Direct(wol) => get_wol(wol, map), + Connection::Not(wol) => !get_wol(wol, map), + Connection::And(wol1, wol2) => get_wol(wol1, map) & get_wol(wol2, map), + Connection::Or(wol1, wol2) => get_wol(wol1, map) | get_wol(wol2, map), + Connection::LShift(wol1, wol2) => get_wol(wol1, map) << get_wol(wol2, map), + Connection::RShift(wol1, wol2) => get_wol(wol1, map) >> get_wol(wol2, map) + }; + map.insert(key, Cache::Cached(val)); + val + } + } +} + +fn get_wol(wol: WireOrLiteral, map: &mut HashMap<[u8; 2], Cache>) -> u16 { + match wol { + WireOrLiteral::Wire(wire) => walk(wire, map), + WireOrLiteral::Literal(literal) => literal + } +} diff --git a/2015/rs/src/seven.txt b/2015/rs/src/seven.txt new file mode 100644 index 0000000..56cae92 --- /dev/null +++ b/2015/rs/src/seven.txt @@ -0,0 +1,339 @@ +af AND ah -> ai +NOT lk -> ll +hz RSHIFT 1 -> is +NOT go -> gp +du OR dt -> dv +x RSHIFT 5 -> aa +at OR az -> ba +eo LSHIFT 15 -> es +ci OR ct -> cu +b RSHIFT 5 -> f +fm OR fn -> fo +NOT ag -> ah +v OR w -> x +g AND i -> j +an LSHIFT 15 -> ar +1 AND cx -> cy +jq AND jw -> jy +iu RSHIFT 5 -> ix +gl AND gm -> go +NOT bw -> bx +jp RSHIFT 3 -> jr +hg AND hh -> hj +bv AND bx -> by +er OR es -> et +kl OR kr -> ks +et RSHIFT 1 -> fm +e AND f -> h +u LSHIFT 1 -> ao +he RSHIFT 1 -> hx +eg AND ei -> ej +bo AND bu -> bw +dz OR ef -> eg +dy RSHIFT 3 -> ea +gl OR gm -> gn +da LSHIFT 1 -> du +au OR av -> aw +gj OR gu -> gv +eu OR fa -> fb +lg OR lm -> ln +e OR f -> g +NOT dm -> dn +NOT l -> m +aq OR ar -> as +gj RSHIFT 5 -> gm +hm AND ho -> hp +ge LSHIFT 15 -> gi +jp RSHIFT 1 -> ki +hg OR hh -> hi +lc LSHIFT 1 -> lw +km OR kn -> ko +eq LSHIFT 1 -> fk +1 AND am -> an +gj RSHIFT 1 -> hc +aj AND al -> am +gj AND gu -> gw +ko AND kq -> kr +ha OR gz -> hb +bn OR by -> bz +iv OR jb -> jc +NOT ac -> ad +bo OR bu -> bv +d AND j -> l +bk LSHIFT 1 -> ce +de OR dk -> dl +dd RSHIFT 1 -> dw +hz AND ik -> im +NOT jd -> je +fo RSHIFT 2 -> fp +hb LSHIFT 1 -> hv +lf RSHIFT 2 -> lg +gj RSHIFT 3 -> gl +ki OR kj -> kk +NOT ak -> al +ld OR le -> lf +ci RSHIFT 3 -> ck +1 AND cc -> cd +NOT kx -> ky +fp OR fv -> fw +ev AND ew -> ey +dt LSHIFT 15 -> dx +NOT ax -> ay +bp AND bq -> bs +NOT ii -> ij +ci AND ct -> cv +iq OR ip -> ir +x RSHIFT 2 -> y +fq OR fr -> fs +bn RSHIFT 5 -> bq +0 -> c +14146 -> b +d OR j -> k +z OR aa -> ab +gf OR ge -> gg +df OR dg -> dh +NOT hj -> hk +NOT di -> dj +fj LSHIFT 15 -> fn +lf RSHIFT 1 -> ly +b AND n -> p +jq OR jw -> jx +gn AND gp -> gq +x RSHIFT 1 -> aq +ex AND ez -> fa +NOT fc -> fd +bj OR bi -> bk +as RSHIFT 5 -> av +hu LSHIFT 15 -> hy +NOT gs -> gt +fs AND fu -> fv +dh AND dj -> dk +bz AND cb -> cc +dy RSHIFT 1 -> er +hc OR hd -> he +fo OR fz -> ga +t OR s -> u +b RSHIFT 2 -> d +NOT jy -> jz +hz RSHIFT 2 -> ia +kk AND kv -> kx +ga AND gc -> gd +fl LSHIFT 1 -> gf +bn AND by -> ca +NOT hr -> hs +NOT bs -> bt +lf RSHIFT 3 -> lh +au AND av -> ax +1 AND gd -> ge +jr OR js -> jt +fw AND fy -> fz +NOT iz -> ja +c LSHIFT 1 -> t +dy RSHIFT 5 -> eb +bp OR bq -> br +NOT h -> i +1 AND ds -> dt +ab AND ad -> ae +ap LSHIFT 1 -> bj +br AND bt -> bu +NOT ca -> cb +NOT el -> em +s LSHIFT 15 -> w +gk OR gq -> gr +ff AND fh -> fi +kf LSHIFT 15 -> kj +fp AND fv -> fx +lh OR li -> lj +bn RSHIFT 3 -> bp +jp OR ka -> kb +lw OR lv -> lx +iy AND ja -> jb +dy OR ej -> ek +1 AND bh -> bi +NOT kt -> ku +ao OR an -> ap +ia AND ig -> ii +NOT ey -> ez +bn RSHIFT 1 -> cg +fk OR fj -> fl +ce OR cd -> cf +eu AND fa -> fc +kg OR kf -> kh +jr AND js -> ju +iu RSHIFT 3 -> iw +df AND dg -> di +dl AND dn -> do +la LSHIFT 15 -> le +fo RSHIFT 1 -> gh +NOT gw -> gx +NOT gb -> gc +ir LSHIFT 1 -> jl +x AND ai -> ak +he RSHIFT 5 -> hh +1 AND lu -> lv +NOT ft -> fu +gh OR gi -> gj +lf RSHIFT 5 -> li +x RSHIFT 3 -> z +b RSHIFT 3 -> e +he RSHIFT 2 -> hf +NOT fx -> fy +jt AND jv -> jw +hx OR hy -> hz +jp AND ka -> kc +fb AND fd -> fe +hz OR ik -> il +ci RSHIFT 1 -> db +fo AND fz -> gb +fq AND fr -> ft +gj RSHIFT 2 -> gk +cg OR ch -> ci +cd LSHIFT 15 -> ch +jm LSHIFT 1 -> kg +ih AND ij -> ik +fo RSHIFT 3 -> fq +fo RSHIFT 5 -> fr +1 AND fi -> fj +1 AND kz -> la +iu AND jf -> jh +cq AND cs -> ct +dv LSHIFT 1 -> ep +hf OR hl -> hm +km AND kn -> kp +de AND dk -> dm +dd RSHIFT 5 -> dg +NOT lo -> lp +NOT ju -> jv +NOT fg -> fh +cm AND co -> cp +ea AND eb -> ed +dd RSHIFT 3 -> df +gr AND gt -> gu +ep OR eo -> eq +cj AND cp -> cr +lf OR lq -> lr +gg LSHIFT 1 -> ha +et RSHIFT 2 -> eu +NOT jh -> ji +ek AND em -> en +jk LSHIFT 15 -> jo +ia OR ig -> ih +gv AND gx -> gy +et AND fe -> fg +lh AND li -> lk +1 AND io -> ip +kb AND kd -> ke +kk RSHIFT 5 -> kn +id AND if -> ig +NOT ls -> lt +dw OR dx -> dy +dd AND do -> dq +lf AND lq -> ls +NOT kc -> kd +dy AND ej -> el +1 AND ke -> kf +et OR fe -> ff +hz RSHIFT 5 -> ic +dd OR do -> dp +cj OR cp -> cq +NOT dq -> dr +kk RSHIFT 1 -> ld +jg AND ji -> jj +he OR hp -> hq +hi AND hk -> hl +dp AND dr -> ds +dz AND ef -> eh +hz RSHIFT 3 -> ib +db OR dc -> dd +hw LSHIFT 1 -> iq +he AND hp -> hr +NOT cr -> cs +lg AND lm -> lo +hv OR hu -> hw +il AND in -> io +NOT eh -> ei +gz LSHIFT 15 -> hd +gk AND gq -> gs +1 AND en -> eo +NOT kp -> kq +et RSHIFT 5 -> ew +lj AND ll -> lm +he RSHIFT 3 -> hg +et RSHIFT 3 -> ev +as AND bd -> bf +cu AND cw -> cx +jx AND jz -> ka +b OR n -> o +be AND bg -> bh +1 AND ht -> hu +1 AND gy -> gz +NOT hn -> ho +ck OR cl -> cm +ec AND ee -> ef +lv LSHIFT 15 -> lz +ks AND ku -> kv +NOT ie -> if +hf AND hl -> hn +1 AND r -> s +ib AND ic -> ie +hq AND hs -> ht +y AND ae -> ag +NOT ed -> ee +bi LSHIFT 15 -> bm +dy RSHIFT 2 -> dz +ci RSHIFT 2 -> cj +NOT bf -> bg +NOT im -> in +ev OR ew -> ex +ib OR ic -> id +bn RSHIFT 2 -> bo +dd RSHIFT 2 -> de +bl OR bm -> bn +as RSHIFT 1 -> bl +ea OR eb -> ec +ln AND lp -> lq +kk RSHIFT 3 -> km +is OR it -> iu +iu RSHIFT 2 -> iv +as OR bd -> be +ip LSHIFT 15 -> it +iw OR ix -> iy +kk RSHIFT 2 -> kl +NOT bb -> bc +ci RSHIFT 5 -> cl +ly OR lz -> ma +z AND aa -> ac +iu RSHIFT 1 -> jn +cy LSHIFT 15 -> dc +cf LSHIFT 1 -> cz +as RSHIFT 3 -> au +cz OR cy -> da +kw AND ky -> kz +lx -> a +iw AND ix -> iz +lr AND lt -> lu +jp RSHIFT 5 -> js +aw AND ay -> az +jc AND je -> jf +lb OR la -> lc +NOT cn -> co +kh LSHIFT 1 -> lb +1 AND jj -> jk +y OR ae -> af +ck AND cl -> cn +kk OR kv -> kw +NOT cv -> cw +kl AND kr -> kt +iu OR jf -> jg +at AND az -> bb +jp RSHIFT 2 -> jq +iv AND jb -> jd +jn OR jo -> jp +x OR ai -> aj +ba AND bc -> bd +jl OR jk -> jm +b RSHIFT 1 -> v +o AND q -> r +NOT p -> q +k AND m -> n +as RSHIFT 2 -> at diff --git a/2015/rs/src/six.rs b/2015/rs/src/six.rs new file mode 100644 index 0000000..0fe0d2d --- /dev/null +++ b/2015/rs/src/six.rs @@ -0,0 +1,57 @@ +static INPUT: &'static str = include_str!("six.txt"); + +#[derive(Debug)] +enum LightCommand { + TurnOff, + TurnOn, + Toggle +} + +fn main() { + let valueified = INPUT.split('\n').filter(|s| !s.is_empty()).map(|s| { + let mut rsplit = s.rsplit(' '); + let mut cd = rsplit.next().unwrap().split(',').map(str::parse::<usize>).map(Result::unwrap); + let mut ab = rsplit.nth(1).unwrap().split(',').map(str::parse::<usize>).map(Result::unwrap); + let ab = (ab.next().unwrap(), ab.next().unwrap()); + let cd = (cd.next().unwrap(), cd.next().unwrap()); + match &s[0..7] { + "turn on" => (LightCommand::TurnOn, ab,cd), + "toggle " => (LightCommand::Toggle, ab,cd), + "turn of" => (LightCommand::TurnOff, ab,cd), + _ => unreachable!() + } + }); + + let mut lights = vec![false; 1_000_000]; + for (cmd, (x1, y1), (x2, y2)) in valueified.clone() { + use LightCommand::*; + for x in x1..=x2 { + for y in y1..=y2 { + match cmd { + TurnOff => { lights[x + y * 1000] = false; }, + TurnOn => { lights[x + y * 1000] = true; }, + Toggle => { lights[x + y * 1000] = !lights[x + y * 1000]; } + } + } + } + } + let light_count = lights.into_iter().filter(|a| *a).count(); + println!("Lit light count: {light_count}"); + + let mut lights = vec![0u64; 1_000_000]; + for (cmd, (x1, y1), (x2, y2)) in valueified { + use LightCommand::*; + for x in x1..=x2 { + for y in y1..=y2 { + match cmd { + TurnOff if lights[x + y * 1000] != 0 => { lights[x + y * 1000] -= 1; }, + TurnOn => { lights[x + y * 1000] += 1; }, + Toggle => { lights[x + y * 1000] += 2 }, + _ => () + } + } + } + } + let light_count = lights.into_iter().sum::<u64>(); + println!("Lit light count(Ancient Nordic Elvish): {light_count}"); +} diff --git a/2015/rs/src/six.txt b/2015/rs/src/six.txt new file mode 100644 index 0000000..c4357c6 --- /dev/null +++ b/2015/rs/src/six.txt @@ -0,0 +1,300 @@ +turn on 887,9 through 959,629 +turn on 454,398 through 844,448 +turn off 539,243 through 559,965 +turn off 370,819 through 676,868 +turn off 145,40 through 370,997 +turn off 301,3 through 808,453 +turn on 351,678 through 951,908 +toggle 720,196 through 897,994 +toggle 831,394 through 904,860 +toggle 753,664 through 970,926 +turn off 150,300 through 213,740 +turn on 141,242 through 932,871 +toggle 294,259 through 474,326 +toggle 678,333 through 752,957 +toggle 393,804 through 510,976 +turn off 6,964 through 411,976 +turn off 33,572 through 978,590 +turn on 579,693 through 650,978 +turn on 150,20 through 652,719 +turn off 782,143 through 808,802 +turn off 240,377 through 761,468 +turn off 899,828 through 958,967 +turn on 613,565 through 952,659 +turn on 295,36 through 964,978 +toggle 846,296 through 969,528 +turn off 211,254 through 529,491 +turn off 231,594 through 406,794 +turn off 169,791 through 758,942 +turn on 955,440 through 980,477 +toggle 944,498 through 995,928 +turn on 519,391 through 605,718 +toggle 521,303 through 617,366 +turn off 524,349 through 694,791 +toggle 391,87 through 499,792 +toggle 562,527 through 668,935 +turn off 68,358 through 857,453 +toggle 815,811 through 889,828 +turn off 666,61 through 768,87 +turn on 27,501 through 921,952 +turn on 953,102 through 983,471 +turn on 277,552 through 451,723 +turn off 64,253 through 655,960 +turn on 47,485 through 734,977 +turn off 59,119 through 699,734 +toggle 407,898 through 493,955 +toggle 912,966 through 949,991 +turn on 479,990 through 895,990 +toggle 390,589 through 869,766 +toggle 593,903 through 926,943 +toggle 358,439 through 870,528 +turn off 649,410 through 652,875 +turn on 629,834 through 712,895 +toggle 254,555 through 770,901 +toggle 641,832 through 947,850 +turn on 268,448 through 743,777 +turn off 512,123 through 625,874 +turn off 498,262 through 930,811 +turn off 835,158 through 886,242 +toggle 546,310 through 607,773 +turn on 501,505 through 896,909 +turn off 666,796 through 817,924 +toggle 987,789 through 993,809 +toggle 745,8 through 860,693 +toggle 181,983 through 731,988 +turn on 826,174 through 924,883 +turn on 239,228 through 843,993 +turn on 205,613 through 891,667 +toggle 867,873 through 984,896 +turn on 628,251 through 677,681 +toggle 276,956 through 631,964 +turn on 78,358 through 974,713 +turn on 521,360 through 773,597 +turn off 963,52 through 979,502 +turn on 117,151 through 934,622 +toggle 237,91 through 528,164 +turn on 944,269 through 975,453 +toggle 979,460 through 988,964 +turn off 440,254 through 681,507 +toggle 347,100 through 896,785 +turn off 329,592 through 369,985 +turn on 931,960 through 979,985 +toggle 703,3 through 776,36 +toggle 798,120 through 908,550 +turn off 186,605 through 914,709 +turn off 921,725 through 979,956 +toggle 167,34 through 735,249 +turn on 726,781 through 987,936 +toggle 720,336 through 847,756 +turn on 171,630 through 656,769 +turn off 417,276 through 751,500 +toggle 559,485 through 584,534 +turn on 568,629 through 690,873 +toggle 248,712 through 277,988 +toggle 345,594 through 812,723 +turn off 800,108 through 834,618 +turn off 967,439 through 986,869 +turn on 842,209 through 955,529 +turn on 132,653 through 357,696 +turn on 817,38 through 973,662 +turn off 569,816 through 721,861 +turn on 568,429 through 945,724 +turn on 77,458 through 844,685 +turn off 138,78 through 498,851 +turn on 136,21 through 252,986 +turn off 2,460 through 863,472 +turn on 172,81 through 839,332 +turn on 123,216 through 703,384 +turn off 879,644 through 944,887 +toggle 227,491 through 504,793 +toggle 580,418 through 741,479 +toggle 65,276 through 414,299 +toggle 482,486 through 838,931 +turn off 557,768 through 950,927 +turn off 615,617 through 955,864 +turn on 859,886 through 923,919 +turn on 391,330 through 499,971 +toggle 521,835 through 613,847 +turn on 822,787 through 989,847 +turn on 192,142 through 357,846 +turn off 564,945 through 985,945 +turn off 479,361 through 703,799 +toggle 56,481 through 489,978 +turn off 632,991 through 774,998 +toggle 723,526 through 945,792 +turn on 344,149 through 441,640 +toggle 568,927 through 624,952 +turn on 621,784 through 970,788 +toggle 665,783 through 795,981 +toggle 386,610 through 817,730 +toggle 440,399 through 734,417 +toggle 939,201 through 978,803 +turn off 395,883 through 554,929 +turn on 340,309 through 637,561 +turn off 875,147 through 946,481 +turn off 945,837 through 957,922 +turn off 429,982 through 691,991 +toggle 227,137 through 439,822 +toggle 4,848 through 7,932 +turn off 545,146 through 756,943 +turn on 763,863 through 937,994 +turn on 232,94 through 404,502 +turn off 742,254 through 930,512 +turn on 91,931 through 101,942 +toggle 585,106 through 651,425 +turn on 506,700 through 567,960 +turn off 548,44 through 718,352 +turn off 194,827 through 673,859 +turn off 6,645 through 509,764 +turn off 13,230 through 821,361 +turn on 734,629 through 919,631 +toggle 788,552 through 957,972 +toggle 244,747 through 849,773 +turn off 162,553 through 276,887 +turn off 569,577 through 587,604 +turn off 799,482 through 854,956 +turn on 744,535 through 909,802 +toggle 330,641 through 396,986 +turn off 927,458 through 966,564 +toggle 984,486 through 986,913 +toggle 519,682 through 632,708 +turn on 984,977 through 989,986 +toggle 766,423 through 934,495 +turn on 17,509 through 947,718 +turn on 413,783 through 631,903 +turn on 482,370 through 493,688 +turn on 433,859 through 628,938 +turn off 769,549 through 945,810 +turn on 178,853 through 539,941 +turn off 203,251 through 692,433 +turn off 525,638 through 955,794 +turn on 169,70 through 764,939 +toggle 59,352 through 896,404 +toggle 143,245 through 707,320 +turn off 103,35 through 160,949 +toggle 496,24 through 669,507 +turn off 581,847 through 847,903 +turn on 689,153 through 733,562 +turn on 821,487 through 839,699 +turn on 837,627 through 978,723 +toggle 96,748 through 973,753 +toggle 99,818 through 609,995 +turn on 731,193 through 756,509 +turn off 622,55 through 813,365 +turn on 456,490 through 576,548 +turn on 48,421 through 163,674 +turn off 853,861 through 924,964 +turn off 59,963 through 556,987 +turn on 458,710 through 688,847 +toggle 12,484 through 878,562 +turn off 241,964 through 799,983 +turn off 434,299 through 845,772 +toggle 896,725 through 956,847 +turn on 740,289 through 784,345 +turn off 395,840 through 822,845 +turn on 955,224 through 996,953 +turn off 710,186 through 957,722 +turn off 485,949 through 869,985 +turn on 848,209 through 975,376 +toggle 221,241 through 906,384 +turn on 588,49 through 927,496 +turn on 273,332 through 735,725 +turn on 505,962 through 895,962 +toggle 820,112 through 923,143 +turn on 919,792 through 978,982 +toggle 489,461 through 910,737 +turn off 202,642 through 638,940 +turn off 708,953 through 970,960 +toggle 437,291 through 546,381 +turn on 409,358 through 837,479 +turn off 756,279 through 870,943 +turn off 154,657 through 375,703 +turn off 524,622 through 995,779 +toggle 514,221 through 651,850 +toggle 808,464 through 886,646 +toggle 483,537 through 739,840 +toggle 654,769 through 831,825 +turn off 326,37 through 631,69 +turn off 590,570 through 926,656 +turn off 881,913 through 911,998 +turn on 996,102 through 998,616 +turn off 677,503 through 828,563 +turn on 860,251 through 877,441 +turn off 964,100 through 982,377 +toggle 888,403 through 961,597 +turn off 632,240 through 938,968 +toggle 731,176 through 932,413 +turn on 5,498 through 203,835 +turn on 819,352 through 929,855 +toggle 393,813 through 832,816 +toggle 725,689 through 967,888 +turn on 968,950 through 969,983 +turn off 152,628 through 582,896 +turn off 165,844 through 459,935 +turn off 882,741 through 974,786 +turn off 283,179 through 731,899 +toggle 197,366 through 682,445 +turn on 106,309 through 120,813 +toggle 950,387 through 967,782 +turn off 274,603 through 383,759 +turn off 155,665 through 284,787 +toggle 551,871 through 860,962 +turn off 30,826 through 598,892 +toggle 76,552 through 977,888 +turn on 938,180 through 994,997 +toggle 62,381 through 993,656 +toggle 625,861 through 921,941 +turn on 685,311 through 872,521 +turn on 124,934 through 530,962 +turn on 606,379 through 961,867 +turn off 792,735 through 946,783 +turn on 417,480 through 860,598 +toggle 178,91 through 481,887 +turn off 23,935 through 833,962 +toggle 317,14 through 793,425 +turn on 986,89 through 999,613 +turn off 359,201 through 560,554 +turn off 729,494 through 942,626 +turn on 204,143 through 876,610 +toggle 474,97 through 636,542 +turn off 902,924 through 976,973 +turn off 389,442 through 824,638 +turn off 622,863 through 798,863 +turn on 840,622 through 978,920 +toggle 567,374 through 925,439 +turn off 643,319 through 935,662 +toggle 185,42 through 294,810 +turn on 47,124 through 598,880 +toggle 828,303 through 979,770 +turn off 174,272 through 280,311 +turn off 540,50 through 880,212 +turn on 141,994 through 221,998 +turn on 476,695 through 483,901 +turn on 960,216 through 972,502 +toggle 752,335 through 957,733 +turn off 419,713 through 537,998 +toggle 772,846 through 994,888 +turn on 881,159 through 902,312 +turn off 537,651 through 641,816 +toggle 561,947 through 638,965 +turn on 368,458 through 437,612 +turn on 290,149 through 705,919 +turn on 711,918 through 974,945 +toggle 916,242 through 926,786 +toggle 522,272 through 773,314 +turn on 432,897 through 440,954 +turn off 132,169 through 775,380 +toggle 52,205 through 693,747 +toggle 926,309 through 976,669 +turn off 838,342 through 938,444 +turn on 144,431 through 260,951 +toggle 780,318 through 975,495 +turn off 185,412 through 796,541 +turn on 879,548 through 892,860 +turn on 294,132 through 460,338 +turn on 823,500 through 899,529 +turn off 225,603 through 483,920 +toggle 717,493 through 930,875 +toggle 534,948 through 599,968 +turn on 522,730 through 968,950 +turn off 102,229 through 674,529 diff --git a/2015/rs/src/three.rs b/2015/rs/src/three.rs new file mode 100644 index 0000000..04db03a --- /dev/null +++ b/2015/rs/src/three.rs @@ -0,0 +1,29 @@ +use std::collections::HashSet; + +static INPUT: &'static str = include_str!("three.txt"); + +fn main() { + let valueified = INPUT.chars().map(|c| match c { '<' => (-1, 0), '>' => (1, 0), '^' => (0, 1), 'v' => (0, -1), _ => (0, 0) }); + + let mut visited = HashSet::new(); + append_visits(valueified.clone(), &mut visited); + println!("Number visited normally: {}", visited.len()); + + let santa_iter = valueified.clone().step_by(2); + let robot_iter = valueified.skip(1).step_by(2); + + let mut visited = HashSet::new(); + append_visits(santa_iter.clone(), &mut visited); + append_visits(robot_iter.clone(), &mut visited); + println!("Number visited w/ robot: {}", visited.len()); +} + +fn append_visits<I: Iterator<Item = (i32, i32)>>(iter: I, visited: &mut HashSet<(i32, i32)>) { + let (mut x, mut y) = (0, 0); + visited.insert((0, 0)); + for (move_x, move_y) in iter { + x += move_x; + y += move_y; + visited.insert((x, y)); + } +} diff --git a/2015/rs/src/three.txt b/2015/rs/src/three.txt new file mode 100644 index 0000000..55f286f --- /dev/null +++ b/2015/rs/src/three.txt @@ -0,0 +1 @@ +^><^>>>^<^v<v^^vv^><<^<><<vv^<>^<^v>^vv<>v><vv^^<>>^^^v<<vv><<^>^<^v<^>^v><<<v^<v<<<v<<vv<v<^><^>><>v>v^<<v^^<^v<><^>^<<^^^>v>>v^^<v>>^>vv><v>>^>>v^>^v>^<^^v>^>^^v<v>^^<v<>>v^^v><^><^<<>v^<^<^v<v>v^>>>v^v^>^<>^v<^^vv<v>^>^<>^^<vv^<><<v<^<^^>vv<>^>v<^>^v>v^>^v<>^><>><vv<>v^v<><>v^v>>>>v^^>^><^^<v<^><^<v>>^v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^<<^^vv^^>vv<^>v>^^<<v^<<^^v<>^>v<<^^<^>^^^v^^<v<^<^>>>v^vv^<^v>^<>^<^<v<^v>>>^<^v<><v<^vv<v>v><v^v^^v<vv><^^<><>^>v<^<^vv>><^v><v<>^<>^^>^<><<<v^>>^<>><<><v>vvv^<<^<vv<v><v<^<<<^>^>>v<^>>vv>^v^^^v<>v<>><>^vv^>vv^ diff --git a/2015/rs/src/two.rs b/2015/rs/src/two.rs new file mode 100644 index 0000000..572c556 --- /dev/null +++ b/2015/rs/src/two.rs @@ -0,0 +1,31 @@ +static INPUT: &'static str = include_str!("two.txt"); + +fn main() { + let valueified = INPUT + .split('\n') + .filter(|s| !s.is_empty()) + .map(|line| { + let mut nums = line + .split('x') + .map(str::parse::<u32>) + .map(Result::unwrap); + (nums.next().unwrap(), nums.next().unwrap(), nums.next().unwrap()) + }); + + let final_area: u32 = valueified.clone() + .map(|(w, l, h)| { + let sides = [w*h, l*w, h*l]; + sides.into_iter().min().unwrap() + sides.into_iter().sum::<u32>() * 2 + }) + .sum(); + println!("Final area: {final_area}"); + + let ribbon_length: u32 = valueified + .map(|(w, l, h)| { + let mut nums = [w, l, h]; + nums.sort(); + (nums[0] + nums[1]) * 2 + (w * l * h) + }) + .sum(); + println!("Ribbon length: {ribbon_length}"); +} diff --git a/2015/rs/src/two.txt b/2015/rs/src/two.txt new file mode 100644 index 0000000..5f3335f --- /dev/null +++ b/2015/rs/src/two.txt @@ -0,0 +1,1000 @@ +29x13x26 +11x11x14 +27x2x5 +6x10x13 +15x19x10 +26x29x15 +8x23x6 +17x8x26 +20x28x3 +23x12x24 +11x17x3 +19x23x28 +25x2x25 +1x15x3 +25x14x4 +23x10x23 +29x19x7 +17x10x13 +26x30x4 +16x7x16 +7x5x27 +8x23x6 +2x20x2 +18x4x24 +30x2x26 +6x14x23 +10x23x9 +29x29x22 +1x21x14 +22x10x13 +10x12x10 +20x13x11 +12x2x14 +2x16x29 +27x18x26 +6x12x20 +18x17x8 +14x25x1 +30x15x22 +17x18x7 +28x23x24 +15x12x25 +14x7x20 +29x23x8 +24x5x22 +6x22x8 +1x15x26 +14x5x1 +24x28x28 +17x23x23 +4x15x7 +23x8x11 +6x15x1 +23x18x13 +17x1x26 +23x13x17 +2x18x8 +22x22x1 +10x22x6 +28x29x20 +22x21x25 +14x8x23 +12x30x14 +8x7x5 +3x30x15 +4x3x29 +25x18x3 +16x7x16 +4x3x8 +9x16x30 +20x28x3 +28x24x6 +4x18x2 +23x18x5 +22x4x30 +15x30x9 +7x12x12 +3x22x29 +12x1x9 +9x2x25 +17x11x10 +25x24x7 +7x27x26 +26x4x12 +29x2x26 +19x24x12 +23x23x3 +26x28x16 +18x4x16 +25x30x18 +29x19x19 +16x3x27 +29x25x29 +18x19x5 +14x21x30 +19x13x26 +19x10x15 +9x4x7 +18x6x6 +24x25x29 +9x12x27 +15x3x22 +30x17x21 +18x19x28 +9x11x12 +8x28x22 +11x3x4 +28x17x20 +24x18x15 +11x12x13 +6x19x24 +28x4x5 +28x22x23 +13x29x2 +9x16x15 +29x28x1 +10x18x30 +19x11x12 +26x28x25 +23x17x13 +25x1x21 +17x1x27 +17x27x28 +28x13x15 +14x13x25 +11x29x7 +22x29x5 +13x6x14 +23x18x13 +25x7x17 +18x9x20 +21x11x2 +28x11x13 +13x25x1 +19x29x25 +16x29x4 +10x21x10 +7x25x17 +5x9x3 +1x15x6 +8x27x29 +23x6x30 +22x22x29 +6x20x30 +26x25x29 +10x19x19 +20x30x9 +5x30x24 +17x10x27 +30x14x30 +8x17x4 +7x18x6 +3x5x4 +24x17x15 +14x20x17 +22x27x15 +18x14x15 +23x9x11 +21x16x29 +7x18x21 +9x3x29 +10x13x4 +2x30x4 +23x20x4 +8x22x21 +29x28x4 +13x16x25 +21x9x11 +7x26x26 +13x23x30 +19x7x10 +9x23x21 +21x9x17 +9x21x15 +20x29x22 +23x13x15 +19x25x2 +12x11x30 +20x21x6 +21x6x17 +24x26x9 +29x21x29 +29x26x16 +6x16x1 +2x12x6 +6x7x20 +7x2x22 +6x22x4 +13x11x27 +25x27x14 +11x8x6 +26x11x14 +30x3x29 +27x21x20 +15x16x26 +6x22x10 +11x9x25 +23x13x6 +13x9x3 +30x22x13 +29x23x14 +25x19x6 +7x29x11 +19x18x5 +29x25x13 +25x24x27 +1x9x12 +22x9x17 +14x12x28 +19x21x17 +13x25x17 +14x25x12 +4x14x30 +7x15x28 +3x6x25 +6x2x16 +15x19x11 +17x30x20 +20x23x7 +26x21x6 +26x29x24 +2x4x30 +4x22x18 +13x3x28 +27x6x21 +5x3x27 +12x7x11 +28x11x9 +12x9x2 +1x22x20 +15x13x28 +14x19x16 +28x20x3 +20x4x9 +26x7x26 +18x19x25 +7x1x13 +20x23x29 +27x26x8 +11x15x15 +10x21x23 +29x2x11 +21x28x20 +3x18x23 +26x17x17 +14x26x17 +20x7x17 +18x12x8 +4x8x8 +8x15x23 +24x29x5 +1x25x8 +1x28x17 +16x18x13 +29x24x22 +13x16x10 +14x7x16 +15x11x29 +12x15x19 +17x6x28 +4x3x9 +15x16x8 +29x27x11 +2x24x20 +4x21x3 +29x24x27 +18x22x22 +7x8x18 +20x7x8 +19x9x2 +20x17x2 +2x29x10 +19x25x1 +28x9x3 +29x27x20 +7x21x7 +10x4x22 +26x8x5 +26x14x1 +5x27x9 +2x18x3 +3x27x17 +30x17x23 +30x11x20 +4x6x7 +6x29x27 +30x16x20 +24x30x28 +19x20x26 +18x1x25 +26x12x12 +19x15x29 +16x21x24 +23x13x26 +25x16x10 +8x9x18 +24x14x1 +24x15x21 +19x9x14 +8x23x11 +22x2x16 +29x9x26 +3x16x25 +15x20x30 +3x11x12 +15x2x3 +13x7x4 +2x7x27 +9x26x11 +30x24x19 +28x17x21 +10x8x2 +11x15x26 +10x12x20 +24x24x27 +25x26x16 +13x4x20 +25x13x11 +12x22x3 +20x7x1 +12x18x6 +26x8x20 +14x2x7 +23x12x1 +26x24x24 +27x26x23 +26x17x5 +17x24x2 +26x5x6 +23x5x1 +5x18x30 +24x21x19 +5x28x11 +21x20x14 +25x4x22 +26x24x11 +7x5x8 +13x1x30 +5x1x6 +14x5x2 +8x11x7 +13x20x1 +17x30x14 +29x22x10 +12x26x3 +27x17x3 +26x27x4 +5x26x17 +22x11x19 +8x26x3 +24x19x22 +7x1x4 +6x27x30 +4x28x14 +16x14x18 +4x5x20 +19x25x4 +15x15x1 +10x14x14 +16x18x24 +21x27x15 +5x5x10 +1x7x13 +16x2x8 +13x15x11 +3x25x10 +20x29x8 +12x3x2 +10x13x12 +25x27x1 +11x30x19 +7x19x13 +27x6x18 +16x21x19 +21x29x5 +16x23x12 +29x19x15 +5x5x10 +27x15x1 +13x16x22 +29x19x5 +8x12x9 +3x18x5 +13x25x3 +5x9x21 +10x20x16 +9x9x11 +23x21x1 +22x2x15 +27x8x13 +23x7x3 +26x30x15 +29x15x16 +16x27x13 +2x18x9 +10x27x8 +20x9x25 +10x2x17 +16x13x13 +21x26x1 +27x26x24 +9x30x16 +19x17x28 +25x15x1 +10x26x6 +10x11x11 +5x26x25 +30x4x15 +9x8x23 +14x25x7 +8x28x8 +28x18x24 +4x4x25 +16x25x11 +17x27x8 +15x16x9 +24x13x21 +17x3x27 +27x5x26 +8x27x12 +29x2x8 +24x23x30 +1x30x21 +6x18x20 +13x14x12 +25x30x23 +24x6x24 +12x7x21 +11x6x8 +8x30x30 +26x3x12 +28x6x5 +18x7x1 +7x6x20 +14x16x18 +11x22x15 +4x20x10 +19x24x19 +8x24x11 +4x9x10 +6x6x22 +10x9x29 +1x5x28 +19x25x29 +20x30x3 +15x13x13 +9x9x24 +20x14x29 +26x24x13 +2x25x8 +10x26x2 +12x19x12 +18x6x20 +4x5x14 +26x27x10 +16x26x20 +3x21x15 +2x26x18 +14x11x17 +26x26x25 +10x1x11 +17x19x19 +27x28x26 +9x2x10 +19x30x15 +23x30x14 +15x3x20 +2x14x22 +21x18x8 +22x4x29 +19x6x29 +9x26x29 +16x10x9 +22x12x22 +13x28x14 +25x14x28 +28x3x30 +10x17x1 +10x27x22 +10x23x19 +14x25x9 +11x24x8 +30x25x10 +22x13x28 +2x7x6 +11x20x8 +9x22x14 +19x16x9 +11x24x4 +11x17x2 +6x4x10 +26x10x10 +12x14x5 +27x10x3 +15x3x6 +11x7x19 +22x10x12 +21x26x10 +13x20x3 +27x8x8 +1x24x23 +24x9x22 +23x17x23 +3x28x19 +2x20x28 +23x17x24 +26x1x4 +4x1x12 +5x6x16 +13x22x13 +25x21x21 +20x21x12 +9x24x25 +17x16x12 +12x28x9 +18x16x27 +29x12x2 +30x12x15 +24x11x10 +4x9x22 +4x24x5 +19x11x5 +6x25x6 +1x20x17 +22x8x21 +11x26x4 +16x19x3 +8x12x8 +13x2x18 +10x5x11 +8x12x17 +21x2x5 +26x17x26 +23x18x17 +28x11x14 +1x4x27 +29x5x28 +5x9x10 +5x7x25 +20x15x27 +15x11x17 +12x14x1 +29x14x4 +18x14x18 +14x25x24 +26x14x18 +13x8x11 +30x1x23 +3x4x12 +12x24x9 +8x6x16 +14x15x30 +12x30x8 +22x11x18 +16x30x28 +17x18x4 +13x14x23 +2x28x8 +3x28x30 +29x30x8 +4x6x26 +6x30x17 +11x30x30 +19x4x3 +12x15x20 +22x28x4 +26x30x2 +6x12x7 +1x10x5 +25x29x7 +17x9x18 +16x21x29 +21x14x7 +15x16x11 +26x6x15 +8x24x7 +2x20x4 +2x9x3 +19x8x13 +18x7x22 +27x14x17 +2x13x8 +18x15x26 +15x27x27 +18x11x15 +1x29x20 +21x12x11 +20x2x15 +28x23x9 +1x1x17 +7x23x9 +30x9x27 +9x16x18 +15x24x28 +30x11x18 +29x26x10 +9x5x25 +2x1x19 +14x3x14 +6x3x6 +30x15x20 +20x17x27 +28x10x9 +14x24x28 +17x11x6 +12x3x6 +8x8x15 +23x14x21 +11x21x7 +5x13x30 +4x29x25 +30x28x24 +18x4x9 +3x15x6 +13x9x19 +30x14x7 +7x9x9 +17x11x26 +24x26x13 +16x21x16 +27x17x25 +2x21x11 +9x11x27 +3x3x7 +13x8x14 +20x20x26 +13x29x22 +30x11x1 +7x10x19 +27x5x9 +23x17x15 +21x6x13 +24x15x16 +18x4x14 +18x16x6 +22x11x18 +14x2x5 +15x3x7 +10x20x29 +16x1x10 +30x23x1 +10x15x11 +17x14x5 +22x8x13 +7x11x28 +26x17x3 +2x23x2 +28x13x19 +18x12x28 +22x23x16 +14x12x1 +20x8x19 +17x19x13 +29x2x12 +2x26x27 +29x16x4 +13x8x18 +16x15x30 +23x16x2 +28x8x27 +21x8x23 +13x20x26 +19x6x17 +17x30x15 +7x4x30 +2x13x30 +18x7x19 +4x13x27 +8x6x5 +18x20x25 +2x3x30 +23x27x13 +22x30x4 +23x25x25 +23x16x19 +25x3x1 +5x6x15 +11x29x12 +25x24x7 +16x7x20 +20x3x2 +12x27x15 +16x10x12 +1x3x14 +22x1x26 +2x24x18 +11x29x16 +15x2x9 +10x1x24 +21x8x11 +30x11x23 +6x30x21 +13x27x29 +14x6x5 +18x29x19 +12x4x28 +29x3x14 +10x30x28 +5x7x15 +14x1x10 +9x25x14 +7x24x18 +28x17x21 +18x13x25 +26x15x1 +21x1x19 +12x16x21 +4x6x13 +7x15x26 +17x19x5 +12x28x2 +1x20x19 +27x7x5 +17x26x8 +12x15x19 +5x23x10 +8x2x8 +16x13x12 +14x27x1 +26x29x3 +24x16x14 +14x13x13 +7x22x23 +2x9x30 +4x27x8 +26x27x15 +23x1x6 +25x29x18 +5x18x1 +20x8x20 +5x10x25 +30x25x15 +7x22x25 +28x26x17 +29x4x1 +21x11x27 +20x9x8 +25x22x12 +2x11x11 +23x2x16 +23x27x20 +2x13x28 +27x2x24 +11x1x17 +12x4x27 +16x20x22 +30x12x10 +5x15x4 +5x2x27 +12x4x25 +1x16x4 +27x4x4 +21x16x3 +27x26x3 +24x6x6 +24x12x12 +20x20x25 +8x29x2 +21x4x5 +2x4x8 +4x13x19 +3x20x10 +12x15x16 +6x5x4 +12x16x20 +22x19x17 +8x17x22 +25x16x15 +7x1x19 +10x1x7 +23x23x5 +28x6x12 +2x25x12 +10x27x12 +24x27x19 +14x14x20 +4x1x5 +16x27x29 +20x20x24 +28x24x30 +6x15x15 +9x15x30 +23x26x3 +17x24x21 +22x25x25 +18x29x10 +20x25x1 +24x11x16 +20x7x21 +20x7x9 +7x26x2 +5x18x1 +16x26x28 +4x10x18 +27x30x21 +26x9x9 +8x16x14 +6x27x8 +28x9x20 +13x13x4 +9x18x16 +18x15x18 +22x19x14 +14x10x17 +25x29x11 +1x18x19 +8x11x26 +18x6x14 +30x24x13 +27x1x27 +15x9x3 +2x29x17 +2x26x21 +22x9x9 +20x20x20 +22x28x2 +26x5x16 +11x3x14 +21x16x16 +18x26x7 +18x30x6 +7x11x12 +15x10x2 +27x2x16 +27x30x24 +28x14x24 +7x4x8 +6x28x15 +13x19x1 +22x26x30 +7x30x24 +2x17x21 +19x26x2 +19x24x15 +14x23x2 +21x27x15 +30x15x14 +21x29x5 +23x30x2 +4x1x2 +15x5x13 +21x2x30 +20x7x16 +1x21x25 +2x25x1 +12x29x5 +28x13x16 +26x3x12 +29x20x23 +28x12x20 +4x30x8 +16x15x16 +6x16x29 +2x28x13 +24x25x2 +26x15x22 +17x20x11 +18x12x7 +19x1x18 +8x27x13 +22x16x8 +19x26x17 +13x11x10 +22x12x3 +13x12x14 +29x17x9 +6x14x10 +14x20x10 +8x26x9 +25x13x22 +3x30x25 +14x28x1 +30x29x12 +3x17x15 +3x24x14 +28x24x22 +16x6x1 +20x25x14 +17x17x13 +6x19x27 +10x15x20 +8x23x20 +7x29x21 +18x9x25 +10x5x22 +2x27x27 +16x18x30 +15x5x12 +26x29x29 +28x11x10 +9x29x28 +24x15x23 +26x9x10 +5x1x25 +22x27x16 +7x29x3 +1x3x5 +8x7x29 +19x21x11 +28x13x30 +17x16x20 +5x10x25 +9x14x15 +15x14x23 +16x4x17 +21x8x2 +9x9x8 +22x22x4 +10x2x27 +12x19x10 +15x29x4 +22x14x7 +29x18x5 +1x7x27 +24x1x15 +23x23x26 +12x17x23 +26x10x24 +8x22x2 +8x1x10 +22x19x12 +2x23x13 +11x27x25 +26x15x27 +27x7x21 +18x9x6 +22x21x22 +7x12x26 +23x21x13 +14x3x8 +5x9x28 +29x29x15 +27x25x23 +12x2x24 +8x2x20 +29x19x4 +12x24x29 +2x27x28 +14x20x9 +28x6x25 +18x29x8 +19x11x30 +15x11x23 +18x7x7 +14x20x14 +26x18x22 +27x25x13 +12x10x30 +30x2x7 +28x10x1 +18x10x30 +22x11x5 +22x16x3 +25x15x9 +5x10x24 +4x28x8 +19x24x18 +3x4x25 +14x4x30 +11x26x3 +12x12x12 +26x7x24 +3x2x14 +1x27x7 +2x2x13 +3x26x26 +12x4x11 +12x17x20 +4x19x30 +5x18x10 +17x6x18 +19x30x20 +11x2x17 +30x13x19 +22x23x7 +17x28x2 +5x17x30 +7x11x4 +21x26x18 +15x28x4 +5x6x27 +12x6x16 +9x17x12 +27x20x5 +14x5x20 +27x14x6 +2x14x21 +4x28x30 +24x5x1 +19x29x29 +11x23x1 +8x16x21 +3x17x19 +10x13x5 +20x21x16 +23x3x6 +27x26x11 +3x2x22 +14x3x5 +10x9x8 |