aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKai WU <kaiwu2004@gmail.com>2022-03-18 09:39:18 +0800
committerKai WU <kaiwu2004@gmail.com>2022-03-18 09:39:18 +0800
commit4e6854698f384eda4040925fbf647b823f223050 (patch)
treed3226f24d643c6063996a43537d331445c9305a5 /src
parentf1023205abc22271c9f83cd81a119558d7c07702 (diff)
downloadadvent-of-code-4e6854698f384eda4040925fbf647b823f223050.tar.gz
advent-of-code-4e6854698f384eda4040925fbf647b823f223050.zip
day8
Diffstat (limited to 'src')
-rw-r--r--src/2015/day8/README.md22
-rw-r--r--src/2015/day8/aoc.cpp5
-rw-r--r--src/2015/day8/aoc.h7
-rw-r--r--src/2015/day8/input300
-rw-r--r--src/CMakeLists.txt1
5 files changed, 335 insertions, 0 deletions
diff --git a/src/2015/day8/README.md b/src/2015/day8/README.md
new file mode 100644
index 0000000..e9688bf
--- /dev/null
+++ b/src/2015/day8/README.md
@@ -0,0 +1,22 @@
+--- Day 8: Matchsticks ---
+
+Space on the sleigh is limited this year, and so Santa will be bringing his list as a digital copy. He needs to know how much space it will take up when stored.
+
+It is common in many programming languages to provide a way to escape special characters in strings. For example, C, JavaScript, Perl, Python, and even PHP handle special characters in very similar ways.
+
+However, it is important to realize the difference between the number of characters in the code representation of the string literal and the number of characters in the in-memory string itself.
+
+For example:
+
+ "" is 2 characters of code (the two double quotes), but the string contains zero characters.
+ "abc" is 5 characters of code, but 3 characters in the string data.
+ "aaa\"aaa" is 10 characters of code, but the string itself contains six "a" characters and a single, escaped quote character, for a total of 7 characters in the string data.
+ "\x27" is 6 characters of code, but the string itself contains just one - an apostrophe ('), escaped using hexadecimal notation.
+
+Santa's list is a file that contains many double-quoted string literals, one on each line. The only escape sequences used are \\ (which represents a single backslash), \" (which represents a lone double-quote character), and \x plus two hexadecimal characters (which represents a single character with that ASCII code).
+
+Disregarding the whitespace in the file, what is the number of characters of code for string literals minus the number of characters in memory for the values of the strings in total for the entire file?
+
+For example, given the four strings above, the total number of characters of string code (2 + 5 + 10 + 6 = 23) minus the total number of characters in memory for string values (0 + 3 + 7 + 1 = 11) is 23 - 11 = 12.
+
+
diff --git a/src/2015/day8/aoc.cpp b/src/2015/day8/aoc.cpp
new file mode 100644
index 0000000..1c33c66
--- /dev/null
+++ b/src/2015/day8/aoc.cpp
@@ -0,0 +1,5 @@
+#include "aoc.h"
+
+namespace aoc2015 {
+
+}
diff --git a/src/2015/day8/aoc.h b/src/2015/day8/aoc.h
new file mode 100644
index 0000000..7eb843c
--- /dev/null
+++ b/src/2015/day8/aoc.h
@@ -0,0 +1,7 @@
+#pragma once
+
+#include "common.h"
+
+namespace aoc2015 {
+
+}
diff --git a/src/2015/day8/input b/src/2015/day8/input
new file mode 100644
index 0000000..3e5be65
--- /dev/null
+++ b/src/2015/day8/input
@@ -0,0 +1,300 @@
+"\xa8br\x8bjr\""
+"nq"
+"zjrfcpbktjmrzgsz\xcaqsc\x03n\"huqab"
+"daz\\zyyxddpwk"
+"draes\xa2n\\g\x27ek\"lj\"\\viqych"
+"nnx\\krnrfomdnt\x2flbl\xd2xpo\"cp\"k"
+"kwdaapalq"
+"u\"ptk"
+"ckhorczuiudfjmmcc\\u\"wozqxibsfjma"
+"ydctdrxat\"pd\"lwi\"bjesevfw\xe8"
+"v\"\xa8rrzep\"\"r"
+"nbydghkfvmq\\\xe0\"lfsrsvlsj\"i\x61liif"
+"jsas\"u"
+"odipikxlo"
+"\"rnubsgwltqkbsu\"pcpcs"
+"eitk\\f\\mhcqqoym\\ji"
+"vnedc"
+"\"lhcaurdqzyjyu"
+"haxzsa\"zcn\"y\"foclgtjfcnv\"m\x68krc"
+"\"eoeggg\"tmiydvcay\"vfavc"
+"snqvyqoncwxcvwbdktoywch"
+"rnfgjsyr\xd5wacy"
+"ik\"hebrpvsts"
+"txw"
+"\x15pxtdkogd\"urbm\"gevhh\"nxr\x3erxtk"
+"cetqtcy"
+"inleep\\mgl"
+"uflwbxvww\x2cxzezqnaply\"yh\"qlllzk"
+"eepak\"xqtedzt"
+"na\x61qzfieafvyrsnwkssznohjmc"
+"yceaonylz\xc1\\jrlbbkzwsidfi"
+"ybqafngkcqpbp"
+"\xaft"
+"yidjpaobqydso"
+"ju\\ldxig\\lrdrhjcmm\x77rc"
+"tylacqeslnwj\x48ds\"tjxa"
+"efbfm"
+"\\fxkgoprgdcjgyajykg\\dtbrz"
+"eujvva"
+"h\x7acwfpikme\\vwthyvrqdnx\""
+"rbpbrxm\\\"\"\"voxx"
+"ykiw\"tkb\\lforu\"rsf\\tf\"x\"rqti"
+"e\\wh\x77aqeugiq\\ihhfqfuaij"
+"g\"t\\o"
+"nxzo\"hf\\xp"
+"dxiaqfo\xea"
+"kali\\zczhiqkqzybjj\"fgdjnik"
+"zdkgrqmdv"
+"bimxim\xb6lrwsaj\"ui\"a"
+"\"rrznitibgx\\olpsjmjqzctxaubdifsq"
+"zb\"khzixaacmhuzmlymoformipdzml"
+"qfwi"
+"hjwsxfpphttjy\"\"zixais\xbblgnqfto"
+"puj\\qmyu\"nqgaqfthbwjokbmrpbhpi"
+"cyxdpkh\\\""
+"q"
+"m"
+"tbxdzzllarlo"
+"gbtys"
+"gytilk\\vlqxvcuutjunrqc"
+"uugkvcuzan\\eyhb"
+"yaxr\"genlbgw\"\\uc"
+"nrgecjeip\\sjdvgqaqxwsqactopu"
+"pu\"r\"txpyrkfny\\zmwfneyvwmnkkdipv"
+"jm\xa3bhwvq"
+"qxojmnml\"w\x9airr"
+"xbzsuihs\x4dcedy\xaclrhgii\\\""
+"drgjirusrekrwmvxllwdm"
+"\x28hfxnfpycmpnkku\"csuf\xaarxlqyg\"x"
+"\"zvz\\rmg\"\\sxxoifffyqfyn\"iq\"ps"
+"\"z"
+"zbwkmk\"sgzos\x93gtc\""
+"bvm\x28aa\\\\\"pywuhaniox\\z\\hbp\xd7mold"
+"aszgvsyna"
+"qf\"vdwuss"
+"lnohni\"qwiacjsjegstlbfq\\kyjhyd"
+"c\\naawulxlqplnacvytspry\xf5ytxxqq"
+"razwqmsqgbaaxcd\\f"
+"radggyrjrg\"zx"
+"\"pu\x11t\\ajcjuieinlkvya"
+"veggiskh"
+"eglfhjxiet\"kouqfskwsy\"hpthsldel"
+"mv\xc1b\"f\\shrssnjwcpmurepdxdlcj"
+"dlayjd\"suvzotgdtc"
+"\xa9pvxeopn"
+"lpplsaxy\"oiwaq"
+"hqwh\\lusv"
+"hykykwlx\"\xa5atkgh\\d\x63dff"
+"vfktanpjy\"xxetc"
+"dnhwkgjnsmsswfuelvihvjl\"jtf"
+"x\"dwvzra\"nbbsewftehczgbvfzd\"rau"
+"csfi\"mzejnjqkqupwadrgti\"von"
+"xckf\xf7xsm\\pgvlpetjndpyblais\\z"
+"yecy\x6fuj\x58bwpgeuiw\"mdu"
+"fgb"
+"c\\lx\x3efthet\xfdelgvwvpem"
+"kgyrmarvfwjinlowt"
+"yzte"
+"vc\"z"
+"sxevqfzmmdwsuu\""
+"fxbaercmcy\xb6md"
+"f"
+"m\x44gqbcppho\\b"
+"gtafr\x57m\x11jy\"\"erwmmpiwjkbckuw"
+"ufdjt\"kssprzxqixzxmq\x58q"
+"yzbyo\"lfdbyaxexyfbnyv\\\xe8xmre"
+"u\x43ntr\\\\byyfjr\"iveujvnwsqbnpuvrta"
+"us\xf6bai"
+"c\\edh"
+"tzckolphexfq\\\x23\xfbdqv\\\"m"
+"yjafhbvhhj\x1b\"bplb"
+"\"o"
+"rubahvmp\""
+"qmkukrnrmqumh"
+"wdpxyvyidhwjf\\nabbijwhr\xc5bksvy\"p"
+"u\"prlpg\""
+"nsvcquyxbwilsxxemf\xd9leq"
+"y\xcetxuafl"
+"it"
+"kwdlysf\\xjpelae"
+"viwh\x58wpjjlnvryuti\x2chngrx\\nhtkui"
+"vhn\x9ehre\xc3ncsqbozms\"nl"
+"ytc\xa3mgeeogjcqavmmmd"
+"xzlexlitseozoxtpzzutfq"
+"cish\x07lmovj"
+"ekbflwqzaiivdr\"pq\\azrfbntqwkn"
+"uc\"xdbegmlmhksofzohavtrnxf"
+"xfdnrdqdrcjzbe"
+"ndg\"ckgrpisib\"rg\"p\\lmpfzlssnvk"
+"witfjwpbyyzlop"
+"zonlww\"emrbcsgdtrg\"rjzy\x64zqntlw"
+"dvgb\"zn\\vrbzema\"ckmd"
+"\\vdlmxhlvldk\"pmzazeip"
+"\"\"r"
+"rsntinv"
+"iy"
+"lr\x20efh"
+"csgexlb\"zqdavlxxhtdbh\"\"\x0fkpvhiphm"
+"ouwhp\"ogbft"
+"cm\\ckltng\"dw\x8brf\xf0eppgckd"
+"zmnlsgalhpkejsizfsbtnfliu\"nhc"
+"pnrkaayqvwpdjbhcrbb\"yfeq\"aq"
+"ozh\\hoxow\x2csrtr\\r\""
+"bqxabj\"u\\s"
+"cpsjti\"gy"
+"aa\"p\\nki\\ajijkqev"
+"q\"\"lfdentjgd\\"
+"bmokvpoebutfki"
+"pielvcbne\xf6efvzxn"
+"kx"
+"zlgmqagcrbhrwtwtmmg"
+"aiyhmntcqjbpv\xb5hhswxbryoedvos"
+"tdpaxrb"
+"fu\"\x7dttkyvhrlwko"
+"oirc\\\"cqlnqffjqt\\k"
+"edxlia\\tcyby"
+"jpeybgwfayerfrfbvfog\"ol"
+"ysr"
+"bzwzilgwfugjk"
+"tlcc\x75nukvwjgftetjcs\xaecwc"
+"dsqssa\"vzrf\"sewbp\\ahhlmhbeihlh"
+"qtgmjck\"n\"guki\"gmdivwqxismqj"
+"\"f"
+"wuorvlovucngbzdszqpikyk"
+"dfrdsacoukmgvhbq\"\"iwto"
+"\"ey\"ch\\wcgioe\\\"ouvligmsw"
+"ciqlszzgs"
+"\\tzyrkaoi\"sopjaq"
+"lmtnv"
+"ar\"fqoroigiertjjlm\"ymgi\\kkjewsxd"
+"wehcimlvudpxtamdn\"rwy"
+"hr\"zvrwthr\"vruzqfrldn\"b"
+"sggekodkiwvym\"mhsco"
+"ltlkfbrrdvk\\"
+"uut\"sfjnz\"\\ef"
+"hxilg\\"
+"zsredsiwlzrpedibn"
+"vtfi"
+"\\h"
+"qekfrc\xf6wduodbwrguqcng\\n"
+"\"lljlfdrxftwidn\\pkv\xd9ij"
+"mrvgqynpehkliuijlpp"
+"gikjph"
+"yoxcdrdt\"wbaurnyhoyxoihu"
+"onmomwuxuammbzxe"
+"rnrr\\twviz\x61gqaljr\x0dmtw"
+"r\"vupaoi"
+"l"
+"sei"
+"jwxtdtbkd\\kxd"
+"\x22v\\"
+"ahd"
+"j\"bjqxs"
+"\\i\x24gglxub\\nzsajokt"
+"lviwpu\"uxdlh\\zuy\"xqy\"ytdzlx\"r"
+"kptfmys"
+"fwxzikfhczkjwyjszqdbkepaeellc"
+"nlqpsvbrbd\\ns"
+"qryuwkjiodw\"\"vaqyq\"dmyifm"
+"tw\x15kdmaudjl\\zorhp\"alwh"
+"aatrvczesykekkjfyb\"kb"
+"usqcutbqbxxhucwxo\xc1ltb\"j\"bghjcvws"
+"ilhsrnzxkz"
+"bianqfdfdhvw"
+"hqibqs\x7ax\"qoxqoaqtcsz"
+"htxtoojbbauztwxuiq\\ngyfy\\obzc"
+"rxn\\moxlj"
+"mtus\x84erh\"dbe"
+"asx\x50huvsitcxadt"
+"\"bugggtnrc\"\"kl\"hmpu\x83hqrvhpo"
+"ewisbp\"\"vuzf\\w\x5fvalszdhl"
+"scusplpwxfnxu\x57\"zynpn\x99xerc\\ri"
+"m\\kinmkke\x0cl"
+"xhuzit\x7fd"
+"kfbo\x04\x50ruqirn"
+"t\"\"xpbdscmdoug"
+"punvpsgnbgyxe\"sptmpz"
+"bxukkazijr"
+"nxyrcdaoo\"rjkk\"wntehcvcip\"vrd"
+"rdpvqskmihqaw"
+"p\\gwdhtqnpgthod"
+"nwnuf\"\"yebycearom\"nqym\"\xd4sii\xccle"
+"alda\"ptspo\"wkkv\"zoi\"hkb\"vnntyd"
+"ixpgpfzbqv"
+"znui\"\\fzn\x03qozabh\"rva\"pv\x67"
+"e\"zswmwuk"
+"hcccygwfa"
+"ngmace\\rtyllolr\"\x68bw"
+"\\c\"jyufbry\"ryo\"xpo\x26ecninfeckh\\s"
+"hdnpngtuc\"dzbvvosn\x31fwtpzbrt"
+"hesbpd\xd4"
+"dsdbstuzrdfmrnyntufs\"dmv"
+"d\xeeibcwhcvkt"
+"fvzwrsfjdqdmy\"\"v"
+"ns\"dqafz\\lkyoflnazv\"mn\x37\"o\"yj\"e"
+"dypilgbwzccayxa\"bnmuernx"
+"q\xa9ztqrhreb\"\"kxfeyodqb"
+"iz\xa5qjxqulaawuwz\"rqmpcj\\yel"
+"z\"\\pq\"\"y\x67zpjtn"
+"ifxqvivp\"kiiftdoe"
+"jxzebj\"\x35\"qr\"ecglcutuoyywqumcs\"kk"
+"q"
+"yob\x85qmpuwexptczbkrl"
+"cjiavv\"uudpozvibyycnmxhxpxmpjoz"
+"xro\\uiqyrcid"
+"nod\\k"
+"d\"neiec"
+"tqyrqvwyvmz\\pzgzzcqsqsrgbqbtapoz"
+"r\"xvocpeuxfxslgueb\x05kzyyie\"aoec"
+"\"du\\uirlhcbgv\\cjqhfreqnvn"
+"zp\x04\x15\"pbjwhrjtmiba"
+"\\cv\""
+"k\"rwnb\\hiu\"rqd\"rc\\nyakrhly"
+"klrmafjzandiddodgz"
+"xipzhqzhvlpykzcuppx"
+"zdvrvn\xd0mtfvpylbn\\\\sxcznrzugwznl"
+"ody\\pvm\"kpjiudzhxazirgxzvumeat\"o"
+"kllvhdp\"prjikzrrc\"adgpegc\\\"gk"
+"sqtpug\xbcaauxaamw"
+"wegxxrrxdvpivrqievfeokmnojsk"
+"\\bo"
+"gijhz"
+"ylowluvabwrigssdgtxdwsiorxev\xdd"
+"\""
+"ghnsrnsqtxpygikahkrl"
+"\"rcfqkbjf\"sgxg\"vnd\\rotn"
+"ap\"smgsuexjrbuqs\"mpbstogj\"x"
+"koaunz\\sgt\"opv"
+"yialiuzwix"
+"yp\"ndxgwzml\"bt"
+"lpcjxmggfsy\\szbxccarjkqzasqkb\xcfd\x0c"
+"x"
+"mgakc"
+"vjieunoh\x73fjwx"
+"erbvv\"qulsd"
+"mimycrbfhqkarmz"
+"tihfbgcszuej\"c\xfbvoqskkhbgpaddioo"
+"mziavkwrmekriqghw"
+"izk\\tnjd\\ed\\emokvjoc"
+"c\"nhbqzndro\\g"
+"usfngdo"
+"aypljdftvptt"
+"ym\"afvq\xbcc"
+"zabi\"wjpvugwhl"
+"ebvptcjqjhc\"n\"p\"dxrphegr\\"
+"mzlqqxokhye\xd9\\rffhnzs"
+"hnipqknwpsjakanuewe"
+"rqgbfcjdrmiz\"h"
+"kzzp\\z\\txmkwaouxictybwx"
+"yzmspjkqrteiydswlvb"
+"gjpxklgpzv\"txri\\hotpuiukzzzd"
+"p\"rxergtbsxmjmkeeqwvoagnki\""
+"santipvuiq"
+"\"ihjqlhtwbuy\"hdkiv\"mtiqacnf\\"
+"oliaggtqyyx"
+"fwwnpmbb"
+"yrtdrieazfxyyneo"
+"nywbv\\"
+"twc\\ehfqxhgomgrgwpxyzmnkioj"
+"qludrkkvljljd\\xvdeum\x4e"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2e28a51..7cc0a82 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -7,6 +7,7 @@ set(SOLUTION_FILES
"2015/day5/aoc.cpp"
"2015/day6/aoc.cpp"
"2015/day7/aoc.cpp"
+ "2015/day8/aoc.cpp"
)
add_library(solution SHARED ${SOLUTION_FILES})