Answers:
>>>>>+>,[>++++++[-<-------->]<+>,]<[-[█<█<]++++++++++<]>[-]>>██[>█>>█>]+[<]<<[<]>█<<+>>[>]█>[>]█+[<]<<[<]>-█>]>>[->]<[-[[<]<]++++++++++<]>[-]>[<█]>]>[>]<[[█]<]<<<<<[<]<<██>>[>]<█[->+<]<█>>[>]<[-[[<]<]++++++++++<]>███>[<<]>[[[>]>████[<]<[-[[<]<]++++++++++<]>[-]>[█<]>]>[>]<[[-]>+[>]<-<[<]<]+<<<<<[<]>[[>]+[[>]>]>[>]>[-<+>]<[<]<[>+[<]>>-<<<<<[[<]<]>>███████>[[█]>]<]<[[<]<]<[█]>]>>>[[>]<->>]]>[[>]>]<<[[[█]<]<]<<<[█]<<█>>>[>]█[-[[<]<]++++++++++<]>>[[>]+[------->++<]>.+.+++++.[---->+<]>+++.>>]>[>]+[------->++<]>++.++.---------.++++.--------.
>>>>>+>,[>++++++[-<-------->]<+>,]<[-[[<]<]++++++++++<]>[-]>>[[[>]>>[>]+[<]<<[<]>[<<+>>[>]>>[>]<+[<]<<[<]>-]>]>>[->]<[-[[<]<]++++++++++<]>[-]>[<<]>]>[>]<[[-]<]<<<<<[<]<<[>>>[>]<[[->+<]<]>>[>]<[-[[<]<]++++++++++<]>[-]>[<<]>[[[>]>[>]+[<]<[-[[<]<]++++++++++<]>[-]>[<<]>]>[>]<[[-]>+[>]<-<[<]<]+<<<<<[<]>[[>]+[[>]>]>[>]>[-<+>]<[<]<[>+[<]>>-<<<<<[[<]<]>>[[-]+>]>[[>]>]<]<[[<]<]<[<]>]>>>[[>]<->>]]>[[>]>]<<[[[-]<]<]<<<[<]<<]>>>[>]<[-[[<]<]++++++++++<]>>[[>]+[------->++<]>.+.+++++.[---->+<]>+++.>>]>[>]+[------->++<]>++.++.---------.++++.--------.
这实现了Eratosthenes的筛网。
初始>>>>>+>,[>++++++[-<-------->]<+>,]
输入每个数字作为字符代码,然后减去47以将其置于1-10的范围内。这允许单元格值为0表示数字之间的间隔。在+>
本节的开头附近,该数字必须至少为两位数,这很快就很重要。
接下来,这是我想出的第一件事<[-[[<]<]++++++++++<]>[-]>
。这在代码中出现了几次,每种都有不同的编辑模式,但不难猜测所有这些实例可能都是同一代码。此代码在磁带上的十进制数字的左边需要三个零,其作用是减少数字。循环的最后一次迭代将把值10保留在数字的左边两个单元格中,但是将其[-]
清除。
如果十进制数字为0,则不会创建多余的10,并且被零置零的单元格[-]
是最高有效数字。然后,磁带头位于第二个最高有效数字(这就是为什么至少需要两位数字的原因)。此代码段的大多数实例后面紧跟着[<<]>
,它将在正常情况下将头部放在非零单元格上,如果原始十进制数为零,则将其放在零单元格上。在该程序中,似乎n-1
使用的十进制表示法表示n
,因此0
捕获到递减而不是递减到-1
。
下一部分将数字从n-1(n)减小到0(1)在磁带上:
>[ until the number reaches zero:
[ for each digit:
[>]>>[>]+[<]<<[<]> create a placeholder for the next copy
[ while the original value of the digit is nonzero:
<<+ add 1 to copy two cells left (to keep one copy)
>>[>]>>[>]<+ go to new copy and increment that cell
[<]<<[<]>- go back to original digit and decrement
] (this is effectively the same as [<+>>+<-] but with the cells at variable locations)
>] next digit
>>[->] cancel the placeholder 1s that were used for the new copy
<[-[[<]<]++++++++++<]>[-]>[<<]> decrement
]
>[>]<[[-]<] clean up the trash 10s on the tape while ending at a known location relative to the last number
现在,这些数字都在磁带上,两个零单元格将它们分开。 <<<<<[<]<<
将我们放在磁带上倒数第二个数字的最后一个单元格中,这是我们在循环的每次迭代中所处的位置。处理完除原始数字以外的所有数字时,循环终止。
在循环开始时,我们将当前编号(最后一个仍在磁带上)右移一个单元以有减少的空间,然后继续进行递减:
[>>>[>]<[[->+<]<]>>[>]<[-[[<]<]++++++++++<]>[-]>[<<]>
如果此减量没有下溢,我们将数字转换为一进制:
[[[>]>[>]+[<]<[-[[<]<]++++++++++<]>[-]>[<<]>]
请注意,此片段已关闭[
。结果,如果数字为0(表示1),则跳过此循环的其余部分。转换为一元后,我们清除剩余的10s,将与我们的一元表示形式向左拖动:
>[>]<[[-]>+[>]<-<[<]<]+
直到现在我才写这篇文章,但是+
该代码段的结尾与一元表示形式之间用单个0隔开。它也是一元表示形式的一部分:该序列1011...11
将表示0 mod k。以下内容<<<<<[<]>
将我们放在数字的开头k+1
,开始新的循环。
此处的内部循环在磁带上的每个数字的右端单元格上以1标记“标记”,并使用一元表示作为时钟来确定哪些数字是的倍数k
。
[
[>]+ mark the current decimal number
[[>]>] move to end of decimal part of tape
>[>] move to 0 in middle of unary "clock"
>[-<+>] move the following 1 to the left if possible
<[<]< if a 1 was moved this will bring us back to a zero before the start of this "clock";
otherwise the looped move command doesn't move us at all and we are at the final 1
[ if there was no gap (happens every kth iteration):
>+[<]>>- reset to original position
<<<<<[[<]<]>> go to number that was just marked
[[-]+>] replace digits with 0s (cell value 1)
>[[>]>]< go back to where we would be without this conditional
]
<[[<]<]<[<]> return to first unmarked number
]
在[[-]+>]
该节是我想通了最后一部分。在此之前,我以为程序只是在进行试验划分,但是我看不到结果在哪里使用。
此循环在最左边的数字的左边结束两个单元格,并>>>[[>]<->>]]
删除放置在磁带上的标记,并使我们再次到达磁带的末尾。之后,>[[>]>]<<[[[-]<]<]
删除一元时钟,或者如果跳过了整个段,则删除剩余的10s。通过将该循环设置为开始条件<<<[<]<<]
。
之后,只需读取输入数字是否在任何时候都被1代替:
>>>[>]<[-[[<]<]++++++++++<]>> do the check
[[>]+[------->++<]>.+.+++++.[---->+<]>+++.>>] conditionally print "not "
>[>]+[------->++<]>++.++.---------.++++.--------. unconditionally print "prime"
幸运的是,实际输出根本没有编辑。
破解这个答案。
f[x_]:=(p=ToString@Boole@PrimeQ@x;StringMatchQ[p&@@Infinity,RegularExpression@"(\
\n{}\b+, )?1"])
Boole
没有PrimeQ
。
(({████){██[████)█>(({}))<>}<>{}███{}((██({}))█████{}]██)({}(<>))<>{(({})){({}[()])<>}{}}{}<>([{}()]{})██[██()██(()█[()]██{}██}{}<>{})
(({})<>){([[]]{})<>(({}))<>}<>{}{}{{}(([]({}))[({}[{}])])({}(<>))<>{(({})){({}[()])<>}{}}{}<>([{}()]{})}([][()])((){[()](<{}>)}{}<>{})
该程序执行从n-2到1的除法运算,然后且仅当以因子1终止时才输出1。
xxd
表示形式,因为编码,空字节和其他可怕的东西:
00000000: 31c0 b90a 0031 dbbe 8100 ac3c 0d74 3c3c 1....1.....<.t<<
00000010: 2075 f7ac 3c0d 7410 2c30 7c2f 3c09 7f2b u..<.t.,0|/<..+
00000020: 93f7 e193 01c3 ebeb 83fb 027c 19c6 0653 ...........|...S
00000030: 0159 b902 0039 d974 1289 d831 d2f7 f109 .Y...9.t...1....
00000040: d274 0341 ebef c606 5301 4eb4 09ba 5301 .t.A....S.N...S.
00000050: cd21 c341 0d0a 24 .!.A..$
首先手动拆卸警察,然后使用Yasm组装。约书亚(Joshua)使用的扭曲字节已损坏了某些字节,但我只是将它们视为已编辑字节。我对它们的实际内容有99.72%的把握。但是,如果我错了,应该花很长时间来修复它。请享用:
; A COM file is just a 16-bit flat binary
; loaded at 0x100 in some segment by DOS
org 0x100
bits 16
; Unsurprisingly, we start by converting
; the commandline string to a number. During
; the conversion, SI is a pointer to the
; string, CX is the base, and BX holds the
; partial result
parse_input:
; We'll read the input character by character
; into AL, but we need the resulting digit as
; a 16-bit number. Therefore, initialise AX to
; zero.
xor ax, ax
mov cx, 10
xor bx, bx
; When a DOS program is loaded, it's preceded
; in memory by the Program Segment Prefix,
; which holds the commandline arguments at
; offset 0x81, terminated by a carriage return
mov si, 0x81
.skip_prog_name:
; Load a character and move the pointer
lodsb
; If we find the terminator here, the program
; was not given any arguments.
cmp al, 13
je finish
cmp al, ' '
jne .skip_prog_name
.input_loop:
lodsb
cmp al, 13
je got_input
; If the ASCII value of the character is less
; than the one of '0', error out. Adjust the
; value in AL so that it holds the digit
; itself. This exploits the fact that the
; comparison instruction is just a subtraction
; that throws away the actual result.
sub al, '0'
jl finish
; If we have a value larger than 9, this
; character wasn't a digit.
cmp al, 9
jg finish
; Multiply the intermediate result by 10 and
; add the new digit to it.
xchg ax, bx
mul cx
xchg ax, bx
add bx, ax
jmp .input_loop
got_input:
; The loop below would go haywire when given a
; zero or a one, so make them a special case.
cmp bx, 2
jl composite
; Patch the output string to say that it's
; prime
mov byte[outstr], 'Y'
; BX = number being checked
; CX = loop counter, potential divisor of BX
mov cx, 2
.loop:
; If CX = BX, we looked everywhere and couldn't
; find a divisor, therefore the number is prime
cmp cx, bx
je finish
; DIV takes DX:AX as a 32-bit number for the
; dividend. We don't want nor need the extra
; precision, so we set DX to 0.
mov ax, bx
xor dx, dx
div cx
; DX now contains the remainder. To check if
; it's 0, we perform some noop operation, that
; happens to set the flags appropriately. AND
; and OR are commonly used for this purpose.
; Because of what's presumably a bug in the
; encoder used by Joshua, I do not yet know
; which for certain. However, I can make an
; educated guess. All other instances of the
; bug happened with a codepoint below 32.
; Moreover, no other bytes from that range
; occur in the code. Because an AND would be
; encoded as an exclamation mark, while OR -
; - as a tab, I am highly confident that Joshua
; used an OR.
or dx, dx
jz composite
; Increment the counter and loop again!
inc cx
jmp .loop
composite:
mov byte[outstr], 'N'
finish:
mov ah, 9
mov dx, outstr
int 0x21
ret
outstr:
db 'A', 13, 10, '$'
bx < 2
完成而不是合成。仅供参考,损坏是由于最初使用X作为掩码字符,并且切换到█时无法正确修复所有问题。
破解这个答案。
25██26█966836897364918299█0█1█65849159233270█02█837903312854349029387313█ị██v
250126,9668368973649182994001,658491592332700020837903312854349029387313ṖịØJv
说明:
看着ị
和v
,我想构建一个数字列表,将其ị
归纳为某个列表并进行评估。
在Jelly中检查素数的“简单”方法是ÆP
,因此(如果它可以破解提交内容):
Æ
和P
。256
用[14, 81]
。所以...程序开头的列表与[14, 81, 49]
mod 256(TIO)一致,并Ṗ
弹出最后一个元素。
破解这个答案。
e█ec█s█ █c "██████WyAkKHNoIC1jICJg█WNobyBabUZqZEc5eWZIUnlJQ2█2SnlBblhHNG5m██JoYVd3Z0t6SjhkMk1nTFhjSyB8YmFzZTY0IC1kYCIpIC1lcSAxIF0K█b█se6███d`"
exec sh -c "`echo WyAkKHNoIC1jICJgZWNobyBabUZqZEc5eWZIUnlJQ2M2SnlBblhHNG5mSFJoYVd3Z0t6SjhkMk1nTFhjSyB8YmFzZTY0IC1kYCIpIC1lcSAxIF0K|base64 -d`"
否在线尝试!这次由于一些问题。但是,您可以使用jdoodle。
按退出代码返回。0
(成功)表示素数,1
(错误)表示合成数。
实际执行的命令是
factor|tr ':' '\n'|tail +2|wc -w
base64
命令。+
是一个有效的base64字符。sh -c "`echo ...|base64 -d`"
回原始程序。tail +n
。当我在工作中尝试破解机器时,它抱怨它。您确实揭露了正确的代码,所以... :(
@(x)eval([(str2num(cell2mat([cellstr(reshape('0█1███1█0█0█00',████))])')█'█')','(x)'])
@(x)eval([(str2num(cell2mat([cellstr(reshape('04141113040800',2,[]))])')+'e')','(x)'])
这是一个有趣的!我为此奋斗了好几天。
第一条线索是认识到eval([...,'(x)'])
作为施工创造的通话isprime
功能,作为串联ints
和char
将隐式转换数组char
,所以...
需要的是无论是isprime
或阵列具有的ASCII值isprime
,[105, 115, 112, 114, 105, 109, 101]
。
其余的只是在文档中苦苦挣扎,以找出reshape
可以使用的一个未知维[]
,尽管我想我可以reshape(...,2, 7)
在相同的字节数下完成。
使用+'e'
(101)代替+'d'
(100)是一个不错的选择,这让我又呆了几分钟,直到我注意到最后的数字(未混淆)00
不是01
,并且很简单。
x=>{if(x<4)return(!0);for(y=x>>>Math.log10(p=████;--y-1;(p=x/y%1)████if(██&&(███))break████return(███)}
x=>{if(x<4)return(!0);for(y=x>>>Math.log10(p=2-1);--y-1;(p=x/y%1)){;;if(!p&&(1<2))break;;;}return(!!p)}
我以某种方式怀疑这正是您的想法,但是它可以工作。
class X{public static void main(String[]args){System.out.println(new String(████████[Integer.parseInt(args[0])]).matches("█████████████")?███);}}
class X{public static void main(String[]args){System.out.println(new String(new char[Integer.parseInt(args[0])]).matches(".?|(..+?)\\1+")?0:1);}}
该代码取自RosettaCode,并在SO上进行了说明。
q]tQ #aQ{*MyP
import random
def f(z):
if z<4:return z>>1
d,s,n,e,c=~-z,0,z,0,50
while not d&1:d//=2;s+=1
while n>0:n//=2;e+=1
random.seed()
while c>0:
a=0
while a<2or a>z-1:
a,b=0,e
while b>0:a=a*2+random.randint(0,1);b-=1
x,r=pow(a,d,z),~-s
if ~-x and x!=~-z:
while r>0:
x,r=pow(x,2,z),~-r
if not ~-x:return 0
elif x==~-z:break
else:return 0
c-=1
else:return 1