注意:尚未出现香草奇偶校验测试的挑战(存在C / C ++挑战,但不允许使用C / C ++以外的语言,而其他非香草语言也大都关闭了),所以我要发布一。
给定一个正整数,以真/假值输出其奇偶校验(即,如果数字是奇数或偶数)。您可以选择真实结果是对应于奇数输入还是偶数输入。
例子
假定真/假为偶数和奇数(这不是必需的,您可以分别使用其他“真/假”值):
(Input):(Output)
1:False
2:True
16384:True
99999999:False
注意:尚未出现香草奇偶校验测试的挑战(存在C / C ++挑战,但不允许使用C / C ++以外的语言,而其他非香草语言也大都关闭了),所以我要发布一。
给定一个正整数,以真/假值输出其奇偶校验(即,如果数字是奇数或偶数)。您可以选择真实结果是对应于奇数输入还是偶数输入。
假定真/假为偶数和奇数(这不是必需的,您可以分别使用其他“真/假”值):
(Input):(Output)
1:False
2:True
16384:True
99999999:False
Answers:
IT'S SHOWTIME
HEY CHRISTMAS TREE i
YOU SET US UP 0
GET YOUR ASS TO MARS i
DO IT NOW
I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY
GET TO THE CHOPPER i
HERE IS MY INVITATION i
I LET HIM GO 2
ENOUGH TALK
TALK TO THE HAND i
YOU HAVE BEEN TERMINATED
1
对于奇数输入,这将输出(真),对于偶数输入,这将输出(虚假)0
。
代码将输入读入变量i
,用模2的结果替换它,然后打印出来。
IT'S SHOWTIME # BeginMain
HEY CHRISTMAS TREE i # Declare i
YOU SET US UP 0 # SetInitialValue 0
GET YOUR ASS TO MARS i # AssignVariableFromMethodCall i
DO IT NOW # CallMethod
I WANT TO ASK YOU ... ANSWERED IMMEDIATELY # ReadInteger
GET TO THE CHOPPER i # AssignVariable i
HERE IS MY INVITATION i # SetValue i (push i on the stack)
I LET HIM GO 2 # ModuloOperator 2
ENOUGH TALK # EndAssignVariable
TALK TO THE HAND i # Print i
YOU HAVE BEEN TERMINATED # EndMain
BULLSHIT
YOU HAVE NO RESPECT FOR LOGIC
GET TO THE CHOPPER
GET YOUR ASS TO MARS
...我没话说。
+[,>,]<.
输入为一元。奇数输出为1(真),偶数输出为NUL(伪)。
我们从增加当前单元格开始,+
以便能够进入while循环[,>,]
。
在每次迭代中,,
从STDIN读取一个字节,>
前进到右侧的单元格,然后,
从STDIN读取另一个字节。输入耗尽后,解释器(无论如何,在TIO上的解释器)会将单元设置为NUL。一旦发生这种情况,while循环的条件将不再满足,我们将打破这种情况。
令n为输入整数。如果有偶数个输入字节(即,如果n为偶数),则前n / 2次迭代将读取两个1,而下一次迭代将读取两个NUL,从而使磁带如下。
... 1 NUL NUL
... 49 0 0
^
<.
还原一个单元并打印其内容,然后将一个NUL字节发送到STDOUT。
但是,如果输入字节数量奇数,则第一个(n-1)/ 2迭代将读取两个1,而下一个迭代将读取一个1和一个NUL,从而使磁带如下。
... 1 1 NUL
... 49 49 0
^
<
现在将回退到包含字节/字符1的单元格,该单元格将进行.
打印。
OddQ
给出True
奇数输入和False
偶数输入,谁知道呢?
还有EvenQ
,但是谁愿意输入所有这些?
2∣#&
作品还
Q
?
我以前从未在Taxi中编写过程序,而且我是一般编程的新手,因此可能有更好的方法来解决此问题。我已经检查了错误,并通过尝试具有相同结果的不同路线设法稍微打了个高尔夫球。我欢迎任何修改。
返回0
偶数和1
奇数。
Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:s 1 l 1 r.Pickup a passenger going to Divide and Conquer.2 is waiting at Starchild Numerology.Go to Starchild Numerology:n 1 l 1 l 1 l 2 l.Pickup a passenger going to Divide and Conquer.Go to Divide and Conquer:e 1 l 2 r 3 r 2 r 1 r.Pickup a passenger going to Cyclone.Go to Cyclone:e 1 l 1 l 2 l.Pickup a passenger going to Trunkers.Pickup a passenger going to Equal's Corner.Go to Trunkers:s 1 l.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:w 1 l.Switch to plan "b" if no one is waiting.Pickup a passenger going to Knots Landing.Go to Knots Landing:n 4 r 1 r 2 r 1 l.[a]Pickup a passenger going to The Babelfishery.Go to The Babelfishery:w 1 l.Pickup a passenger going to Post Office.Go to Post Office:n 1 l 1 r.[b]0 is waiting at Starchild Numerology.Go to Starchild Numerology:n 1 r.Pickup a passenger going to Knots Landing.Go to Knots Landing:w 1 r 2 r 1 r 2 l 5 r.Switch to plan "a".
您是对的,没有换行符就很难阅读。这是格式化的版本:
Go to Post Office:w 1 l 1 r 1 l.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery:s 1 l 1 r.
Pickup a passenger going to Divide and Conquer.
2 is waiting at Starchild Numerology.
Go to Starchild Numerology:n 1 l 1 l 1 l 2 l.
Pickup a passenger going to Divide and Conquer.
Go to Divide and Conquer:e 1 l 2 r 3 r 2 r 1 r.
Pickup a passenger going to Cyclone.
Go to Cyclone:e 1 l 1 l 2 l.
Pickup a passenger going to Trunkers.
Pickup a passenger going to Equal's Corner.
Go to Trunkers:s 1 l.
Pickup a passenger going to Equal's Corner.
Go to Equal's Corner:w 1 l.
Switch to plan "b" if no one is waiting.
Pickup a passenger going to Knots Landing.
Go to Knots Landing:n 4 r 1 r 2 r 1 l.
[a]Pickup a passenger going to The Babelfishery.
Go to The Babelfishery:w 1 l.
Pickup a passenger going to Post Office.
Go to Post Office:n 1 l 1 r.
[b]0 is waiting at Starchild Numerology.
Go to Starchild Numerology:n 1 r.
Pickup a passenger going to Knots Landing.
Go to Knots Landing:w 1 r 2 r 1 r 2 l 5 r.
Switch to plan "a".
这是我最好的解释逻辑的尝试:
Go to Post Office to pick up the stdin value in a string format.
Go to The Babelfishery to convert the string to a number.
Go to Starchild Numerology to pickup the numerical input 2.
Go to Divide and Conquer to divide the two passengers (stdin & 2).
Go to Cyclone to create a copy of the result.
Go to Trunkers to truncate the original to an integer.
Go to Equal's Corner to see if the two passengers are the same.
Equal's Corner returns the first passenger if they're the same (no .5 removal so the stdin was even) or nothing if they're not.
If nothing was returned, it was odd, so go pick up a 0 from Starchild Numerology.
Go to Knots Landing to convert any 0s to 1s and all other numbers to 0s.
Go to The Babelfishery to convert the passenger (either a 1 or 0 at this point) to a string.
Go to Post Office to print that string.
Try and fail to go to Starchild Numerology because the directions are wrong so the program terminates.
不返回出租车车库会导致输出到STDERR,但是我很好。
[02468]$
视网膜答案(用于十进制输入)。这也是一个简单的正则表达式解决方案,几乎可以在任何正则表达式中使用。匹配(和打印1
),用于甚至输入和不匹配(和打印0
),用于奇数输入。
另一种也是8个字节的替代方法,使用音译阶段将所有偶数数字都转换为x
第一个(因为音译阶段具有用于偶数/奇数数字的内置功能):
T`E`x
x$
当然,在这种情况下,最短的输入格式(甚至比unary短)将是二进制的,其中简单的正则表达式0$
就足够了。但是,由于挑战本质上是寻找最低有效的二进制数字,因此二进制输入似乎绕过了实际挑战。
因为内置程序很无聊
:He
对于偶数输入,这将输出非零值的矩阵(这是真实的),对于奇数输入,这将在其右下角的条目中输出零(这是虚假的)。
在线尝试!页脚代码是if-else
分支,用于说明结果的真实性或虚假性。删除该页脚将隐式显示矩阵。
以输入5
为例
: % Implicitly input n. Push row vector [1 2 ... n]
% STACK: [1 2 3 4 5]
He % Reshape into a 2-row matrix, padding with zeros if needed
% STACK: [1 3 5;
2 4 0]
n->n%2<1
Object c(int n){return n%2<1;}
输出true
偶数和false
奇数
如果1/0
允许而不是true/false
(不是,请考虑此处的投票数):
n->n%2
int c(int n){return n%2;}
int o(int n){return java.util.stream.IntStream.of(n).map(n->n%2).filter(n==0).findAny().isPresent();}
5njaampjhompppam
如果输入为偶数,则此程序返回0,如果输入为奇数,则返回1。
上面的文字代表图片。您可以通过将图像粘贴到解释器页面上的文本框中来生成图像。为了方便起见,我在下面提供了可编码大小为31像素的图像。网格是为了提高可读性而不是程序的一部分。
该程序使用模内建函数来确定输入是偶数还是奇数。
Instruction Δ Hue Δ Lightness Stack
------------ ----- ----------- -------
In (Number) 4 2 n
Push [2] 0 1 2, n
Modulo 2 1 n % 2
Out (Number) 5 1 [Empty]
[Exit] [N/A] [N/A] [Empty]
永远不会访问左下角的深蓝色编码,并且可以将其更改为相邻编码的颜色以外的任何颜色。我选择深蓝色,因为我认为该程序的其余部分看起来不错。左上方的黑色编解码器也可以是白色,但不能是其他任何颜色。我选择了黑色,因为它看起来更好。
我已经以图像形式和文本形式提供了该程序,因为在如何对Piet程序评分上没有明确的共识。随时参与元讨论。
0|1
,对吗?@TheLethalCoder
,++[>++]>++.
这需要带有圆形胶带和环绕单元的解释器。TIO上的一个具有65,536个8位单元,可以满足要求。
I / O以字节为单位。奇数输入映射到0x00(伪),甚至输入映射到非零字节(真实)。
我们首先读取带有的输入字节,,
然后通过将其值加2来开始++
。稍后我们将说明为什么需要增量。
接下来,我们进入一个循环,该循环前进到右侧的单元格,将其加2,然后重复该过程,除非将此单元格的值设置为0。
最初,除输入单元格外,所有其他单元格均保持0。如果输入为奇数,则将其加2永远不会将其清零。但是,在磁带上循环127次之后,循环的下一次迭代会将输入单元格右侧的单元格设置为128×2 = 0(mod 256),从而导致循环结束。>++
再重复一次循环体,因此下一个单元也被清零,然后用印刷.
。
另一方面,如果输入为n且n为偶数,则循环之前的代码会将输入像元设置为n + 2。在磁带上绕(256-(n-2))/ 2 =(254-n)/ 2次循环后,输入单元将达到 0,其右侧的单元格将保留值(254-n)/ 2 ×2 = 254-n。在加上2后>++
,.
将输出256-n = -n(mod 256),由于n为非零是非零的。
最后,请注意,如果我们在循环之前不增加输入,则第二种情况将打印258-n = 2-n(mod n),因为需要在磁带上再循环一次才能将输入单元清零。因此,该程序将因输入2而失败。
根据下面的评论,这是最新的候选版本:
1 INPUT A
2 IF NOT A THEN STOP
3 PRINT A;":";NOT INT A-(INT (INT A/VAL "2")*VAL "2")
现在它将 PRINT
1
是偶数和0
奇数。零出口。
以下是符号列表的旧版本,仅供参考:
1 INPUT A
2 IF NOT A THEN STOP
3 LET B=INT (INT A/2)
4 PRINT A;":";NOT INT A-B*2
5 RUN
这是旧的(v0.01)清单,因此您可能会看到我所做的改进,因为新清单不仅较小,而且速度更快:
1 INPUT A
2 IF A<1 THEN STOP
3 LET B=INT (INT A/2)
4 LET M=1+INT A-B*2
5 PRINT A;":";
6 GOSUB M*10
7 RUN
10 PRINT "TRUE"
11 RETURN
20 PRINT "FALSE"
21 RETURN
这是v0.02(使用Sinclair子字符串):
1 INPUT A
2 IF NOT A THEN STOP
3 LET B=INT (INT A/2)
4 LET M=1+INT A-B*2
5 LET C=4*(M=2)
6 PRINT A;":";"TRUE FALSE"(M+C TO 5+C+(M=2))
7 RUN
PRINT (A-2*INT A/2)/A
吗?
0
不应产生a TRUE
或FALSE
,因此,0
由于不应该产生结果,因此我STOP
对程序进行了ping操作。我可能会解释原始问题,因为它是@SIGSEGV发布的,字面意思有点过分。是的,您可以对它进行优化和重构。
É
我个人认为是更好的选择;开玩笑的。
É
回报a % 2 == 1
。
template<int v>int o=v&1;
这定义了一个变量模板(类似于函数的构造),其值等于按位运算input&1
。0
甚至值1
对于奇数。该值是在编译时计算的。
需要C ++ 14。
main()
的结构,该程序也只会被编译为return 0
,甚至根本无法编译。这与我在此答案中链接的元帖子相矛盾。
[](int x){return x%2;}
在线尝试
我做的。我打高尔夫。这是一次非平凡的解决方案,设法获得了最后一个字节!
!F
真值偶数(不包括0,但这不是正数,所以...)。
说明:
! Not
FQQ Applied to the input (first Q) Q times
例如, !!2 = !0 = 1
,和!!!3 = !!0 = !1 = 0
我将在此处保留3字节解决方案的库。
“还有多个3字节解决方案的另一个答案,但这还远未完成。让我们再添加几个:
@U2
[0,1]
模块化地索引列表,为奇数输入提供真实值。
}2P
输入的素数分解中是否为2?(甚至要认真)
ti2
GCD是2,输入2是吗?(甚至要认真)
gx1
将输入与1进行异或运算不会减少它吗?(甚至要认真)
q_F
基本上Q == Q*-1^Q
,其中Q是输入,但通过循环完成。(甚至要认真)
_FI
同上。
g^_
转换为Q <= -Q^Q
(Truthy on even)
请注意,任何涉及上述解决方案g
将与<
翻转后truthy-falsiness。)
n=>n%2<1
编译为Func<int, bool>
。
或者,如果不允许使用匿名函数,则此方法为21个字节:
bool p(int n)=>n%2<1;
if (1)
不编译。
if (1)
您的代码中没有?
if (x)
评估为true,x
则为真实值。如果评估为假,则为false
。因此,使用伪代码:if x, disp(true), else disp(false)
。如果无法编译,则x
无法使用。在MATLAB和其他几种语言中,任何非零值都被视为true,而0
and false
则被视为false。因此,字符串Hello
在MATLAB中是真实值。但是,某些语言要求该值是布尔值(此处是这种情况),因此必须使用将该值转换为布尔值<1
。
当然,更确切地说,这是TIS-100仿真器所仿真的T21基本执行节点体系结构的程序。
我将为您提供这个答案,以对TIS-100程序的得分及其结构进行非常深入的解释。
@0
ADD UP
G:SUB 2
JGZ G
MOV ACC ANY
说明:
@0 # Indicates that this is node 0
ADD UP # Gets input and adds it to ACC, the only addressable register in a T-21
G: # Defines a label called "G"
SUB 2 # Subtracts 2 from ACC
JGZ G # If ACC is greater than 0, jumps to G
MOV ACC ANY # Sends the value of ACC to the first available neighbor; in this case, output.
# Implicitly jumps back to the first line
在伪代码中,它看起来像:
while (true) {
acc = getIntInput()
do {
acc -= 2
} while (acc > 0)
print(acc)
}
T21没有布尔类型或真/假值,因此程序会返回-1表示奇数,0表示偶数,除非先前的输入是奇数,在这种情况下,它返回-1表示偶数,0表示奇数数字-如果这一事实困扰您,那么这是一个完整的程序,因此您可以在两次使用之间重新启动T21。
Ḃ
只是另一个内置函数。
对于不了解Jelly的人:它具有相当多的功能来推断缺少的代码,因此,代码段,函数和完整程序之间在语法上没有太大区别;解释器将自动添加代码以输入适当的参数并输出结果。在处理PPCG规则时,这非常方便,该规则允许使用函数和程序,但不允许使用摘要。在TIO链接中,我将其视为函数,并在1到20(含1和20)之间的每个整数上运行它,但它也可以作为完整程序运行。
&1
没有内置功能也很短。(这是按位与1。)
177407770236713353
7与普通的if语句没有任何相似之处,并且具有一种以上的惯用方式来表示布尔值。因此,很难知道什么是真实和错误的,但是该程序使用1
奇数和空字符串用于偶数(Perl的真值和假值,其中编写了7解释器)。(更改它很容易;奇数输出在前7个之前指定,偶数输出在前两个7之间指定。不过,可能需要更改输出格式以处理其他类型的输出;我使用了两者最短的不同输出在这里。)
7使用压缩的八进制编码,其中源的三个字节代表程序的八个字节,因此在磁盘上的7个字节中表示源的18个字符。
177407770236713353
77 77 7 Separate the initial stack into six pieces (between the 7s)
023 Output format string for "output integers; input one integer"
7 6 Escape the format string, so that it's interpreted as is
13 Suppress implicit looping
3 Output the format string (produces input)
5 Run the following code a number of times equal to the input:
40 Swap the top two stack elements, escaping the top one
3 Output the top stack element
像许多输出格式一样,“输出整数”在输出之前撤消任何数量的转义。因此40
,可以结合使用进行交换和转义操作,代替405
交换操作(交换和转义后跟不转义)。如果使用的输出格式在转义方面不稳定,则需要完整的格式405
。(顺便说一下,我们最初需要转义格式字符串的原因是,如果第一个输出包含无法代表的字符,它将自动强制输出格式7。转义它会删除无法代表的字符并允许选择格式0。)
在六个初始堆栈元素中,最上面的是主程序(并且13
要运行的是被消耗);第二个是023
选择输出格式并请求输入,并由该操作使用;第三个消耗是该3
操作的副作用(除了产生输出外,还用于丢弃堆栈元素);第四个40
是循环的主体(并由5
执行循环的消耗);和第五个和第六个交换等于输入的次数(如果输入为偶数,则交换到其原始位置;如果输入为奇数,则交换到彼此的位置)。
你可以高尔夫球关闭通过改变导致一个字符177
到17
(和依靠隐式空第六堆元件上),但是这将输出的奇偶变更为比奇数是真少一个惯用方法,以及它不保存一个完整的字节(源仍然是七个字节长)。因此,我决定使用更自然的输出形式,因为它的得分不会更差。
(({})){({}[()]<>)}<>
首先,我们将使用复制一个输入(({}))
。
最下面的副本将用作真实值,而最上面的副本将用于实际处理。这样做是因为我们需要将输入放在顶部,并且在输入的下方放置1相当麻烦(两个额外的字节!)。
然后我们开始循环{({}[()]<>)}
。这是对标准倒数循环的简单修改,每次递减时都会切换堆栈。
因为有两个堆栈,所以偶数将在它开始的堆栈顶部结束,而奇数将在相反的堆栈结束。复制的值将保留在原处,因此将成为我们开始的标记。
一旦完成循环,我们就会0
在真实值(输入的副本)或虚假值(空堆栈)的顶部放置一个(最初是输入)。我们在另一个堆栈上也有相反的值。
我们需要摆脱0
可以通过{}
或删除的<>
。两者似乎都起作用并且给出相反的结果,但是{}
当它应该返回真值时会导致零的错误值。这是因为我们的“真实”值是输入的副本,而零是唯一可能是虚假的输入。
通过以结束程序<>
来解决此问题。
(当然,根据规范,我从技术上讲不必支持零,但可以选择两个选项,我宁愿支持它)
?ABv
/ \ <
!+ <
哎呀,我觉得有一个18字节的解决方案浮动超出范围:(哈哈!-2字节通过使用a +
重定向来自不同方向的位。
仍然感觉其中有太多空白(整个6个字节!)
?ABv Feed unary input into the main loop
/ \ Every loop, two bits will be removed from the input
+ <
/ \ < When we reach the point where there is either one or no bits of input left
!+ If one, it will reflect off both /\s and turn left at the +
And output, otherwise the program ends since no more bits are moving
@cmd/cset/a%1%%2
输出1表示奇数,0表示偶数。备用16字节版本也适用于负数:
@cmd/cset/a"%1&1
17个字节输出偶数为1,奇数输出为0:
@cmd/cset/a"~%1&1
(Input):(Output)
”
?[A1]mod 2
;一个匿名的VBE立即窗口函数,该函数从VBE立即窗口输入[A1]
和输出,其中0
(falsey)代表偶数,1
(truthy)代表奇数
JSFuck是基于JavaScript原子部分的深奥和教育性编程风格。它仅使用六个不同的字符来编写和执行代码。
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]])+[])[!+[]+!+[]]+(!![]+[])[+[]]+(+(+!+[]+[+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+[+!+[]])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]+!+[]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]])()(([]+[])[([![]]+[][[]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]]()[+[]])[+[]]+[!+[]+!+[]])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]]
输出1表示奇数,0表示偶数。
alert([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]])+[])[!+[]+!+[]]+(!![]+[])[+[]]+(+(+!+[]+[+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+[+!+[]])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]+!+[]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]])()(([]+[])[([![]]+[][[]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]]()[+[]])[+[]]+[!+[]+!+[]])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[!+[]+!+[]]](prompt()))
alert(prompt()%2)
似乎是9384个字符。
+
以进一步节省77个字节;-)我个人认为用JSF回答是可以的;它基本上是JS的方言。
bc<<<$1%2
读取命令行输入,使用mod操作将值扩展为字符串,然后将字符串传递给bc进行计算。输出1表示奇数,0表示偶数。
测试用例:
(Input):(Output)
1:1
2:0
16384:0
99999999:1
编辑:感谢@ ais523,保存了7个字节
编辑2:感谢@Dennis,保存了3个字节
编辑3:感谢@Dennis,保存了另外两个字节
bc<<<$1%2
。