Created
December 5, 2017 15:11
-
-
Save davidhamann/febb5e48b61ce61bd89d5ba8903e0c59 to your computer and use it in GitHub Desktop.
just for fun captcha solver for code challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solve_captcha(sequence): | |
return sum( | |
int(num) for i, num in enumerate(sequence) if num == sequence[(i+1) % len(sequence)] | |
) | |
assert solve_captcha('1122') == 3 | |
assert solve_captcha('1111') == 4 | |
assert solve_captcha('1234') == 0 | |
assert solve_captcha('91212129') == 9 | |
sequence = '3801219356208138590410639949502922324758870956901034391673799018355647790565877097195839447540715564272571483487956780824953658829135545484059928411675056348415711573285456843872061893305099849813733887049254118252931250950553524728357672662214635748158436021219711283189827562053402598336411051488102965027876043723951010003925195389132557334026742444154387486314469312232719954644805681399271596840033764549177793261113525450924586619784251686652364931747953378089212551908515581599501188912896127337722907992361449678187290503180583991009524375784935707382892678629672965456641020695820138089004237819736874474190685803639253938668337043493403375869310881448009873269985430793208961281808497096847394012898904160470106518410310865842857977602374474348041345223089044998026993954285652178380101608276937031189381098461498787923568439791839850187503817155425146172789017084716643322925503362778565054434826752677047839408555993717139723488535519408425976810984504990390432419671238442486883896585891797710825023569194944160375311421902050684850312420951140205552297164465181103684324995262677582949328937688882211798032308046835473981424317308399496561612275061014885407552118703142255703410994144508738418468591885426566198220135286690633105019982233508563393175221668957425331043484742299730798102044092168051162105031517863799138585595736669000095454744720828744625239571148450753555397894155872393959054856564726997179430842473548855603673402362663812823929672044320408053576302637189523709652947963273624584196806556349547404138293414809236518439748255884392857670837141288203468593005285515493881551777814515350551214296568069867749466009994142929581886406159386005962044366907184227451001992532845725294289407994957472542532475757221649139349903358223668812386217226414377883546352408108341186423317410125198781095718979512223746457244790301637528476079743219219146622644424098047690439675699391108514724881126840620007189969389540326196565092953166912397015353401475448399920639190386164563771284459430959' | |
print(solve_captcha(sequence)) | |
# >> 987 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment