两大不同-强盗


29

对于主要警察的挑战,请单击此处

注意 -此挑战现已结束。现在发布的任何裂缝都不会计入排行榜,接受的答案也不会改变。

挑战

给定原始程序,其输出以及更改后的程序的输出,您必须找出需要更改,删除或添加哪些字符才能获得预期的输出。

当您破解某人的代码时,请在其答案上留下评论并附带指向您的破解的链接。

格式化

# [<language>, <username of program owner>](<link to answer>)

## Description

<description of change and how you found it>

## Code

<changed code>

获奖

破解最多的人将获胜。

排行榜

13个裂缝:

  • 丹尼斯

8个裂缝:

  • 亚历克斯·范·刘

5个裂缝:

  • Sp3000
  • 伊萨格

3个裂缝:

  • 路易斯·门多
  • 吉米23013
  • 唐·黑斯廷斯

2个裂缝:

  • mbomb007
  • 烂49

1个裂缝:

  • 头号
  • 雅库比
  • 骄傲的哈斯克勒
  • 张大卫
  • 萨格马克
  • 保罗·奥德索
  • 雷瑞恩
  • 镁比松
  • n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳
  • 斯蒂夫·格里芬
  • bl

1
@ mbomb007您可以避免编辑此帖子吗,因为它使我在更新排行榜时更加难以知道自己的位置
Beta Decay 2015年

Answers:


10

CJam,毛里斯(Mauris)

描述

Mauris的原始代码执行以下操作:

"f~"     e# Push that string on the stack.
    :i   e# Cast each to integer. Pushes [102 126].
      :# e# Reduce by exponentiation. Pushes 102^126.

CJam的其他数学运算符没有其他任何一个会产生大的数字,因此:#无法修改。由于#当用于取幂时,仅将整数用作输入,因此:i也无法删除。这仅留下一个地方来修改输入:string "f~"

无论该字符串包含多少个字符,结果都将是一个左联想力量塔。CJam支持介于0到65535之间的字符(代理字符除外),因此我们必须将输出表示为b n×k×j,其中bnkj是该范围内的整数。

修改后的代码产生的整数的十进制对数略小于log 10(2.44×10 242545)= log 10(2.44)+ 242545,因此我们可以将该值除以所有可能的底数的对数,以找到合适的值对于n×k×j

事实上:

$ cjam <(echo '65536,2>{2.44AmL242545+1$AmL/i:I#s8<"24399707"=}=SIN')
5 347004

比较前8位就足够了。

这意味着我们可以将输出表示为5 347,004 = 15625 57,834 = 125 9×102×126,因此可以替换"f~""㴉""} f~"

"㴉":i:#

要么

"}  f~":i:#

请注意,ASCII代码中的空格实际上应该是制表符。

尝试在在线解释器中执行此代码可能不是一个好主意,但是您可以通过以下方法从命令行验证结果:

$ wget -q https://bpaste.net/raw/f449928d9870
$ cjam <(echo '[15625 57834]:c`":i:#") > mauris.cjam
$ cat mauris.cjam; echo
"㴉":i:#
$ cjam mauris.cjam | diff -s - f449928d9870
Files - and f449928d9870 are identical
$ echo -en '"}\tf~":i:#' > mauris-ascii.cjam
$ cat mauris.cjam; echo
"}  f~":i:#
$ cjam mauris-ascii.cjam | diff -s - f449928d9870
Files - and f449928d9870 are identical

11
一个人不能简单地在CJam中击败Dennis
Fatalize 2015年

您如何找出要使用的数字?
Alex Van Liew

@AlexVanLiew蛮力。我目前正在写一个说明。我只想在其他人之前发布该漏洞。
丹尼斯

@丹尼斯:足够公平。我正在尝试这个,但是我不认识CJam。我想出了所需的解决方案,涉及实际~f在程序中的某个地方使用。
Alex Van Liew

1
@Mauris这个问题说,仅更改程序中的两个字符(强调我的意思),所以我认为这没问题。无论如何,将数字分解是最困难的部分。
丹尼斯

15

Ruby,历史学家

描述

通过添加将x更改为数组而不是标量 *

9通过添加将最后一个更改为字符串而不是数字?

结果是将单个元素([9])乘以9,然后插入"9"作为分隔符的数组。

x=*9;puts x*9*?9

12

Python 2,泥dy

描述

通过涉及大量分解和寻找影响因素的试验和磨难,我意识到将87654更改为58116就足够了。然后,我将58116分解为87 * 668。然后我意识到01234 = 668,所以我只需要将87654更改为87并完全删除01234。这是通过注释完成的。

print (sum(range(054321)*9876)*87)#654)/01234

是的,几乎完全是我的想法(我的曾经是print sum(range(054321)*9876)*87#654)/01234
蓝色

聪明聪明!我很高兴有人得到它,它比“玩数字游戏”更有趣!
Alex Van Liew

11

莎士比亚,超越火焰

在场景III中,必须在以下片段中将Claudius更改为Claudio:

[Enter Claudio]

Claudius:
 Thou art as stupid as the sum of thee and the product of the 
 product of me and Helen and Helena

[Exeunt]

修改后的代码:

The Hidden Change.

Helen, a young woman with a remarkable patience.
Helena, a likewise young woman of remarkable grace.
Claudio, a remarkable man much in dispute with Claudius.
Claudius, the flatterer.
The Archbishop of Canterbury, the useless.


          Act I: Claudius's insults and flattery.

          Scene I: The insulting of Helen.

[Enter Claudius and Helen]

Claudius:
 Thou art as hairy as the sum of a disgusting horrible fatherless 
 dusty old rotten fat-kidneyed cat and a big dirty cursed war.
 Thou art as stupid as the product of thee and a fat smelly 
 half-witted dirty miserable vile weak son.

[Exeunt]

          Scene II: The complimenting of Helena.

[Enter Claudio and Helena]

Claudio:
 Thou art the sunny amazing proud healthy peaceful sweet joy.
 Thou art as amazing as the product of thee and the pretty
 lovely young gentle handsome rich Hero. Thou art as great 
 as the sum of thee and the product of a fair golden prompt good honest 
 charming loving noble king and a embroidered rich smooth golden angel.

[Exeunt]

          Scene III: The insulting of Claudio

[Enter Claudius and Helen]

Helen:
 Thou art as stupid as the sum of the sum of thee and a cat and me.
[Exit Helen]

[Enter Claudio]

Claudio:
 Thou art as stupid as the sum of thee and the product of the 
 product of me and Helen and Helena

[Exeunt]

          Scene IV: The Final Countdown

[Enter The Archbishop of Canterbury and Claudius]

Claudius:
 Thou art the sum of you and a cat.

The Archbishop of Canterbury:
 Am I better than a fine road?

Claudius:
 If not, let us return to the insulting of Claudio.

[Exit The Archbishop of Canterbury]

[Enter Claudio]

Claudius:
 Open your heart!
 Open your heart!
[Exeunt]

使用通过@AboveFire链接的编译器,打印11


2
您能否更清楚地说明哪些字符已更改?来回看并不容易。
mbomb007

该死,迟到了15分钟。恭喜你
Sumyrda-恢复莫妮卡2015年

2
Jeebus H.基督。不错的工作!
rayryeng-恢复莫妮卡

1
@ mbomb007我希望我的编辑更加清晰。AboveFire:对不起:)
Plannapus

3
@plannapus Haha,没关系,但清除该问题的预期方法是将“ king”一词替换为“ pig”。更改后,Helena等于0,并且“ thee和我乘积的和而海伦和海伦娜”等于1。我列出了所有可以用两个字母反转的单词,并在我的代码中使用了很多单词(例如:joy-> hog-> son,war-> cat,道路->蟾蜍,英雄->地狱,诅咒->钱包,海伦->海伦娜,克劳迪奥->克劳迪乌斯等)唯一可以更改莎士比亚程序(含2个字符)的事物是变量的变化,名词和goto的变化。
AboveFire



7

C,LambdaBeta

描述

main(a,_)main(_)。main的第一个参数argc是初始化为1

main(_){puts(_*_-1||_*_*_-1||_*_*_*_-1?"Expected Output":"?");}

这就是我想到的解决方案。不错的收获。顺便说一句,如果将argv恰好加载到存储单元1中,则它将不起作用。我只是想不出任何可以运行该页面上各种解释语言的系统。
LambdaBeta 2015年

6

Python 2,rp.belrann

将最外面的列表理解更改为集合理解。部分感谢@ mbomb007,他消除了所有“无聊”的解决方案(交换x和交换y,调整操作员,更改范围)。

'~'*sum({(x,y)[x%2] for x in[y for y in range(8)]})

说明:

在原始文件中,[(x,y)[x%2]for x in[y for y in range(8)]]生成以下列表:

[0, 7, 2, 7, 4, 7, 6, 7]

这是因为在Python 2.7中,y内部列表理解中的ins会以其最后的已知值(在范围的末尾为7)泄漏到封闭的作用域中。因此,在元组中,y始终为7 x,但是,正常情况下会遍历该列表,范围为0到7。当x为偶数时,它选择的值x,当为奇数时,它选择y(始终为7)。我注意到,如果我恰好包括了一个7以及所有其余的值x,则我得到19;然后我意识到我可以将外部理解转换为集合理解,这将消除所有重复的值并使我剩下正好19。

这非常聪明,我认为我以前从未使用过固定的理解力。荣誉


不。不是这个。print len('~'*sum([(x,y)[x%2]for x in[y for y in range(6)]]))返回21。只需将代码分配给变量,然后在变量等于所需字符串的情况下进行打印。如果看到True,则将其破解。
mbomb007

奇怪 _我猜是出卖了我。
Alex Van Liew

@ mbomb007我明白了。
Alex Van Liew

你懂我 做得好。
rp.beltran


5

丹尼斯·巴什(Bash)

原始代码:

echo {{{1..9}}}

原始输出:

{{1}} {{2}} {{3}} {{4}} {{5}} {{6}} {{7}} {{8}} {{9}}

修改后的代码:

echo {,{1..9},}

修改后的输出:

1 2 3 4 5 6 7 8 9

说明:

在Bash中,您可以在一对大括号内输出逗号分隔的项目列表,如下所示:

echo {a,b,c}

版画

a b c

因此,修改后的代码将打印出一无所有的列表,数字1..9,无任何内容。


5

MATLAB,Luis Mendo

原始代码:

-sin(2:.5:3)    
ans =    
   -0.9093   -0.5985   -0.1411

新答案:

psi(2:.5:3)
ans =
    0.4228    0.7032    0.9228

描述:

更改-sinpsi,MATLAB中的polygamma函数。该-符号由替换,p并且n被删除。


4

C,LambdaBeta

描述

更改-1*0,乘积的结果为0(伪造的值)。

main(a,_){puts(_*_*_*_*_*0?"Expected Output":"?");}

糟糕,好像我在打高尔夫球时引入了(安全漏洞?)。我会仔细研究一下是否可以解决它。虽然不错。
LambdaBeta 2015年

4

Kurousagi Brainfuck

描述

删除第一个>并将第一个更改<.

brainfuck.tk测试。请注意,输出与Kurousagi的帖子完全不匹配由于SE吃了不可打印的字符。

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[>.+<-]

@muddyfish我在第二条评论中链接了该答案,但我仍在等待Kurousagi的确认
Sp3000

4

该隐Fantom

通过晦涩难懂的安全性是一种非常差劲的安全性形式(尤其是当这两种方法在Fantom文档中彼此相邻时,任何知道浮动对象的人都会立即知道该怎么做)。

Float.makeBits32(1123581321)

1
你在1分钟之前就把我弄了!表现出色
AboveFire 2015年

1
哈哈,你得到了我,享受自由的破解
该隐2015年

@Cain那是故意的

1
@BassetHound我的意思是,这更多的是一项社会实验,以了解人们是否会为这种破解而学习一些晦涩的语言。我本来应该做一些实际的工作,但是应该使它更困难。
该隐2015年


4

Python 2,Sp3000

描述

012340x1234min9in

4669 = (01234-1)*sum(m<<m in R for m in R)是令人误解的事实。

R=range(0x1234);print sum(m<<9in(m,n)for m in R for n in R)

做得很好!我有m<<m in(m,n),但主要是将更min改为in
Sp3000



3

Java,TheNumberOne

描述

该程序是的一次性实施,Random.next()初始种子为Integer.MAX_INT,所有十六进制数字均转换为十进制。将种子更改为的补码将MAX_INT生成输出:

class T{public static void main(String[]a){System.out.print(((~Integer.MAX_VALUE^25214903917L)&281474976710655L)*25214903917L+11L&281474976710655L);}}

(由于必须有两个更改,因此请选择任何一种无操作更改:在某处添加空格,多余的分号等)


1
不错,你能也翻Integer.MAX_VALUEInteger.MAX_VALUE+1Integer.MIN_VALUE
TheNumberOne

哦,你知道吗?我尝试过,+1但是因为我是用Python编写的,所以它只能滚动很长时间了。实际上,那是我的第一个想法。
Alex Van Liew

3

Brainfuck,高于火

这个程序是对这个代码的修改,我得到了一个cookie答案。该答案的工作方式是先预先计算一个有用字符的有用ascii码表,然后通过三个循环组成三个条件语句,并通过使三个循环进入1在正确的位置。

我如何破解代码的开始是,如果您进入表格左移进入第三个循环,则更改后的输出中的重复图案主要是打印内容。

++++++++++[->++++++++<]>>++++++[-<---------->]<-------[----------->>>-<<+<[->->+<<]]>>>+<<>>>+++[->++++++++++<]>(<)++ .<+++++++++[->>>>>>>++++++++++<+++++<++++++++++++++<++++++++++<+++++<++++++++++<<]++++++++++>>+++++...>++>++>-->+>(>)++++<<<<<<<.<<<[->>>>>>.<<>>>>>.<<<<<.>>>>>.<<<<<>>>.<<<<.>>>>>.<<<<.>>>>>.<<<<<.>>>>.<<<<<.>>>>.<<...>.<<<<<<]>[->>>>>.<<...>>>.<<<<.>>>>>.<<<<...>>>>.<<<<<.>>>>.<<...>.<<<<<]>[->>>>.<<>>>>>>.<<<<<<..>>>.<<<<.>>>>>.<<<<>>>>>>.<<<<<<.>>>>>>.<<<<<<>>>>.<<<<<.>>>>.<<...>.<<<<]

(其他字符用括号标记)


3

Python 2,泥dy

描述

变化<<<>(的弃用版本!=)和0x1560156中,代码点"n"(出现3次在长度23的字符串'<built-in function sum>').

print sum((ord(i)<>0156 for i in `sum`))

3

JavaScript,Razvan撰写

描述

修改后的输出显然是Euler的自然数,可以通过访问Math['E']

By changing '' to '3' and 32 to 36, String.fromCharCode generates the E.

Code

a=1,b=a*2,c=a+b,d=[a+b];while(c>b)c-=a;for(i=1;i<=c;i++)d.push(i);i='3'+c*d['length']*d['length'];alert(Math[String.fromCharCode(i.charCodeAt(0) * i.charCodeAt(1) / 36)])

Yes, that's correct. Still it was actually something deeper but it seems that you could bypass it with this trick. I'll think of something else and I'll come back.
Razvan

3

Fantom, Cain

Description

数组索引已经设置好了,所以我只需要做一个55。老实说,最困难的部分是下载语言。

[7115432d/9,219.or(64),37,55,55][3]

(插入逗号0-> 3


好吧,这不是预期的解决方案,我的红鲱鱼是一个实际的解决方案
该隐2015年

3

莎士比亚,超越火焰

不正确-抱歉:(

当我下班回家时,将进行进一步的研究。原始的克劳迪奥的值为1132462081,克劳迪乌斯的值为1

在最终的场景中,克劳迪奥的值被打印两次,

[Enter Claudio]

Claudius:
 Open your heart!
 Open your heart!

敞开心heart x2 =舞台上其他人的打印价值(Claudio)。因此,如果将Claudius更改为Claudio(2个字符)-将显示Claudius的值-为1-两次

The Hidden Change.

Helen, a young woman with a remarkable patience.
Helena, a likewise young woman of remarkable grace.
Claudio, a remarkable man much in dispute with Claudius.
Claudius, the flatterer.
The Archbishop of Canterbury, the useless.


          Act I: Claudius's insults and flattery.

          Scene I: The insulting of Helen.

[Enter Claudius and Helen]

Claudius:
 Thou art as hairy as the sum of a disgusting horrible fatherless 
 dusty old rotten fat-kidneyed cat and a big dirty cursed war.
 Thou art as stupid as the product of thee and a fat smelly 
 half-witted dirty miserable vile weak son.

[Exeunt]

          Scene II: The complimenting of Helena.

[Enter Claudio and Helena]

Claudio:
 Thou art the sunny amazing proud healthy peaceful sweet joy.
 Thou art as amazing as the product of thee and the pretty
 lovely young gentle handsome rich Hero. Thou art as great 
 as the sum of thee and the product of a fair golden prompt good honest 
 charming loving noble king and a embroidered rich smooth golden angel.

[Exeunt]

          Scene III: The insulting of Claudio

[Enter Claudius and Helen]

Helen:
 Thou art as stupid as the sum of the sum of thee and a cat and me.
[Exit Helen]

[Enter Claudio]

Claudius:
 Thou art as stupid as the sum of thee and the product of the 
 product of me and Helen and Helena

[Exeunt]

          Scene IV: The Final Countdown

[Enter The Archbishop of Canterbury and Claudius]

Claudius:
 Thou art the sum of you and a cat.

The Archbishop of Canterbury:
 Am I better than a fine road?

Claudius:
 If not, let us return to the insulting of Claudio.

[Exit The Archbishop of Canterbury]

[Enter Claudio]

Claudio: << changed Claudius to Claudio
 Open your heart!
 Open your heart!
[Exeunt]

Nope, Claudio value is not 1 xD. Better luck next time.
AboveFire

@AboveFire - crud.. I'll have another look at it when i get home, really thought I had it :(
Alex Carlsen

That was my first guess, too, but I didn't have a chance to try it, yet. Anyway, the only part I didn't understand yet is the one with the archbishop so I'll have a look at that when I get home.
Sumyrda - Reinstate Monica

3

VBA by JimmyJazzx

Changed IRR to MIRR and changed 5 to a , so there are 3 parameters.

I found this while looking for how Excel's IRR function works. There was an article: How Excel's MIRR Function Can Fix the IRR Function. That tipped me off. Clever attempt, though. I'd never used VBA before, so that was interesting as well.

Sub q()
Dim a(2) As Double
a(0)=-5
a(1)=10
msgBox MIRR(a,0.2,3)
End Sub

Nice. Technically i added both the M and the , so the middle arg was 0.25 but i think they end up having the same result anyway. Thought using some finance functions could stump the programmers but was revealed by the documentation. Good job
JimmyJazzx

3

Matlab / Octave, Jonas

Description

In the last line, add ' to transform arg' into the string 'arg', which will then be interpreted as ASCII numbers. And then add another ' at the end to maintain the column format.

The almost unnecessary ' in the original code was the main clue. Also, in restrospect, the fact that arg was defined separately (instead of directly within the sin line) should have looked suspicious.

Code

format long
arg = [.1 .2 .3];
sin('arg'*exp(9))'

3

bc, abligh

Merely inserted the math operators. Took about 1 minute to solve once I looked up what bc was and what math operations it had. The first thing I thought of was division, but there weren't common factors that looked nice. So I immediately went for exponentiation and modulus. At least 15 digits were necessary for the modulus b/c of the expected output. After that, I guessed twice and found it.

4518^574%615489737231532

3

Lua, TreFox

Description

"_G" is the global table, making "_G.load" refer to the global function "load". Converting a function to a string results in returning the function's address, which is then made into the length of the string by the length-operator "#".

Code

G={load="lfkjgGsHjkU83fy6dtrg"}
print(#tostring(_G.load))

Also, since this is my first post on here, I can't make a comment on the original answer.


I've left a comment on the cop answer. By the way, this doesn't quite work for me. The address is I get is 0x321a40c6d0, for a final output of 22.
Dennis

I am not sure why you are getting 22... on everything I tested it was 18 or 26.
TreFox

@Dennis Try it in the official lua demo.
Xrott

Aha, I was so close! I knew I needed the global load, and I knew _G referred to the global symbol table... I just didn't put the two together.
Alex Van Liew

3

Python, rp.beltran

Description

I noticed that the needed letters were always 2 in front of a digit. changing the third \w to \d got all of the right letters except the spaces. \D was the only \ group I could find that allowed letters and spaces.

Code

import re;''.join(re.findall('\D(?=\w\d)','t74q joh7 jv f9dfij9j bfjtf0e nnjen3j nnjrb6fgam3gtm5tem3hj s3eim7djsd3ye d5dfhg5un7ljmm8nan3nn6n k m2ftm5bsof5bf r5arm4ken8 adcm3nub0 nfrn6sn3jfeb6n d m6jda5 gdif5vh6 gij7fnb2eb0g '))

w -> D, w -> d in the regex.


3

Pyth, isaacg

Description

The original code does the following:

 CG      Convert "abcdefghijklmnopqrstuvwxyz" from base 256 to integer, yielding
         156490583352162063278528710879425690470022892627113539022649722.
   ^3y21 Compute 3^(2 * 21).
%        Calculate the modulus.

Since 156490583352162063278528710879425690470022892627113539022649722 - 58227066 gives 156490583352162063278528710879425690470022892627113538964422656, which equals 226 × 3 × 7 × 7477 × 381524422711 × 17007550201751761 × 2288745700077000184147, the desired output can be obtained by replacing ^3y21 with something that evaluates to a divisor of this product and is larger than 58227066.

The ^ in the original code suggests that we might use it to calculate a power of 2, the 3 that we could calculate a fitting divisor of the form 3 × 2n.

Both are misleading. Solutions with a Levenshtein distance of 3 (%CG^2 26, %CG^y2 13, %CG^4y13) or 4 (%CG.<3y13) are readily found, but the solution at distance 2 requires a different approach.

The lowercase alphabet (G) has 26 letters, so its power set (the set of all strictly increasing sequences of lowercase letters) has 226 elements. By replacing y2 with yG, we compute this power set.

We can retrieve the set's length by replacing 3 with l, which leaves us with ^lyG1, i.e., 226 raised to the first power.

Code

%CG^lyG1

Note that this will only work on a computer with enough available memory (roughly 6.43 GiB, according to time), so it will not work with the online interpreter.

Here's how you can verify the results from the command line:

$ \time -v pyth -c '%CG^lyG1'
58227066
        Command being timed: "pyth/pyth.py -c %CG^lyG1"
        User time (seconds): 30.73
        System time (seconds): 2.12
        Percent of CPU this job got: 100%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:32.85
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 6742564
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 2269338
        Voluntary context switches: 1
        Involuntary context switches: 58
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

Correct! Well done.
isaacg
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.