Tantangan ini merupakan penghargaan untuk Legendary Challenge Writer ™ kami, Calvin Hobbies - sekarang berganti nama menjadi Helka Homba -, dengan semangat yang sama dengan Generate Dennis Numbers .
Calvin adalah kontributor yang cukup mengesankan untuk PPCG, dengan reputasi ke-6 secara keseluruhan dan mungkin tidak terbantahkan keterampilan menulis tantangan terbaik dari kita semua. Namun, tentu saja, untuk tantangan ini, kami akan fokus pada ID penggunanya.
26997 mungkin tidak terlihat sangat menarik pada awalnya. Bahkan, ini hampir
menarik dalam beberapa hal. Misalnya, berikut adalah bagan 26997 mod <n>
untuk nilai-nilai tertentu n
:
n | 26997 % n
----+-----------
3 | 0
4 | 1
5 | 2
6 | 3
7 | 5 :(
8 | 5
9 | 6
10 | 7
Namun, 26997 adalah salah satu dari beberapa angka yang dapat diwakili oleh , di mana bilangan bulat> 0.(n * 10)n - n
n
Berikut adalah beberapa angka pertama yang dapat diekspresikan dengan cara ini, yang selanjutnya akan kita sebut Calvin Numbers :
9
398
26997
2559996
312499995
46655999994
8235429999993
1677721599999992
387420488999999991
99999999999999999990
28531167061099999999989
8916100448255999999999988
3028751065922529999999999987
1111200682555801599999999999986
437893890380859374999999999999985
184467440737095516159999999999999984
82724026188633676417699999999999999983
39346408075296537575423999999999999999982
19784196556603135891239789999999999999999981
10485759999999999999999999999999999999999999980
Ini Calvin Nomor memiliki beberapa sifat menarik. Lebih banyak pola muncul ketika kami meluruskannya dan menyoroti semua 9
s:
Yang kami tertarik untuk tantangan ini adalah:
Terlepas dari
n
, setiap Nomor Calvin berakhir dengan .10n - n
Jadi, Calvin (1) berakhir dengan
9
, Calvin (2) berakhir dengan98
, dan pola berlanjut997
,9996
,99995
, dll, dengan masing-masing berturut-turut Calvin Nomor menghitung mundur dan menambahkan ekstra9
ke awal.Untuk nilai di
n
manan % 10 == 0
(yaitun
dibagi dengan 10), Calvin (n) diakhiri dengan .102n - n
Artinya, polanya meluas dua kali lipat dari angka normal, dengan jumlah ekstra
9
s pada awalnya sama dengann
.Ketika
n
adalah kekuatan10
(10
,100
,1000
, dll), pola meluas lebih jauh-setiap digit tunggal baik9
atau0
.Pola ini adalah sebagai berikut: sembilan, dan nol. Ini lebih mudah dipahami dalam bagan (solusi Anda hanya perlu menangani angka hingga 10.000, jadi ini yang Anda butuhkan):
(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
Jumlah sembilan bahkan memamerkan beberapa properti Calvin Numbers sendiri, tapi itu terlalu detail untuk tantangan ini.
Tantangan
Calvin Numbers menjadi terlalu besar, terlalu cepat, untuk "mendapatkan tantangan Nomor Calvin ke layak dalam bahasa tanpa bilangan bulat presisi sewenang-wenang. Oleh karena itu, tantangannya adalah untuk menentukan apakah angka cocok dengan pola di atas — yaitu, apakah angka adalah "Calvin Calon Nomor" atau tidak.
Berikut adalah kriteria untuk nomor yang akan dipertimbangkan sebagai Calvin Number (selanjutnya disingkat CCN):
Itu berakhir dengan angka yang sesuai dengan pola untuk bilangan bulat .
10n - n
n
Jadi, untuk menjadi CCN, angka harus diakhiri dengan 9, atau 98, atau 997, 9996, 99995, dll.
Jika digit terakhir adalah
0
, itu juga harus diakhiri dengan , sama seperti pada poin sebelumnya.102n - n
n
Ini berarti bahwa
12312312399999999999999999999999999999999999980
itu bukan CCN, tetapi10485759999999999999999999999999999999999999980
(itu yang benar, sebenarnya).Jika nilai
n
dalam dua langkah sebelumnya adalah kekuatan 10, seluruh angka harus sesuai dengan pola ketiga yang dijelaskan di atas.
Input output
Input akan diberikan sebagai string, dan itu akan selalu mewakili angka yang kurang dari Calvin(10000) + 10000
(yang juga dapat dinyatakan sebagai
). (Untuk memperjelas, input sebesar mungkin adalah 50000 sembilan, dan input seminimal mungkin adalah .)1050000
1
Keluaran harus berupa nilai kebenaran jika input mewakili angka yang merupakan CCN, dan nilai palsu sebaliknya. Untuk definisi istilah-istilah ini, lihat meta .
Uji kasus
Input yang menghasilkan nilai kebenaran:
9
26997
99999999999999999990
437893890380859374999999999999985
10485759999999999999999999999999999999999999980
999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999900
259232147948794494594485446818048254863271026096382337884099237269509380022108148908589797968903058274437782549758243999867043174477180579595714249308002763427793979644775390624999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999850
1027092382693614216458468213549848274267264533712122209400214436472662418869004625362768700557725707157332451380426829473630485959339004149867738722096608953864534215649211386152032635755501464142277508289403434891444020975243742942368836579910208098242623061684967794815600266752580663281483595687307649904776800899000484103534573979334062832465904049046104660220505973505050538180250643437654409375728443182380726453925959886901573523090619465866810938078629561306599174923972607310649219442207992951278588892681161967770532314854195892941913447519131828356181219857012229150315613569162930098836696593474888020746503116685472977764615483225628639443918309216648893055765917642528801571387940219884056021782642758517893124803355573565644666880920219871370649806723296262307899148031362558110611562055614190049332906933360406981359187305353360484377948591528385990255894034369523166777375785900198782250651053530165824984161319460372145229568890321167955690544235365954748429659526071133879976348254667755220636244075595290123987745560038255541751251200827018722242010925729483977388235141539109139120069464709993781356334885359200734157439642935779132120725231008699003342908280056975158266782782304550273268246184659474285971272532354920744956064671379745219778013465792544241259691493098443741845166419905920702654683993902052727208789915748213660571390107102976665776293366616518962323688316843422737162297255648351087284877987537325761187239807598009767936409247247417410607537333841650998421607775989879490006136112078031237742552602618996017404602674987181629319060214150458746352191115606789019875790921190573561400752476956787515392210098071407806221412149732955903681690377998882038499470092453400748916257640501488510563314141992573250882286817352407459053866180642034662845694338400386823496563185664221362457851894843439705365082614359220653285052800751906334000698723288454227654466240011140570190301931122357632719033275258503935182047714841766010764632214069382579660602964184231995352310981811428980530707871661256260926759509418970021224649566130995825802676411575264295689037775857674060557127369881379685432291930869072749065675720647595081516460449973211035071920099349836074945813885239767788449030051892470053308048906746273036871919251738920141071153777908913021898541658119513188402271468288293408246833819954990709460114510017598873554406350044072275643892449218394225569069468466660333869360644718801813500285081977089623921689922204185138003164149106921903053243405307546841149889662566529697217181329051855403329741409045760789280950603184354320839342588593832348459938736210265795978675460906504449491132656307256451707333439200130425932724262464823848348296787445624028385464112471408499986690593095395244034885421580844176161027627954578726208600199909963055422192706751708210693468639072881081717288837393188012794669089175022406897622823484220002211676520484520241135615999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999028
Input yang menghasilkan nilai palsu:
1
26897
79999999999999999990
437893890380859374299999999999985
12312312399999999999999999999999999999999999980
999998999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999900
259232147948794494594485446818048254863271026096382337884099237269509380022108148908589797968903058274437782549758243999867043174477180579595714249308002763427793979644775390624999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999911111
1027092382693614216458468213549848274267264533712122209400214436472662418869004625362768700557725707157332451380426829473630485959339004149867738722096608953864534215649211386152032635755501464142277508289403434891444020975243742942368836579910208098242623061684967794815600266752580663281483595687307649904776800899000484103534573979334062832465904049046104660220505973505050538180250643437654409375728443182380726453925959886901573523090619465866810938078629561306599174923972607310649219442207992951278588892681161967770532314854195892941913447519131828356181219857012229150315613569162930098836696593474888020746503116685472977764615483225628639443918309216648893055765917642528801571387940219884056021782642758517893124803355573565644666880920219871370649806723296262307899148031362558110611562055614190049332906933360406981359187305353360484377948591528385990255894034369523166777375785900198782250651053530165824984161319460372145229568890321167955690544235365954748429659526071133879976348254667755220636244075595290123987745560038255541751251200827018722242010925729483977388235141539109139120069464709993781356334885359200734157439642935779132120725231008699003342908280056975158266782782304550273268246184659474285971272532354920744956064671379745219778013465792544241259691493098443741845166419905920702654683993902052727208789915748213660571390107102976665776293366616518962323688316843422737162297255648351087284877987537325761187239807598009767936409247247417410607537333841650998421607775989879490006136112078031237742552602618996017404602674987181629319060214150458746352191115606789019875790921190573561400752476956787515392210098071407806221412149732955903681690377998882038499470092453400748916257640501488510563314141992573250882286817352407459053866180642034662845694338400386823496563185664221362457851894843439705365082614359220653285052800751906334000698723288454227654466240011140570190301931122357632719033275258503935182047714841766010764632214069382579660602964184231995352310981811428980530707871661256260926759509418970021224649566130995825802676411575264295689037775857674060557127369881379685432291930869072749065675720647595081516460449973211035071920099349836074945813885239767788449030051892470053308048906746273036871919251738920141071153777908913021898541658119513188402271468288293408246833819954990709460114510017598873554406350044072275643892449218394225569069468466660333869360644718801813500285081977089623921689922204185138003164149106921903053243405307546841149889662566529697217181329051855403329741409045760789280950603184354320839342588593832348459938736210265795978675460906504449491132656307256451707333439200130425932724262464823848348296787445624028385464112471408499986690593095395244034885421580844176161027627954578726208600199909963055422192706751708210693468639072881081717288837393188012794669089175022406897622823484220002211676520484520241135615999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999027
Aturan
Anda tidak boleh , pada titik mana pun dalam program Anda, menangani bilangan bulat yang lebih besar dari
18446744073709551615
( ), jika bahasa Anda memiliki dukungan untuk bilangan bulat presisi sewenang-wenang (atau tipe angka dengan presisi yang cukup tinggi untuk memungkinkan menyimpan angka lebih besar dari ini).264
Ini hanya untuk mencegah solusi yang melewati semua Calvin Numbers yang mungkin (atau semua nilai yang mungkin dari ).
10n - n
Ini adalah kode-golf , jadi kode terpendek dalam byte akan menang.
9
harus jujur. Tetap.