From 7eba035e0dc0683037725f78d676db9fa8cecc7b Mon Sep 17 00:00:00 2001 From: Meutel Date: Sat, 2 Dec 2017 12:20:13 +0100 Subject: [PATCH] Day 1: inverse captcha --- .gitignore | 1 + 01dec/.invcaptcha.go.swp | Bin 0 -> 12288 bytes 01dec/input | 1 + 01dec/invcaptcha.go | 30 ++++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 01dec/.invcaptcha.go.swp create mode 100644 01dec/input create mode 100644 01dec/invcaptcha.go diff --git a/.gitignore b/.gitignore index 7560965..4fa74d7 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 .glide/ +01dec/01dec diff --git a/01dec/.invcaptcha.go.swp b/01dec/.invcaptcha.go.swp new file mode 100644 index 0000000000000000000000000000000000000000..db0dbdcb7830d1f036be4a67e4ccfbf5150e946e GIT binary patch literal 12288 zcmeI1KZp}S6o==o+u~HT5epet)D7l#6A$E2B8XTVqMRIB*o1Naj z;UPAs{ehK*g{_UPB3OxyAc!C$Hd<-rZ#LOn63KDx>09`id9!cczWFvOLax`YE?ngE zc8%fM!&r9TyteRojlI0fSmd{JKh!t2zG6?<$5(kAxUuIuwYulKj#M32B)PjR>{dLXAT5&tGO#@Z?L3&BpJ8(+>cv<6uz85@ z+k0hudntk5AYRy0`I{a@EW`VFTgXf z0Um*MunH1z9-IWTU_bbc+TXwz@DY3fZ^3i$1Z;qZK=-f)RzL?VgA3pcI1T2212~ul z-_iGH@D4l$>tGe!11lf|O>h}3f=l2Wz~7*(4lHmC8~}8Y0Wv@a$N(8217v^#_P8ah!pUT7p!YZ+b8y>!{%Yx>}2 zDr7cDPFJ1WR%2d Q&Mo{z7w!##7WMPkA6pVGod5s; literal 0 HcmV?d00001 diff --git a/01dec/input b/01dec/input new file mode 100644 index 0000000..9dd697e --- /dev/null +++ b/01dec/input @@ -0,0 +1 @@ +951484596541141557316984781494999179679767747627132447513171626424561779662873157761442952212296685573452311263445163233493199211387838461594635666699422982947782623317333683978438123261326863959719777179228599319321138948466562743761584836184512984131635354116264899181952748224523953976485816295227945792555726121913344959454458829485471174415775278865324142733339789878929596275998341778873889585819916457474773252249179366599951454182657225576277834669222982366884688565754691273745959468648957498511326215934353963981471593984617554514519623785326888374742147318993423214834751785956958395133486656388454552769722562524415715913869946325551396638593398729938526424994348267935153555851552287223313383583669912941364344694725478258297498969517632881187394141593479818536194597976519254215932257653777455227477617957833273463216593642394215275314734914719726618923177918342664351954252667253233858814365351722938716621544226598956257753212248859258351363174782742336961425325381561575992352415514168782816173861148859478285339529151631429536819286498721812323861771638574344416879476255929929157912984151742613268754779685396125954595318134933366626594498249956388771723777242772654678448815844555372892574747735672368299826548254744359377667294764559334659523233146587568261116253155189394188696831691284711264872914348961888253386971994431352474717376878745948769171243242621219912378731755544387249443997382399714738351857752329367997665166956467544459817582915478514486541453932175598413554259672117364863112592515988922747164842668361925135551248923449968328385889877512156952725198691746951431443497496455761516486573476185321748523644283494181119399874324683922393547682851931435931276267766772798261563117954648576421741384823494187895272582575669685279986988357796138794326125852772995446355723211161523161886222562853546488411563473998633847953246787557146187696947831335722888918172961256498971868946237299523474841983527391489962357196433927251798764362493965894995592683296651874787384247326643886774966828657393717626591578321174832222434128817871765347278152799425565633521152643686221411129463425496425385516719682884157452772141585743166647191938727971366274357874252166721759 diff --git a/01dec/invcaptcha.go b/01dec/invcaptcha.go new file mode 100644 index 0000000..bbb923f --- /dev/null +++ b/01dec/invcaptcha.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "strconv" + "strings" +) + +var in string +var p string +var f string +var sum int + +func main() { + fmt.Scanf("%s", &in) + for _, d := range strings.Split(in, "") { + if p == "" { + f = d + } else if p == d { + incr, _ := strconv.Atoi(p) + sum += incr + } + p = d + } + if f == p { + incr, _ := strconv.Atoi(p) + sum += incr + } + fmt.Println(sum) +}