四是魔数


26

在发布此挑战之前,我没有检查沙盒 -似乎是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应该是一百四两个,而不是一百四十二
  • 输出不区分大小写,并且应遵循以下格式:“ NKKMM是...,并且四是幻数”(除非输入为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


有最大可能的输入量吗?
Arcturus

7
以后,请同时检查沙盒,看看是否有人对您有想法
El'endia Starman

@ El'endiaStarman好吧,我在与该帖子相关的挑战活动的顶部添加了一些文字
Jojodmo 2015年

您的内置函数奖金应该更像-150到-200字节。
TanMath

1
我只是想把它扔掉-对于大多数语言,即使是最疯狂地优化的数字转换器,也几乎不会花费少于150字节的成本,因为它可以使-150成为陷阱而不是奖金。
ricdesi

Answers:


9

Bash +通用实用程序(包括bsd游戏),123-30 = 93字节

for((n=$1;n-4;n=m)){
m=`number -l -- $n|sed 's/nus/&&/;s/\W//g'`
s+="$n is $[m=${#m}] and "
}
echo $s 4 is the magic number

幸运的是,bsd-games number实用程序的输出几乎正是我们所需要的。按照第8个要点,输出编号均以数字形式而不是文字形式:

$ ./4magic.sh 131072
131072 is 37 and 37 is 11 and 11 is 6 and 6 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number
$ ./4magic.sh -4
-4 is 12 and 12 is 6 and 6 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number
$ 

6

C,263261字节-180 = 81

char*i="jmmonnmoonmpprrqqsrrjjddeeecdd",x;f(n,c){return!n?n:n<0?f(-n,8):n<100?c+i[n<20?n:n%10]-i[20+n/10]:f(n/1000,8)+f(n/100%10,7)+f(n/100%10,0)+c;}main(int c,char**v){for(c=atoi(*++v);c-4;c=x)printf("%d is %d and ",c,x=c?f(c,0)):4;puts("4 is the magic number");}

受到Cole Cameron的回答的启发。我以为没有宏定义,我也许可以做得更好。尽管我最终做到了,但确实需要花些力气才能实现!

它需要一个带有连续字母的主机字符集(因此ASCII可以,但是EBCDIC将不起作用)。这是用于一对查找表的。我选择j了零字符,并且利用了需要进行两次查找的优势,因此我可以从另一个中减去一个,而不必从两个中都减去我的零。

评论版本:

char*i=
    "jmmonnmoon"                /* 0 to 9 */
    "mpprrqqsrr"                /* 10 to 19 */
    "jjddeeecdd";               /* tens */
char x;                /* current letter count */

f(n,c){
return
    !n?n                        /* zero - return 0 (ignore c) */
    :n<0?f(-n,8)                /* negative n (only reached if c==0) */
    :n<100?c+i[n<20?n:n%10]-i[20+n/10] /* lookup tables */
    :
      f(n/1000,8)               /* thousand */
    + f(n/100%10,7)             /* hundred */
    + f(n%100,0)                /* rest */
    + c;                        /* carry-in */
}
main(int c, char**v)
{
    for(c=atoi(*++v);c-4;c=x)
        printf("%d is %d and ",c,x=c?f(c,0):4);
    puts("4 is the magic number");
}

通过替换f(n/1000,8)为,显然可以扩展支持数百万美元f(n/1000000,7)+f(n/1000%1000,8)

测试输出

0 is 4 and 4 is the magic number
1 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number
2 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number
3 is 5 and 5 is 4 and 4 is the magic number
4 is the magic number
5 is 4 and 4 is the magic number
6 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number
7 is 5 and 5 is 4 and 4 is the magic number
8 is 5 and 5 is 4 and 4 is the magic number
9 is 4 and 4 is the magic number
10 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number
17 is 9 and 9 is 4 and 4 is the magic number
100 is 10 and 10 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number
142 is 18 and 18 is 8 and 8 is 5 and 5 is 4 and 4 is the magic number
1000 is 11 and 11 is 6 and 6 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number
1642 is 29 and 29 is 10 and 10 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number
70000 is 15 and 15 is 7 and 7 is 5 and 5 is 4 and 4 is the magic number
131072 is 37 and 37 is 11 and 11 is 6 and 6 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number
999999 is 50 and 50 is 5 and 5 is 4 and 4 is the magic number

4

Mathematica,156-30 = 126个字节

a=ToString;({a@#," is ",a@#2," and "}&@@@Partition[NestWhileList[#~IntegerName~"Words"~StringCount~LetterCharacter&,#,#!=4&],2,1])<>"4 is the magic number"&

令我惊讶的是它使用字符串,而且时间不长。


4

迅速2408 419 - 30 = 389个字节

如果Swift的正则表达式不是那么冗长(除去连字符和空格),我将能够摆脱176个字节。

func c(var s:Int)->String{var r="";while(s != 4){r+="\(s)";let f=NSNumberFormatter();f.numberStyle=NSNumberFormatterStyle.SpellOutStyle;let v=f.stringFromNumber(s)!;s=v.stringByReplacingOccurrencesOfString("[- ]",withString:"",options:NSStringCompareOptions.RegularExpressionSearch,range:Range<String.Index>(start:v.startIndex,end:v.endIndex)).utf8.count+(s<0 ?3:0);r+=" is \(s) and "};return r+"4 is the magic number"}

可以在swiftstub.com上进行测试,这里

我运行了一点for循环,结果100003是0到999999之间的数字具有最长的字符串结果,该结果有6次迭代,并且是

1000032323111166335544是幻数

不打高尔夫球

func a(var s: Int) -> String{
    var r = ""
    while(s != 4){
        r+="\(s)"

        let f = NSNumberFormatter()
        f.numberStyle = NSNumberFormatterStyle.SpellOutStyle
        let v = f.stringFromNumber(s)!
        s = v.stringByReplacingOccurrencesOfString(
            "[- ]",
            withString: "",
            options: NSStringCompareOptions.RegularExpressionSearch,
            range: Range<String.Index>(start: v.startIndex, end: v.endIndex)
        ).utf8.count + (s < 0 ? 3 : 0)

        r+=" is \(s) and "
    }
    return r+"4 is the magic number"
}

7
NSStringCompareOptions.RegularExpressionSearch我以为JS String.fromCharCode太冗长了。:P
ETHproductions 2015年

4
Python和Ruby: string.replace。斯威夫特:String.stringByReplacingOccurrencesOfString

4

Haskell,285-180 = 105字节

实际上,根本没有内置的数字显示功能。我仍然对分数不满意。随时发表评论。不过,我将进一步尝试。分数仍然比Swift的分数好

c n|n<0=8+c(-n)|n>999=r 1000+8|n>99=7+r 100|n>19=r 10+2-g[30..59]+g[20..29]|n>15=r 10-1|2>1=[0,3,3,5,4,4,3,5,5,4,3,6,6,8,8,7]!!n where{g=fromEnum.elem n;r k=c(mod n k)+c(div n k)}
m 4="4 is the magic number"
m 0="0 is 4 and "++m 4
m n=show n++" is "++show(c n)++" and "++m(c n)

用法

m 7
"7 is 5 and 5 is 4 and 4 is the magic number"
m 999999
"999999 is 50 and 50 is 5 and 5 is 4 and 4 is the magic number"

说明。

m是微不足道的,但是,事实c并非如此。c是计算字符数的函数,数字的英文名称为。

c n |n<0=8+c(-n) -- Add word "negative" in front of it, the length is 8
    |n>999=r 1000+8 -- the english name for number with form xxx,yyy is xxx thousand yyy
    |n>99=7+r 100 -- the english name for number with form xyy is x hundred yy
    |n>19=r 10+2-g[30..59]+g[20..29] -- the english name for number with form xy with x more
                                     -- than 1 is x-ty. However *twoty>twenty,
                                     -- *threety>thirty, *fourty>forty, *fivety>fifty.
    |n>10=r 10-1-g(15:18:[11..13]) -- the english name for number with form 1x is x-teen.
                                     -- However, *oneteen>eleven, *twoteen>twelve,
                                     -- *threeteen>thirteen, *fiveteen>fifteen,
                                     -- *eightteen>eighteen
    |2>1=[0,3,3,5,4,4,3,5,5,4,3]!!n -- for number 0-10, the length is memorized. 0 is 0
                                    -- because it is omitted. Input zero is handled
                                    -- separately. If we defined 0 to be 4, then
                                    -- 20 => twenty zero.
  where g   =fromEnum.elem n      -- Check if n is element of argument array, if true, 1 else 0
        r k=c(mod n k)+c(div n k) -- Obvious.

1
哦,是吗?好吧,斯威夫特有...嗯...更高的分数...(我在复出中不是很好)
Jojodmo 2015年

4

C,268-180 = 88字节

#define t(x,o)n<x?o:f(n/x)+(n%x?f(n%x):0)
char*i="4335443554366887798866555766";f(n){return t(1000,t(100,n<20?n<0?8+f(-n):i[n]-48:i[n/10+18]-48+(n%10?f(n%10):0))+7)+8;}main(n){for(scanf("%d",&n);n^4;n=f(n))printf("%d is %d and ",n,f(n));puts("4 is the magic number");}

在这里尝试。

不打高尔夫球

/* Encode number length in string (shorter representation than array) */
char*i="4335443554366887798866555766";

f(n)
{
    return n < 1000
        ? n < 100
            ? n < 20
                ? n < 0
                    ? 8 + f(-n) /* "Negative x" */
                    : i[n] - 48 /* "x" */
                : i[n/10+18] + (n%10 ? f(n%10) : 0) /* 20-99 */
            : f(n/100) + (n%100 ? f(n%100) : 0) + 7 /* x hundred y */
        : f(n/1000) + (n%1000 ? f(n%1000) : 0) + 8; /* x thousand y */
}

main(n)
{
    /* Keep printing until you get to the magic number */
    for(scanf("%d",&n);n^4;n=f(n))
        printf("%d is %d and ",n,f(n));
    puts("4 is the magic number");
}

3

Java,800-150 = 650字节

class G{static String e="",i="teen",j="ty",k="eigh",y="thir",d="zero",l="one",n="two",m="three",h="four",s="five",c="six",t="seven",b=k+"t",g="nine",D="ten",L="eleven",N="twelve",M=y+i,H=h+i,S="fif"+i,C=c+i,T=t+i,B=k+i,G=g+i,o="twen"+j,p=y+j,q="for"+j,r="fif"+j,u=c+j,v=t+j,w=k+j,x=g+j,A=" ",O=" hundred ",z,E;public static void main(String a[]){z=e;int l=new Integer(a[0]);do{E=a(l,1,e);l=E.replace(A,e).length();z=z+E+" is "+a(l,1,e)+" and ";}while(l!=4);System.out.print(z+h+" is the magic number");}static String a(int P,int _,String Q){String[]f={e,l,n,m,h,s,c,t,b,g,D,L,N,M,H,S,C,T,B,G,e,D,o,p,q,r,u,v,w,x};int R=20,X=10,Y=100,Z=1000;return P==0?(_>0?d:e):(P<R?f[P]+Q:(P<Y?(f[R+(P/X)]+" "+a(P%X,0,e)).trim()+Q:(P<Z?a(P/Y,0,O)+a(P%Y,0,e)+Q:a(P/Z,0," thousand ")+a((P/Y)%X,0,O)+a(P%Y,0,e)+Q)));}}

去高尔夫

class G {

   static String e="",i="teen",j="ty",k="eigh",y="thir",d="zero",l="one",n="two",m="three",h="four",s="five",c="six",t="seven",b=k+"t",g="nine",D="ten",L="eleven",N="twelve",M=y+i,H=h+i,S="fif"+i,C=c+i,T=t+i,B=k+i,G=g+i,o="twen"+j,p=y+j,q="for"+j,r="fif"+j,u=c+j,v=t+j,w=k+j,x=g+j,A=" ",O=" hundred ",z,E;

   public static void main(String a[]){
     z = e;
     int l = new Integer(a[0]);
     do {
             E = a(l,1,e);
             l = E.replace(A,e).length();  
             z = z+E+" is "+a(l,1,e)+" and ";
     } while(l!=4);
     System.out.println(z+h+" is the magic number");
   }

   static String a(int P,int _,String Q) {
     String[] f = {e,l,n,m,h,s,c,t,b,g,D,L,N,M,H,S,C,T,B,G,e,D,o,p,q,r,u,v,w,x};
     int R=20,X=10,Y=100,Z=1000;
     return P==0?(_>0?d:e):(P<R?f[P]+Q:(P<Y?(f[R+(P/X)]+" "+a(P%X,0,e)).trim()+Q:(P<Z?a(P/Y,0,O)+a(P%Y,0,e)+Q:a(P/Z,0," thousand ")+ a((P/Y)%X,0,O)+a(P%Y,0,e)+Q)));
   }
}

我知道已经一年多了,但是您可以删除该三元分配中的一些括号,也可以将更==0改为<1。因此:return P<1?_>0?d:e:P<R?f[P]+Q:P<Y?(f[R+(P/X)]+" "+a(P%X,0,e)).trim()+Q:P<Z?a(P/Y,0,O)+a(P%Y,0,e)+Q:a(P/Z,0," thousand ")+a((P/Y)%X,0,O)+a(P%Y,0,e)+Q;-10个字节
Kevin Cruijssen

3

QC,265-30-150 = 85字节

(✵1:oaT%=ta100%=ha100/⌋T%=X[0 3 3 5 4 4 3 5 5 4 3 6 6 8 8 7 7 9 8 8]=Y[6 6 5 5 5 7 6 6]=a0≟4a20<Xt☌YtT/⌋2-☌Xo☌+▲▲hXh☌7+0▲+)(❆1:na0<8*=ba‖1000/⌋=ca1000%=nbb✵8+0▲a✵++){I4≠:EEI" is "++=II❆=EEI" and "++=E!}E"4 is the magic number"+

测试套件

取消高尔夫:

(✵1:
oaT%=                                        # ones
ta100%=                                      # tens
ha100/⌋T%=                                   # hundreds
X[0 3 3 5 4 4 3 5 5 4 3 6 6 8 8 7 7 9 8 8]=  # length of "zero", "one", "two", ..., "nineteen"
Y[6 6 5 5 5 7 6 6]=                          # length of "twenty", ..., "ninety"
a0≟
  4
  a20< 
    Xt☌ 
    YtT/⌋2-☌ Xo☌ +
  ▲ 
▲
hXh☌7+0▲+)

(❆1:
na0<8*=                 # if negative, add 8
ba‖1000/⌋=              # split aaaaaa into bbbccc
ca1000%=
n bb✵8+0▲ a✵ ++)

{I4≠:EEI" is "++=II❆=EEI" and "++=E!}E"4 is the magic number"+

如果您没有使用内置函数来获取数字的长度,那么您实际上可以从分数中减去150
Jojodmo,2016年

2

JavaScript,382-150-30 = 202字节

var o=[0,3,3,5,4,4,3,5,5,4],f=s=>(s[1]==1?[3,6,6,8,8,7,7,9,8,8][s[0]]:o[s[0]]+(s.length>1?[0,3,6,6,5,5,5,7,6,6][s[1]]:0))+(s.length==3?(7+o[s[2]]-(o[s[2]]==0?7:0)):0),l=n=>{var s=(""+n).split("").reverse();return f(s.slice(0,3))+(s.length>3?(f(s.slice(3,6))+8):0)};(n=>{var s="";while(n!=4){s+=n+" is ";n=n>=0?l(n):(l(-n)+8);s+=n+" and ";}console.log(s+"4 is the magic number");})()

输入作为立即调用函数表达式的参数给出。

测试输入:

999999 ->
    999999 is 50 and 50 is 5 and 5 is 4 and 4 is the magic number
17 ->
    17  is 9 and 9 is 4 and 4 is the magic number
-404 ->
    -404 is 23 and 23 is 11 and 11 is 6 and 6 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number

脱胶

// array of the lengths of digits in ones place:
// one is 3, two is 3, three is 5, etc... zero is a special case
// and is assigned zero length because zero is never written out in a number name
var o=[0,3,3,5,4,4,3,5,5,4],

// function that computes the length of a substring of the input
// because the input is 6 digits, it can be broken into two 3 digit subsections
// each of which can have it's length calculated separately
f=s=>
  (
  s[1]==1? // check for if the tens digit is a one
    // when the tens is a one, pull the string length from an array that represents
    // ten, eleven, twelve, thirteen, etc...
    [3,6,6,8,8,7,7,9,8,8][s[0]]
  :
    // when the tens digit is not a one, add the ones digit normally and...
    o[s[0]]
    +
    // add the tens digit length from the array that represents
    // zero, ten, twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety
    (s.length>1?[0,3,6,6,5,5,5,7,6,6][s[1]]:0)
  )
  +
  (
  s.length==3? // check if the length is 3 and weren't not accidentally trying to do something wierd with a minus sign
    // if so, then we have to add a hundred (7 characters) to the length and the
    // length of the ones digit that is in the hundreds place like
    // 'one' hundred or 'two' hundred
    (7+o[s[2]]-
      (
        // also, if the hundreds place was a zero, subtract out those 7 characters
        // that were added because 'hundred' isn't added if there's a zero in its
        // place
        o[s[2]]==0?
          7
        :
          0
      )
    )
  :
    // if the length wasn't 3, then don't add anything for the hundred
    0
  ),

// function that computes the length of the whole six digit number
l=n=>{
  // coerce the number into a string and then reverse the string so that the
  // ones digit is the zeroth element instead of last element
  var s=(""+n).split("").reverse();
  return
    // calculate the character length of the first 3 characters
    // like in the number 999888, this does the '888'
    f(s.slice(0,3))
    +
    // then if there actually are any characters after the first 3
    (s.length>3?
        // parse the character length of the second 3 characters
        (f(s.slice(3,6))+8)
      :
        0
    )
};
// lastly is the Immediately-Invoked Function Expression
(n=>{
  var s="";
  // as long as we haven't reached four, just keep going through the loop
  while(n!=4){
    s+=n+" is ";
    n=n>=0?l(n):(l(-n)+8) // this handles negatives by only passing positive values to l and then just adding 8 onto the length for negatives
    s+=n+" and ";
  }
  // finally just say that '4 is the magic number'
  console.log(s+"4 is the magic number");
})(999999)

1

Python 641-150 = 501字节

至少它不比Java长!它基于此,除了使用字符串。

编辑:我忘了约0,我需要说“ 5是4”,而不是跳到“ 4是魔术数”-这增加了分数。

w={0:"zero",1:"one",2:"two",3:"three",4:"four",5:"five",6:"six",7:"seven",8:"eight",9:"nine",10:"ten",11:"eleven",12:"twelve",13:"thirteen",14:"fourteen",15:"fifteen",16:"sixteen",17:"seventeen",18:"eighteen",19:"nineteen",20:"twenty",30:"thirty",40:"forty",50:"fifty",60:"sixty",70:"seventy",80:"eighty",90:"ninety"}
s=""
def i(n):
 global s
 e=""
 o=n%10
 t=n%100
 h=n/100%10
 th=n/1000
 if th:
  e+=i(th)
  e+='thousand'
 if h:
  e+=w[h]
  e+='hundred'
 if t:
  if t<20 or o==0:
   e+=w[t]
  else:
   e+=w[t-o]
   e+=w[o]
 if len(e)==4:s+="4 is the magic number";print s
 else: s+="%d is %d and "%(n,len(e));i(len(e))
In=input()
i(In)

在这里尝试!


您不必显示名称,对不对?
Akangka '16

这是不正确的。i(5)打印4 is the magic number,而不是5 is 4 and 4 is the magic number
mbomb007'3

1

MOO,182 176/ 192个 188个字节- 30 =158分之146

188字节版本:

u=$string_utils;s="";i=args[0];while(i-4)j=u:english_number(i);s=s+j+(s?" and "+j|"")+" is ";i=length(u:strip_chars(j,"- "}));endwhile;return s+(s?"four and "|"")+"four is the magic number"

176个字节的实现相关版本:

s="";i=args[0];while(i-4)j=#20:english_number(i);s=s+j+(s?" and "+j|"")+" is ";i=length(#20:strip_chars(j," -"));endwhile;return s+(s?"four and "|"")+"four is the magic number"

两者都是功能。


1

PHP,168-30 = 138个字节

function m($i){$e=strlen(preg_replace('/[^a-z-]/','',(new NumberFormatter("en",5))->format($i)));echo($i==$e?"":"$i is $e and "),($e==4?"4 is the magic number":m($e));}
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.