MYSTellany -- Combinatorics and Riven
The 3129 digits below form what's called a "de Bruijn sequence of order 5 on
the alphabet {1, 2, 3, 4, 5}" [*]. In other words, every possible five-digit
sequence -- consisting only of the digits 1 through 5 -- appears exactly once.
For example, you can search the text and verify that each of the sequences
11111, 12345, 54321, and 55555 appears once and only once.
[*] Technical note: The actual definition of a de Bruijn sequence deals with
circular sequences, so in fact the first 3125 digits below form a de Bruijn
sequence, and the last four digits (which repeat the first four) should be
ignored. The sequence below also has an interesting mathematical property:
It's the lexicographically smallest sequence such that the first 5^n digits
form a de Bruijn sequence of order n, for n = 1, 2, 3, 4, 5.
1234511314152242533554432111212213222311421431241151251331341351441452153154225232332433342352442453
2543435344454551552555354121122211321213111133213331123121411141223214221232214421143223312241233322
4311342124213431312351115211532151124323132324131334112521253115411352135312541324222244114431423143
3144412443323412551145121523151315241413351225115512451325141424151425151525221543153315531354215541
4341445143513441345222532254232524233432444223422452335223532354325341534242434252535153523433442344
3445243525441544254515453145332552145415551355145522553245424453434535333353552355334543354444354544
5534554255435552455554525123111221111123211211131121321131211331113221123311313113231122312212114112
1421114222122221312223222141212123131321313422114232122332114411114311144221331212412133221243121341
1124132141311413223133141131511115113241113412143212332222233312314123152121441215121151321521314212
1532213423113332124412214233131431322411224211242214332143421134321323314223142421224321443221513323
1232314413124231243311433313243133241222413315122152211522215332153411325211153111542115432154122442
1234114141142431413414124142131531215423134331244222341314423153231541315433133331432321344213244132
3421334214143143431124441123423223232242232421424414144151141512324322242323431223432244311444214443
1233412252132531225313155111251113511215513115141152321552112532115522125121252222512225223155231152
4215143151442411334314433152232511225411155321254212552223512135123351133521135321352213541124521145
2214511145311254311533315343152331544113443134441332512415214153132541232532323513125142152431545112
3521225512145231252313513225131352314513145241143441153441234341154431554213552123531135431253311554
3135331255311454214532145511255411455312344142241432414425113451223522243322344224241242422434123541
3334132551323523225241251521515115153141451412524324234142342413424325132451142521425314254141541425
5141352413534124343233332325422155331355314352143531335314452124531245411555213354144341334415234151
3415244153241533414334154241453413434222451235511355412455122453314543145541344511525114354151541525
3151551422514325224154341551512425125251342513515135251443511445313453152541535115353153542225432253
3225523244232452233422335322255422354233233443234442333433242442522515325154251451514525215255152252
5233252342532425235141552415534145441253421535512535215444143551333513345133551533514235152352524432
4344242353323534225343254421545213454125443332443423354242542433424435224351243532435425245142451524
5242254442435522345214454135441355511545414555143351543514345144441554414445124451343515535125452244
4325533245342343523335235351353522535325254253442535433253332545322355242452532535532245432355423453
2335525155451255515445153451555315554154552155552245523345232554422555234453244522545422445423544235
5532345425433333444334343335434245442444425524335242553425445234551345524445254352434524455144552525
5253342555424553255553334533355343353343543533525345255352453514535255453344543443355543245543345533
5343553534534435353544343444445335451354523545345443554345451454524545354553554545435445444345552545
54445545553445554453555551234