Skip to content

Instantly share code, notes, and snippets.

@bhuber
Last active December 16, 2015 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhuber/5401882 to your computer and use it in GitHub Desktop.
Save bhuber/5401882 to your computer and use it in GitHub Desktop.
Bob the Bungler
Our building is secured by locked doors with keypads. The keypads have 10 digits
on them (0 - 9) and require a 4-digit access code to unlock the doors.
Unfortunately, they were designed by Bob the Bungler, so rather than typing 4
digits and hitting "Enter", they simply wait for the right sequence of digits to
be pressed and then unlock. So for example if the code is "1234", and someone
enters "2938470871234" it will open on the last digit. What is the minimum
number of digits you have to enter to try all possible combinations?
Here's the answer. In order to avoid spoilers, I won't tell you how long it is.
00001000200030004000500060007000800090011001200130014001500160017001800190021002
20023002400250026002700280029003100320033003400350036003700380039004100420043004
40045004600470048004900510052005300540055005600570058005900610062006300640065006
60067006800690071007200730074007500760077007800790081008200830084008500860087008
80089009100920093009400950096009700980099010102010301040105010601070108010901110
11201130114011501160117011801190121012201230124012501260127012801290131013201330
13401350136013701380139014101420143014401450146014701480149015101520153015401550
15601570158015901610162016301640165016601670168016901710172017301740175017601770
17801790181018201830184018501860187018801890191019201930194019501960197019801990
20203020402050206020702080209021102120213021402150216021702180219022102220223022
40225022602270228022902310232023302340235023602370238023902410242024302440245024
60247024802490251025202530254025502560257025802590261026202630264026502660267026
80269027102720273027402750276027702780279028102820283028402850286028702880289029
10292029302940295029602970298029903030403050306030703080309031103120313031403150
31603170318031903210322032303240325032603270328032903310332033303340335033603370
33803390341034203430344034503460347034803490351035203530354035503560357035803590
36103620363036403650366036703680369037103720373037403750376037703780379038103820
38303840385038603870388038903910392039303940395039603970398039904040504060407040
80409041104120413041404150416041704180419042104220423042404250426042704280429043
10432043304340435043604370438043904410442044304440445044604470448044904510452045
30454045504560457045804590461046204630464046504660467046804690471047204730474047
50476047704780479048104820483048404850486048704880489049104920493049404950496049
70498049905050605070508050905110512051305140515051605170518051905210522052305240
52505260527052805290531053205330534053505360537053805390541054205430544054505460
54705480549055105520553055405550556055705580559056105620563056405650566056705680
56905710572057305740575057605770578057905810582058305840585058605870588058905910
59205930594059505960597059805990606070608060906110612061306140615061606170618061
90621062206230624062506260627062806290631063206330634063506360637063806390641064
20643064406450646064706480649065106520653065406550656065706580659066106620663066
40665066606670668066906710672067306740675067606770678067906810682068306840685068
60687068806890691069206930694069506960697069806990707080709071107120713071407150
71607170718071907210722072307240725072607270728072907310732073307340735073607370
73807390741074207430744074507460747074807490751075207530754075507560757075807590
76107620763076407650766076707680769077107720773077407750776077707780779078107820
78307840785078607870788078907910792079307940795079607970798079908080908110812081
30814081508160817081808190821082208230824082508260827082808290831083208330834083
50836083708380839084108420843084408450846084708480849085108520853085408550856085
70858085908610862086308640865086608670868086908710872087308740875087608770878087
90881088208830884088508860887088808890891089208930894089508960897089808990909110
91209130914091509160917091809190921092209230924092509260927092809290931093209330
93409350936093709380939094109420943094409450946094709480949095109520953095409550
95609570958095909610962096309640965096609670968096909710972097309740975097609770
97809790981098209830984098509860987098809890991099209930994099509960997099809991
11121113111411151116111711181119112211231124112511261127112811291132113311341135
11361137113811391142114311441145114611471148114911521153115411551156115711581159
11621163116411651166116711681169117211731174117511761177117811791182118311841185
11861187118811891192119311941195119611971198119912121312141215121612171218121912
22122312241225122612271228122912321233123412351236123712381239124212431244124512
46124712481249125212531254125512561257125812591262126312641265126612671268126912
72127312741275127612771278127912821283128412851286128712881289129212931294129512
96129712981299131314131513161317131813191322132313241325132613271328132913321333
13341335133613371338133913421343134413451346134713481349135213531354135513561357
13581359136213631364136513661367136813691372137313741375137613771378137913821383
13841385138613871388138913921393139413951396139713981399141415141614171418141914
22142314241425142614271428142914321433143414351436143714381439144214431444144514
46144714481449145214531454145514561457145814591462146314641465146614671468146914
72147314741475147614771478147914821483148414851486148714881489149214931494149514
96149714981499151516151715181519152215231524152515261527152815291532153315341535
15361537153815391542154315441545154615471548154915521553155415551556155715581559
15621563156415651566156715681569157215731574157515761577157815791582158315841585
15861587158815891592159315941595159615971598159916161716181619162216231624162516
26162716281629163216331634163516361637163816391642164316441645164616471648164916
52165316541655165616571658165916621663166416651666166716681669167216731674167516
76167716781679168216831684168516861687168816891692169316941695169616971698169917
17181719172217231724172517261727172817291732173317341735173617371738173917421743
17441745174617471748174917521753175417551756175717581759176217631764176517661767
17681769177217731774177517761777177817791782178317841785178617871788178917921793
17941795179617971798179918181918221823182418251826182718281829183218331834183518
36183718381839184218431844184518461847184818491852185318541855185618571858185918
62186318641865186618671868186918721873187418751876187718781879188218831884188518
86188718881889189218931894189518961897189818991919221923192419251926192719281929
19321933193419351936193719381939194219431944194519461947194819491952195319541955
19561957195819591962196319641965196619671968196919721973197419751976197719781979
19821983198419851986198719881989199219931994199519961997199819992222322242225222
62227222822292233223422352236223722382239224322442245224622472248224922532254225
52256225722582259226322642265226622672268226922732274227522762277227822792283228
42285228622872288228922932294229522962297229822992323242325232623272328232923332
33423352336233723382339234323442345234623472348234923532354235523562357235823592
36323642365236623672368236923732374237523762377237823792383238423852386238723882
38923932394239523962397239823992424252426242724282429243324342435243624372438243
92443244424452446244724482449245324542455245624572458245924632464246524662467246
82469247324742475247624772478247924832484248524862487248824892493249424952496249
72498249925252625272528252925332534253525362537253825392543254425452546254725482
54925532554255525562557255825592563256425652566256725682569257325742575257625772
57825792583258425852586258725882589259325942595259625972598259926262726282629263
32634263526362637263826392643264426452646264726482649265326542655265626572658265
92663266426652666266726682669267326742675267626772678267926832684268526862687268
82689269326942695269626972698269927272827292733273427352736273727382739274327442
74527462747274827492753275427552756275727582759276327642765276627672768276927732
77427752776277727782779278327842785278627872788278927932794279527962797279827992
82829283328342835283628372838283928432844284528462847284828492853285428552856285
72858285928632864286528662867286828692873287428752876287728782879288328842885288
62887288828892893289428952896289728982899292933293429352936293729382939294329442
94529462947294829492953295429552956295729582959296329642965296629672968296929732
97429752976297729782979298329842985298629872988298929932994299529962997299829993
33343335333633373338333933443345334633473348334933543355335633573358335933643365
33663367336833693374337533763377337833793384338533863387338833893394339533963397
33983399343435343634373438343934443445344634473448344934543455345634573458345934
64346534663467346834693474347534763477347834793484348534863487348834893494349534
96349734983499353536353735383539354435453546354735483549355435553556355735583559
35643565356635673568356935743575357635773578357935843585358635873588358935943595
35963597359835993636373638363936443645364636473648364936543655365636573658365936
64366536663667366836693674367536763677367836793684368536863687368836893694369536
96369736983699373738373937443745374637473748374937543755375637573758375937643765
37663767376837693774377537763777377837793784378537863787378837893794379537963797
37983799383839384438453846384738483849385438553856385738583859386438653866386738
68386938743875387638773878387938843885388638873888388938943895389638973898389939
39443945394639473948394939543955395639573958395939643965396639673968396939743975
39763977397839793984398539863987398839893994399539963997399839994444544464447444
84449445544564457445844594465446644674468446944754476447744784479448544864487448
84489449544964497449844994545464547454845494555455645574558455945654566456745684
56945754576457745784579458545864587458845894595459645974598459946464746484649465
54656465746584659466546664667466846694675467646774678467946854686468746884689469
54696469746984699474748474947554756475747584759476547664767476847694775477647774
77847794785478647874788478947954796479747984799484849485548564857485848594865486
64867486848694875487648774878487948854886488748884889489548964897489848994949554
95649574958495949654966496749684969497549764977497849794985498649874988498949954
99649974998499955556555755585559556655675568556955765577557855795586558755885589
55965597559855995656575658565956665667566856695676567756785679568656875688568956
96569756985699575758575957665767576857695776577757785779578657875788578957965797
57985799585859586658675868586958765877587858795886588758885889589658975898589959
59665967596859695976597759785979598659875988598959965997599859996666766686669667
76678667966876688668966976698669967676867696777677867796787678867896797679867996
86869687768786879688768886889689768986899696977697869796987698869896997699869997
77787779778877897798779978787978887889789878997979887989799879998888988998989999
000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment