Bu meydan okuma, Calvin'in Hobileri olan - artık Helka Homba olarak adlandırılan - Efsanevi Mücadelemiz Yazar ™ 'a, şimdi Dennis Numaraları Üretme ile aynı ruh haliyle bir hediyedir .
Calvin, PPCG'ye oldukça etkileyici bir katkıda bulunuyor, genel olarak 6. en ünlüsü ve muhtemelen hepimizin tartışmasız en iyi mücadele yazma becerileri. Ancak, elbette, bu zorluk için, kullanıcı kimliğine odaklanacağız.
26997 ilk başta çok ilginç görünmeyebilir. Aslında,
birkaç şekilde neredeyse ilginç. Örneğin, işte 26997 mod <n>
belirli değerlerin şeması n
:
n | 26997 % n
----+-----------
3 | 0
4 | 1
5 | 2
6 | 3
7 | 5 :(
8 | 5
9 | 6
10 | 7
Ancak, 26.997 ile temsil edilebilir birkaç sayılarından biridir , burada bir tamsayı> 0'dır.(n * 10)n - n
n
İşte bu şekilde ifade edilebilecek ilk birkaç sayı. Bundan sonra Calvin Numbers diyeceğiz :
9
398
26997
2559996
312499995
46655999994
8235429999993
1677721599999992
387420488999999991
99999999999999999990
28531167061099999999989
8916100448255999999999988
3028751065922529999999999987
1111200682555801599999999999986
437893890380859374999999999999985
184467440737095516159999999999999984
82724026188633676417699999999999999983
39346408075296537575423999999999999999982
19784196556603135891239789999999999999999981
10485759999999999999999999999999999999999999980
Bu Calvin Numaraları bazı ilginç özelliklere sahiptir. Doğru hizaladığımızda ve tüm özellikleri vurguladığımızda daha fazla desen ortaya çıkıyor 9
:
Bu meydan okuma için ilgilendiklerimiz:
Ne olursa olsun
n
, her Calvin Number ile bitiyor .10n - n
Yani, Calvin (1) ile biter
9
Calvin (2) ile biter,98
ve desen devam997
,9996
,99995
birbirini izleyen her ile, vb Calvin Sayısı geri sayıma ve ekstra ekleyerek9
başına.Değerleri için (yani, 10 ile divisble olan), Calvin, (n) ile uçları .
n
n % 10 == 0
n
102n - n
Yani, desen normalin iki katı haneye kadar uzanır
9
ve başlangıçta eşit miktarda s bulunurn
.Ne zaman
n
bir güç10
(10
,100
,1000
ve benzeri), model daha da-her bir basamak ya da a, uzanmaktadır9
ya da0
.Bu kalıp şudur: dokuz ve sıfır. Bir grafikte bunu anlamak daha kolaydır (çözümünüz yine de sadece 10000'e kadar sayıları idare etmek zorunda kalacak, bu yüzden tek ihtiyacınız olan şey bu):
(n + 1) * 10n - n
n
n | Calvin(n) -------+----------------------- 10 | 19 nines, 1 zero 100 | 298 nines, 2 zeroes 1000 | 3997 nines, 3 zeroes 10000 | 49998 nines, 4 zeroes
Dokuzların sayısı, Calvin Numbers'ın kendisinin çeşitli özelliklerini bile sergiliyor , ancak bu zorluk için çok fazla ayrıntı.
Meydan okuma
Sayılar Calvin için, çok çabuk, çok büyük olsun, bir "inci olsun Calvin Numarası keyfi kesinlikte tamsayılar olmadan dilde mümkün olduğu meydan. Bu nedenle, meydan olsun, bir sayı yukarıdaki desenleri-is uyup uymadığını belirlemektir bir sayı "aday Calvin Numarası" dır veya değildir.
Bir adayın Calvin Number olarak sayılması gereken kriterler: (bundan sonra kısaca CCN olarak anılacaktır):
Bir tamsayı için desene uyan bir sayı ile sona erer .
10n - n
n
Bu nedenle, bir CCN olması için, bir sayının 9 veya 98 veya 997, 9996, 99995 vb. İle bitmesi gerekir.
Son hane ise
0
, önceki noktadakiyle aynı şekilde bitmelidir .102n - n
n
Bu
12312312399999999999999999999999999999999999980
, bir CCN olmadığı anlamına gelir , ancak10485759999999999999999999999999999999999999980
(aslında doğru olanıdır).n
Önceki iki adımdaki değer 10'luk bir güç ise, tüm sayılar yukarıda açıklanan üçüncü desene uymalıdır.
Giriş çıkış
Girdi, bir dize olarak sağlanacak ve her zaman Calvin(10000) + 10000
(aynı zamanda ifade edilebilecek
) değerinden daha küçük bir sayıyı temsil edecektir . (Netleştirmek için, mümkün olan en büyük giriş 50000 dokuzdur ve mümkün olan en düşük girişdir .)1050000
1
Girdi bir CCN olan bir sayıyı temsil ediyorsa ve aksi takdirde sahte bir değerse çıktı, gerçek bir değer olmalıdır. İçin Bu terimlerin tanımları, meta bkz .
Test durumları
Gerçek bir değere yol açması gereken girdiler:
9
26997
99999999999999999990
437893890380859374999999999999985
10485759999999999999999999999999999999999999980
999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999900
259232147948794494594485446818048254863271026096382337884099237269509380022108148908589797968903058274437782549758243999867043174477180579595714249308002763427793979644775390624999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999850
1027092382693614216458468213549848274267264533712122209400214436472662418869004625362768700557725707157332451380426829473630485959339004149867738722096608953864534215649211386152032635755501464142277508289403434891444020975243742942368836579910208098242623061684967794815600266752580663281483595687307649904776800899000484103534573979334062832465904049046104660220505973505050538180250643437654409375728443182380726453925959886901573523090619465866810938078629561306599174923972607310649219442207992951278588892681161967770532314854195892941913447519131828356181219857012229150315613569162930098836696593474888020746503116685472977764615483225628639443918309216648893055765917642528801571387940219884056021782642758517893124803355573565644666880920219871370649806723296262307899148031362558110611562055614190049332906933360406981359187305353360484377948591528385990255894034369523166777375785900198782250651053530165824984161319460372145229568890321167955690544235365954748429659526071133879976348254667755220636244075595290123987745560038255541751251200827018722242010925729483977388235141539109139120069464709993781356334885359200734157439642935779132120725231008699003342908280056975158266782782304550273268246184659474285971272532354920744956064671379745219778013465792544241259691493098443741845166419905920702654683993902052727208789915748213660571390107102976665776293366616518962323688316843422737162297255648351087284877987537325761187239807598009767936409247247417410607537333841650998421607775989879490006136112078031237742552602618996017404602674987181629319060214150458746352191115606789019875790921190573561400752476956787515392210098071407806221412149732955903681690377998882038499470092453400748916257640501488510563314141992573250882286817352407459053866180642034662845694338400386823496563185664221362457851894843439705365082614359220653285052800751906334000698723288454227654466240011140570190301931122357632719033275258503935182047714841766010764632214069382579660602964184231995352310981811428980530707871661256260926759509418970021224649566130995825802676411575264295689037775857674060557127369881379685432291930869072749065675720647595081516460449973211035071920099349836074945813885239767788449030051892470053308048906746273036871919251738920141071153777908913021898541658119513188402271468288293408246833819954990709460114510017598873554406350044072275643892449218394225569069468466660333869360644718801813500285081977089623921689922204185138003164149106921903053243405307546841149889662566529697217181329051855403329741409045760789280950603184354320839342588593832348459938736210265795978675460906504449491132656307256451707333439200130425932724262464823848348296787445624028385464112471408499986690593095395244034885421580844176161027627954578726208600199909963055422192706751708210693468639072881081717288837393188012794669089175022406897622823484220002211676520484520241135615999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999028
Sahte bir değere yol açması gereken girdiler:
1
26897
79999999999999999990
437893890380859374299999999999985
12312312399999999999999999999999999999999999980
999998999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999900
259232147948794494594485446818048254863271026096382337884099237269509380022108148908589797968903058274437782549758243999867043174477180579595714249308002763427793979644775390624999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999911111
1027092382693614216458468213549848274267264533712122209400214436472662418869004625362768700557725707157332451380426829473630485959339004149867738722096608953864534215649211386152032635755501464142277508289403434891444020975243742942368836579910208098242623061684967794815600266752580663281483595687307649904776800899000484103534573979334062832465904049046104660220505973505050538180250643437654409375728443182380726453925959886901573523090619465866810938078629561306599174923972607310649219442207992951278588892681161967770532314854195892941913447519131828356181219857012229150315613569162930098836696593474888020746503116685472977764615483225628639443918309216648893055765917642528801571387940219884056021782642758517893124803355573565644666880920219871370649806723296262307899148031362558110611562055614190049332906933360406981359187305353360484377948591528385990255894034369523166777375785900198782250651053530165824984161319460372145229568890321167955690544235365954748429659526071133879976348254667755220636244075595290123987745560038255541751251200827018722242010925729483977388235141539109139120069464709993781356334885359200734157439642935779132120725231008699003342908280056975158266782782304550273268246184659474285971272532354920744956064671379745219778013465792544241259691493098443741845166419905920702654683993902052727208789915748213660571390107102976665776293366616518962323688316843422737162297255648351087284877987537325761187239807598009767936409247247417410607537333841650998421607775989879490006136112078031237742552602618996017404602674987181629319060214150458746352191115606789019875790921190573561400752476956787515392210098071407806221412149732955903681690377998882038499470092453400748916257640501488510563314141992573250882286817352407459053866180642034662845694338400386823496563185664221362457851894843439705365082614359220653285052800751906334000698723288454227654466240011140570190301931122357632719033275258503935182047714841766010764632214069382579660602964184231995352310981811428980530707871661256260926759509418970021224649566130995825802676411575264295689037775857674060557127369881379685432291930869072749065675720647595081516460449973211035071920099349836074945813885239767788449030051892470053308048906746273036871919251738920141071153777908913021898541658119513188402271468288293408246833819954990709460114510017598873554406350044072275643892449218394225569069468466660333869360644718801813500285081977089623921689922204185138003164149106921903053243405307546841149889662566529697217181329051855403329741409045760789280950603184354320839342588593832348459938736210265795978675460906504449491132656307256451707333439200130425932724262464823848348296787445624028385464112471408499986690593095395244034885421580844176161027627954578726208600199909963055422192706751708210693468639072881081717288837393188012794669089175022406897622823484220002211676520484520241135615999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999027
kurallar
Şunları değil programınıza herhangi bir noktada, daha sap tamsayılar büyük
18446744073709551615
( ), dil (bundan daha büyük sayılar depolamak izin için yeterince yüksek bir hassasiyetle veya sayı tipleri) keyfi kesinlikte tamsayılar için destek varsa.264
Bu, yalnızca tüm olası Calvin Numaraları (veya tüm olası değerleri) arasında dolaşan çözümleri önlemek içindir .
10n - n
Bu kod golf , yani bayt cinsinden en kısa kod kazanacak.
9
truthy olmalı. Sabit.