Skip to content

Instantly share code, notes, and snippets.

@sunsetsonwheels
Created October 22, 2018 00:14
Show Gist options
  • Save sunsetsonwheels/8d82aadea6247126a9d7046bb8a84070 to your computer and use it in GitHub Desktop.
Save sunsetsonwheels/8d82aadea6247126a9d7046bb8a84070 to your computer and use it in GitHub Desktop.
Look and Say Sequence (MCC 2018)
#Input the string here(renamed to stre to avoid conflict)
stre = "2447223522885338847799391928442276611848335958837719966312339882255338863322986779969779778814944544661225529911669955811799225855446671388642551449985992267743388558661966992211556676179983388776613688439947764433665885593885774425577115588933525533521557998899786292274366882775599664135997239932255811833687788226679977667733223366885133554882944244224411668442784883811483322833847755883328711278994955144937933225521772788542232992355448822992291886357692667733668559129353624244296699553221194433218851158677223377144557749481445445541411997799743311893447177188577615445518899116338822166112833448511266114557183366844898833977448453349984579944711557745533972116638844388233734485998844642554499223328866355883644699447755343443392211461625523374428854133966216688667744844811776633886655937734899799112361199377954993377495584433172882553369922556676998872255229811731447799332217722866177997443889338868552276477223661162334488548114998221199113764488213599773329988688944966117871146617554489113129164439225526196481422446633244911667339964232557491145827886611257744767722114552288113993357455119955991889924467788541121174997733556699557799441899225588377224455115576997796112214559944882784422728816364334334116699884488664998446623553264497755448566332255116611998221556679977955882996554335669562788229889225665299263349221164662447558856511442551219667746649989977332774462511998644668822781995779557996611521663116548995211442253447466366775477299855441884499661669449668877221121168812299736679887788774884427711997722445887445577996965429144233645116194993696371384477614488115446566881443352886687558819981711722554488988253374459955773391137881798867752572216659355991137552289881579913661122554677584988116447615348855737144655178332299661929922969979781866155766266911622995488227791127712115223994721335545545566224422691332447984468223355899311662255744228893311335355838913396212293452234429927944854478312898896615933113445566244811779641155442331991445311235577112463367449877679941188337556436677866117744699443344822155144899446455998874455644959936962266855917445523288377447711447744337221244332776776649942711388115122337997856877963369426251155877661445661144661589774499447995566894478855972288225622522966823324477887799699272466336618155914774551169922115411374253544553369563856698553388448844226373399559778998338437745536622553358823877223771183348893392668873399232112435158833668899118811736322489448544252211922844337744117487239418899234776511443886554155266774113311788966776177668774711774196627247443855966426655933421139983974466923399884455661455787334499885511889544557446577448857558813311332211277977225221132233133197769377557612255293349272299778827889987551134399488394355139791221228997188115937799114456624473748844664471631137113399791733442869951"
#Shamelessly stolen from Stack Overflow (/s)
def seq(a):
a = str(a)
k,last,result = 1,a[0],''
for i in range(1,len(a)):
if last==a[i]:k+=1
else:
result = result+str(k)+last
k=1
last = a[i]
result = result+str(k)+last
return result
print(seq(stre))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment