在发布此挑战之前,我没有检查沙盒 -似乎是CᴏɴᴏʀO'Bʀɪᴇɴ提出的挑战。
给定一个整数输入,编写一个打印“四是一个魔术数字”之谜的程序
- 四是魔数
- 五是四,四是魔数
- 六是三,三是五,五是四,四是魔数
- 十一是六,六是三,三是五,五是四,四是魔数
- 五百是十一,十一是六,六是三,三是五,五是四,四是魔数
如果您已经知道了谜语,或者太懒了而无法解决它,就急于找出谜语是什么,这里有一个解释
下一个数字是上一个数字中的字母数。因此,例如,五个有四个字母,因此下一个数字是四个。
六个有三个字母,所以下一个数字是3,三个有五个字母,所以下一个数字是5,五个有四个字母,所以下一个数字是4
谜题以4结尾的原因是因为四个有四个字母,四个是四个,四个是四个,四个是四个...(四个是魔幻数字)
测试用例
0 =>
Zero is four and four is the magic number
1 =>
One is three and three is five and five is four and four is the magic number
2 =>
Two is three and three is five and five is four and four is the magic number
3 =>
Three is five and five is four and four is the magic number
4 =>
Four is the magic number
5 =>
Five is four and four is the magic number
6 =>
Six is three and three is five and five is four and four is the magic number
7 =>
Seven is five and five is four and four is the magic number
8 =>
Eight is five and five is four and four is the magic number
9 =>
Nine is four and four is the magic number
10 =>
Ten is three and three is five and five is four and four is the magic number
17 =>
Seventeen is nine and nine is four and four is the magic number
100 =>
One Hundred is ten and ten is three and three is five and five is four and four is the magic number
142 =>
One Hundred Forty Two is eighteen and eighteen is eight and eight is five and five is four and four is the magic number
1,000 =>
One Thousand is eleven and eleven is six and six is three and three is five and five is four and four is the magic number
1,642 =>
One Thousand Six Hundred Forty Two is twenty nine and twenty nine is ten and ten is three and three is five and five is four and four is the magic number
70,000 =>
Seventy Thousand is fifteen and fifteen is seven and seven is five and five is four and four is the magic number
131,072 =>
One Hundred Thirty One Thousand Seventy Two is thirty seven and thirty seven is eleven and eleven is six and six is three and three is five and five is four and four is the magic number
999,999 =>
Nine Hundred Ninety Nine Thousand Nine Hundred Ninety Nine is fifty and fifty is five and five is four and four is the magic number
规则
- 输入可以取自
STDIN
函数或可以作为函数的参数 - 输入为0到999,999之间的正数
- 输入将仅包含数字(它将遵循regex
^[0-9]+$
) - 输入可以是整数或字符串
- 当转换为字串时,计数中不应包含空格和连字符(100 [一百]是10个字符,而不是11。1,742 [一千七百四十二]是31个字符,而不是36)
- 当转换为字符串时,100应该是一百,而不是一百或一百,1000应该是一千,而不是一千或一千。
- 当转换为字符串142应该是一百四两个,而不是一百和四十二
- 输出不区分大小写,并且应遵循以下格式:“ N是K,K是M,M是...,并且四是幻数”(除非输入为4,在这种情况下,输出应为“四”是魔术数字”)
- 只要您的程序始终一致,输出就可以使用数字而不是字母(“ 5是4,4是幻数”而不是“ 5是4和4是幻数”)
- 输出可以是函数的返回值,也可以打印为
STDOUT
- 适用标准漏洞
- 这是代码高尔夫球,因此以字节为单位的最短程序获胜。祝好运!
奖金
如果程序在输入介于-999,999和999,999之间时工作,则为-30个字节。
负数转换为单词时,在其前面仅带有“负数”。例如-4
“负四”,负四是十二,十二是六,六是三,三是五,五是四,四是魔数
-150字节(如果程序未使用任何内置函数来生成数字的字符串表示形式)
排行榜
这是一个堆栈片段,可按语言生成排行榜和获胜者概述。
为确保您的答案显示出来,请使用以下Markdown模板以标题开头
## Language Name, N bytes
N是提交内容的大小(以字节为单位)
如果要在标头中包含多个数字(例如,敲击旧分数或在字节数中包含标志),只需确保实际分数是标头中的最后一个数字
## Language Name, <s>K</s> X + 2 = N bytes