이 도전은 데니스 넘버 생성 과 같은 정신으로 , 캘빈의 취미 ( Helka Homba 로 이름이 변경됨) 인 Legendary Challenge Writer ™에 경의를 표합니다 .
Calvin은 PPCG에 매우 인상적인 기여를했으며 전체적으로 6 위의 명성을 얻었으며 아마도 우리 모두에게 최고의 기술을 썼을 것입니다. 그러나 당연히이 과제에 대해서는 사용자 ID에 중점을 둘 것입니다.
26997은 처음에는 그리 재미 있지 않을 수 있습니다. 실제로
몇 가지면에서 거의 흥미 롭습니다. 예를 들어 다음 26997 mod <n>
은 특정 값에 대한 차트 입니다 n
.
n | 26997 % n
----+-----------
3 | 0
4 | 1
5 | 2
6 | 3
7 | 5 :(
8 | 5
9 | 6
10 | 7
그러나 26997은로 나타낼 수있는 소수 중 하나입니다. 여기서 정수> 0입니다.(n * 10)n - n
n
여기에 우리가 이제부터는 호출 할이 방법으로 표현 될 수있다 처음 몇 숫자 캘빈 번호는 :
9
398
26997
2559996
312499995
46655999994
8235429999993
1677721599999992
387420488999999991
99999999999999999990
28531167061099999999989
8916100448255999999999988
3028751065922529999999999987
1111200682555801599999999999986
437893890380859374999999999999985
184467440737095516159999999999999984
82724026188633676417699999999999999983
39346408075296537575423999999999999999982
19784196556603135891239789999999999999999981
10485759999999999999999999999999999999999999980
이 Calvin Numbers 에는 몇 가지 흥미로운 속성이 있습니다. 패턴을 오른쪽 정렬하고 모든 패턴을 강조 표시하면 더 많은 패턴이 나타납니다 9
.
우리가이 도전에 관심이있는 것은 :
에 관계없이
n
모든 Calvin Number 는로 끝납니다 .10n - n
그래서 캘빈 (1) 단부와
9
캘빈 (2)와 단부,98
및 패턴 계속997
,9996
,99995
각각의 연속으로, 등 캘빈 번호 카운트 다운하고 추가 첨가9
시작한다.n
wheren % 10 == 0
(즉n
, 10으로 나눌 수 있는) 값의 경우 Calvin (n)은로 끝납니다 .102n - n
즉, 패턴은 일반보다 두 배 많은 숫자로 확장되며
9
시작 부분 에 s 가 추가 됩니다n
.때
n
의 힘10
(10
,100
,1000
등), 패턴은 더욱-매 자리 중 하나 인 확장9
또는이0
.이 패턴은 9와 0입니다. 차트에서 이해하기가 더 쉽습니다 (어쨌든 솔루션은 최대 10000까지의 숫자 만 처리하면되므로 필요한 것입니다).
(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
9의 숫자는 심지어 Calvin Numbers 자체 의 여러 속성을 보여 주지만,이 도전에 대해서는 너무 자세합니다.
도전
Calvin Numbers 는 " 정확한 정수가없는 언어에서 n 번째 Calvin Number 과제를 실현할 수 있도록하기에는 너무 빠르며 너무 빠릅니다."따라서 숫자가 위의 패턴에 맞는지 여부, 즉 숫자는 "후보자 캘빈 수"입니다.
다음은 후보 캘빈 번호 로 간주되는 번호의 기준입니다 (이하 CCN이라고합니다).
정수 패턴 에 맞는 숫자로 끝납니다 .
10n - n
n
따라서 CCN이 되려면 숫자는 9 또는 98 또는 997, 9996, 99995 등으로 끝나야합니다.
마지막 숫자가
0
이면 이전 포인트 와 동일하게 로 끝나야합니다 .102n - n
n
이것은 그것이
12312312399999999999999999999999999999999999980
CCN이 아니라는 것을 의미합니다10485759999999999999999999999999999999999999980
(사실 올바른 것입니다).n
이전 두 단계 의 값이 10의 거듭 제곱이면 정수는 위에서 설명한 세 번째 패턴에 맞아야합니다.
입출력
입력은 문자열로 제공되며 항상보다 작은 숫자 Calvin(10000) + 10000
(로 표현 될
수 있음)를 나타냅니다 . (명확하게 말하면, 가능한 최대 입력은 50000 nines이고 가능한 최소 입력은 입니다.)1050000
1
입력 값이 CCN 인 숫자를 나타내면 출력값이 참 값이어야하고, 그렇지 않으면 거짓 값입니다. 이러한 용어 의 정의는 meta를 참조하십시오 .
테스트 사례
확실한 값을 가져야하는 입력 :
9
26997
99999999999999999990
437893890380859374999999999999985
10485759999999999999999999999999999999999999980
999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999900
259232147948794494594485446818048254863271026096382337884099237269509380022108148908589797968903058274437782549758243999867043174477180579595714249308002763427793979644775390624999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999850
1027092382693614216458468213549848274267264533712122209400214436472662418869004625362768700557725707157332451380426829473630485959339004149867738722096608953864534215649211386152032635755501464142277508289403434891444020975243742942368836579910208098242623061684967794815600266752580663281483595687307649904776800899000484103534573979334062832465904049046104660220505973505050538180250643437654409375728443182380726453925959886901573523090619465866810938078629561306599174923972607310649219442207992951278588892681161967770532314854195892941913447519131828356181219857012229150315613569162930098836696593474888020746503116685472977764615483225628639443918309216648893055765917642528801571387940219884056021782642758517893124803355573565644666880920219871370649806723296262307899148031362558110611562055614190049332906933360406981359187305353360484377948591528385990255894034369523166777375785900198782250651053530165824984161319460372145229568890321167955690544235365954748429659526071133879976348254667755220636244075595290123987745560038255541751251200827018722242010925729483977388235141539109139120069464709993781356334885359200734157439642935779132120725231008699003342908280056975158266782782304550273268246184659474285971272532354920744956064671379745219778013465792544241259691493098443741845166419905920702654683993902052727208789915748213660571390107102976665776293366616518962323688316843422737162297255648351087284877987537325761187239807598009767936409247247417410607537333841650998421607775989879490006136112078031237742552602618996017404602674987181629319060214150458746352191115606789019875790921190573561400752476956787515392210098071407806221412149732955903681690377998882038499470092453400748916257640501488510563314141992573250882286817352407459053866180642034662845694338400386823496563185664221362457851894843439705365082614359220653285052800751906334000698723288454227654466240011140570190301931122357632719033275258503935182047714841766010764632214069382579660602964184231995352310981811428980530707871661256260926759509418970021224649566130995825802676411575264295689037775857674060557127369881379685432291930869072749065675720647595081516460449973211035071920099349836074945813885239767788449030051892470053308048906746273036871919251738920141071153777908913021898541658119513188402271468288293408246833819954990709460114510017598873554406350044072275643892449218394225569069468466660333869360644718801813500285081977089623921689922204185138003164149106921903053243405307546841149889662566529697217181329051855403329741409045760789280950603184354320839342588593832348459938736210265795978675460906504449491132656307256451707333439200130425932724262464823848348296787445624028385464112471408499986690593095395244034885421580844176161027627954578726208600199909963055422192706751708210693468639072881081717288837393188012794669089175022406897622823484220002211676520484520241135615999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999028
잘못된 값을 초래하는 입력 :
1
26897
79999999999999999990
437893890380859374299999999999985
12312312399999999999999999999999999999999999980
999998999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999900
259232147948794494594485446818048254863271026096382337884099237269509380022108148908589797968903058274437782549758243999867043174477180579595714249308002763427793979644775390624999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999911111
1027092382693614216458468213549848274267264533712122209400214436472662418869004625362768700557725707157332451380426829473630485959339004149867738722096608953864534215649211386152032635755501464142277508289403434891444020975243742942368836579910208098242623061684967794815600266752580663281483595687307649904776800899000484103534573979334062832465904049046104660220505973505050538180250643437654409375728443182380726453925959886901573523090619465866810938078629561306599174923972607310649219442207992951278588892681161967770532314854195892941913447519131828356181219857012229150315613569162930098836696593474888020746503116685472977764615483225628639443918309216648893055765917642528801571387940219884056021782642758517893124803355573565644666880920219871370649806723296262307899148031362558110611562055614190049332906933360406981359187305353360484377948591528385990255894034369523166777375785900198782250651053530165824984161319460372145229568890321167955690544235365954748429659526071133879976348254667755220636244075595290123987745560038255541751251200827018722242010925729483977388235141539109139120069464709993781356334885359200734157439642935779132120725231008699003342908280056975158266782782304550273268246184659474285971272532354920744956064671379745219778013465792544241259691493098443741845166419905920702654683993902052727208789915748213660571390107102976665776293366616518962323688316843422737162297255648351087284877987537325761187239807598009767936409247247417410607537333841650998421607775989879490006136112078031237742552602618996017404602674987181629319060214150458746352191115606789019875790921190573561400752476956787515392210098071407806221412149732955903681690377998882038499470092453400748916257640501488510563314141992573250882286817352407459053866180642034662845694338400386823496563185664221362457851894843439705365082614359220653285052800751906334000698723288454227654466240011140570190301931122357632719033275258503935182047714841766010764632214069382579660602964184231995352310981811428980530707871661256260926759509418970021224649566130995825802676411575264295689037775857674060557127369881379685432291930869072749065675720647595081516460449973211035071920099349836074945813885239767788449030051892470053308048906746273036871919251738920141071153777908913021898541658119513188402271468288293408246833819954990709460114510017598873554406350044072275643892449218394225569069468466660333869360644718801813500285081977089623921689922204185138003164149106921903053243405307546841149889662566529697217181329051855403329741409045760789280950603184354320839342588593832348459938736210265795978675460906504449491132656307256451707333439200130425932724262464823848348296787445624028385464112471408499986690593095395244034885421580844176161027627954578726208600199909963055422192706751708210693468639072881081717288837393188012794669089175022406897622823484220002211676520484520241135615999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999027
규칙
언어에서 임의 정밀도 정수 (또는 이보다 큰 숫자를 저장할 수있을 정도로 높은 정밀도를 가진 숫자 유형)를 지원하는 경우 프로그램의 어느 시점에서나 ( ) 보다 큰 정수를 처리 할 수 없습니다 .
18446744073709551615
264
이는 가능한 모든 Calvin Number (또는 가능한 모든 값 ) 를 반복하는 솔루션을 방지하기위한 것입니다 .
10n - n
이것은 code-golf 이므로 바이트 단위의 가장 짧은 코드가 승리합니다.
9
것은 진실해야합니다. 결정된.