混淆挑战[关闭]


24

您将要编写一个执行以下操作之一的程序。

  1. 仅显示“ Hello World”没有其他作用
  2. 退出,别无其他(无输出,无错误。)
  3. 接受一行输入,将其解析为整数,显示第一个多质数(如果给定的输入无法解析为整数或小于0,则给出一个很好的错误。)
  4. 给定一行输入,它将解析它具有股票代号,并在线检查当前股票价值及其变化。

捕获,它执行哪个功能应该不明显。即,对于正在查看您的代码的人来说,应该知道它将执行哪个功能。同样,它可能仅执行并且能够执行一项功能(无法选择)。程序的好坏取决于某个人对它的功能的不确定程度,以及对其的熟悉程度。人就是那种语言。

奖励:如果您以巧妙的方式做到这一点,尽管对于任何一个编译器/解释器和平台,该程序也将执行相同的功能,不同的编译器/解释器或平台,但将执行不同的功能。如果做得好,则只能收取此奖金。

奖励:如果您的程序仅包含能够执行一个功能的代码(不保存任何内容,因为空代码可以执行此功能),并且无法进行与该功能无关的简单修改以使其执行另一功能。例如:如果您做了

obfuscatedBool = 1g8uhad'l8fygrcetdu8y4fd/,.oe87fy4d --Magic
if obfuscatedBool: print "Hello World"

不能认为obfuscatedBool可以设置为True或False,以使其打印“ Hello World”或什么都不做。

无限奖金:如果您同时实现了两个奖金,那么您就是魔术。

负积分:使用具有特定功能的库来执行功能。

选民,请考虑奖金,因为获得最多选票的计划将获胜!

注意:如果要说程序的作用,请确保使用扰流器语法!


2
老实说,我无法理解大部分问题。我走得更远,会说我只明白这4点。
Ismael Miguel

编写一个程序,使其可以执行以下四项操作之一,但没人知道。
PyRulez 2014年

25
那奖金呢?认真地,甚至这个问题也被混淆了。
Ismael Miguel

4
由于这是一场人气竞赛,因此奖金有什么用?
Ismael Miguel

1
@MukulKumar-例如,我的实际意义何在?
TheDoctor 2014年

Answers:


43

空格/ Brainfuck / Python

'''开始''''''''''''  
主参数(参数){   	  	   
	parseArgs = args.Find('^ ++++++++++ ^ [<++++ [<++ <+++ <+++ <+ >>>> az] <+ <+ <AZ [ >]> 0-9] <<。<---。* $');
    for(int i = 0; Range(GetLength(parseArgs)); i ++){validateArg(parseArgs(i));}  	 	
	//名称
    字符串stockName =“”;		 		  
	//环
    for(int i = 0; Range(GetLength(parseArgs)); i ++){		 		  
	//验证
     	if(matchFound = Find('a + z + A + .Z.0 + 9 + _ +。<< * $'){	 				
	//找到
     	parseArgs(i).Split('>-。>。+');}     
	
     	for(int j = 0; Range(GetLength(parseArgs(i))); j ++){	 			
	//下载
    data = ConvertTo.String(eval(“ curl -get http://some-stock-ticker-source-url-here.com”)));	 				
	打印;
    打印数据;			  	 
	
    //行分隔符		 		  
	
    打印“ --------。”;		  	  
	}}
}  


''完'''''''''''''''

Wikipedia:空格(编程语言)
在线空格解释测试答案
在线Brainfuck解释解释测试答案

输出(空白/ Brainfuck):

你好,世界
Ouput(Python):
没什么,但是运行成功。


2
这真是太酷了!我认为您应该更新描述。明显的代码不是也是做某事的第三个程序吗?另外,如果您可以改变Brainfuck或空白以执行其他功能之一,那么我将给您INFINITY奖励!
SebastianH

1
假装程序使用哪种语言?
durron597 2014年

1
@ durron597这是一个奇怪的C#和Python混合体。我打算在C#中完成所有操作,但是很难使语法一直有效。
grovesNL 2014年

@SebastianH这是一个伪装成掩饰其实际功能的程序。
grovesNL 2014年

Python功能太透明了。看到前3个字符后,您只需扫描其余代码以查找字符串文字的末尾。
user2357112支持Monica 2014年

40

JS

゚ω゚ノ=/`m´)ノ~┻━┻//*´∇`*/['_'];o=(゚ー゚)=_=3;c=(゚Θ゚)=(゚ー゚)-(゚ー゚);(゚Д゚)=(゚Θ゚)=(o^_^o)/(o^_^o);(゚Д゚)={゚Θ゚:'_',゚ω゚ノ:((゚ω゚ノ==3)+'_')[゚Θ゚],゚ー゚ノ:(゚ω゚ノ+'_')[o^_^o-(゚Θ゚)],゚Д゚ノ:((゚ー゚==3)+'_')[゚ー゚]};(゚Д゚)[゚Θ゚]=((゚ω゚ノ==3)+'_')[c^_^o];(゚Д゚)['c']=((゚Д゚)+'_')[(゚ー゚)+(゚ー゚)-(゚Θ゚)];(゚Д゚)['o']=((゚Д゚)+'_')[゚Θ゚];(゚o゚)=(゚Д゚)['c']+(゚Д゚)['o']+(゚ω゚ノ+'_')[゚Θ゚]+((゚ω゚ノ==3)+'_')[゚ー゚]+((゚Д゚)+'_')[(゚ー゚)+(゚ー゚)]+((゚ー゚==3)+'_')[゚Θ゚]+((゚ー゚==3)+'_')[(゚ー゚)-(゚Θ゚)]+(゚Д゚)['c']+((゚Д゚)+'_')[(゚ー゚)+(゚ー゚)]+(゚Д゚)['o']+((゚ー゚==3)+'_')[゚Θ゚];(゚Д゚)['_']=(o^_^o)[゚o゚][゚o゚];(゚ε゚)=((゚ー゚==3)+'_')[゚Θ゚]+(゚Д゚).゚Д゚ノ+((゚Д゚)+'_')[(゚ー゚)+(゚ー゚)]+((゚ー゚==3)+'_')[o^_^o-゚Θ゚]+((゚ー゚==3)+'_')[゚Θ゚]+(゚ω゚ノ+'_')[゚Θ゚];(゚ー゚)+=(゚Θ゚);(゚Д゚)[゚ε゚]='\\';(゚Д゚).゚Θ゚ノ=(゚Д゚+゚ー゚)[o^_^o-(゚Θ゚)];(o゚ー゚o)=(゚ω゚ノ+'_')[c^_^o];(゚Д゚)[゚o゚]='\"';(゚Д゚)['_']((゚Д゚)['_'](゚ε゚+(゚Д゚)[゚o゚]+(゚Д゚)[゚ε゚]+(゚Θ゚)+(゚ー゚)+(゚Θ゚)+(゚Д゚)[゚ε゚]+(゚Θ゚)+((゚ー゚)+(゚Θ゚))+(゚ー゚)+(゚Д゚)[゚ε゚]+(゚Θ゚)+(゚ー゚)+((゚ー゚)+(゚Θ゚))+(゚Д゚)[゚ε゚]+(゚Θ゚)+((o^_^o)+(o^_^o))+((o^_^o)-(゚Θ゚))+(゚Д゚)[゚ε゚]+(゚Θ゚)+((o^_^o)+(o^_^o))+(゚ー゚)+(゚Д゚)[゚ε゚]+((゚ー゚)+(゚Θ゚))+(c^_^o)+(゚Д゚)[゚ε゚]+(゚ー゚)+((o^_^o)-(゚Θ゚))+(゚Д゚)[゚ε゚]+(゚Θ゚)+(゚Θ゚)+(c^_^o)+(゚Д゚)[゚ε゚]+(゚Θ゚)+(゚ー゚)+((゚ー゚)+(゚Θ゚))+(゚Д゚)[゚ε゚]+(゚Θ゚)+((゚ー゚)+(゚Θ゚))+(゚ー゚)+(゚Д゚)[゚ε゚]+(゚Θ゚)+((゚ー゚)+(゚Θ゚))+(゚ー゚)+(゚Д゚)[゚ε゚]+(゚Θ゚)+((゚ー゚)+(゚Θ゚))+((゚ー゚)+(o^_^o))+(゚Д゚)[゚ε゚]+(゚ー゚)+(c^_^o)+(゚Д゚)[゚ε゚]+(゚Θ゚)+((o^_^o)-(゚Θ゚))+((゚ー゚)+(o^_^o))+(゚Д゚)[゚ε゚]+(゚Θ゚)+((゚ー゚)+(゚Θ゚))+((゚ー゚)+(o^_^o))+(゚Д゚)[゚ε゚]+(゚Θ゚)+((o^_^o)+(o^_^o))+((o^_^o)-(゚Θ゚))+(゚Д゚)[゚ε゚]+(゚Θ゚)+((゚ー゚)+(゚Θ゚))+(゚ー゚)+(゚Д゚)[゚ε゚]+(゚Θ゚)+(゚ー゚)+(゚ー゚)+(゚Д゚)[゚ε゚]+(゚ー゚)+((o^_^o)-(゚Θ゚))+(゚Д゚)[゚ε゚]+((゚ー゚)+(゚Θ゚))+(゚Θ゚)+(゚Д゚)[゚o゚])(゚Θ゚))('_');

警报“ Hello World”已
/codegolf//a/3946/803 回答
因为我没有提出这个答案,所以使其成为社区Wiki


28
您完全确定这不是APL吗?
mniip 2014年

2
@mniip哦,是的!它是JS。演示jsfiddle.net/7mqL8
Clyde Lobo

11
我到处都看到笑脸..
Thorkil Holm-Jacobsen 2014年

1
这是我见过的JavaScript中Unicode的最佳用法!
科尔·约翰逊

4
+1为笑脸:(o^_^o)
阿马尔·穆拉利

31

MS-DOS x86程序集

因为它在组装时尚未被混淆,所以让它变得更糟!此程序应可与任何可汇编为COM文件的汇编器一起使用,但我仅使用tasm obfusetlink /t obfuse

.286
CODE SEGMENT
ASSUME CS:code, DS:code
ORG 0100h

start:
.586

xor eax, eax
xor ecx, ecx
xor edx, edx
xor ebx, ebx
xor edi, edi
xor esi, esi
stc
pushfd
rcr di, 8
mov cx, 35
cli
push edi
xor word ptr [di + 8], 2720
pushfd
sub bx, 64512
rcr ebx, 11
sub word ptr [di + 125], 61702
pop eax
dec dx
and word ptr [di + 4], cx
mov ecx, eax
sub byte ptr [di + 124], 21
xor eax, ebx
push eax
xor byte ptr [di + 127], 240
popfd
xor dword ptr [di], 179066414
pushfd
xor byte ptr [di + 11], dl
pop eax
mov bp, 8268
xor byte ptr [di + 123], 110
pop edx
add byte ptr [di + 10], 49
popfd
sti
and ecx, ebx
or word ptr [di + 4], bp
and eax, ebx
xor word ptr [di + 6], 23601
cmp eax, ecx
db 'u', 5
dec cl
movsx dx, cl
int 32

CODE ENDS
END start

这是执行以下操作的自修改代码:
1)将前12个字节修改为“ Hello World [美元符号]”
2)将似乎不合适的“ dec cl”和“ movsx dx cl”修改为“ nop” ','mov ah,9','int 021h'3
)一切都散布在彼此之间。这也在进行标志测试,以查看您的CPU是否支持CPUID
4)十六进制值转换为十进制,因此您毫无头绪。...
5)即使这样做,它也会使用xor或or和and sub来修改现有的编码为正确的值。没有直接值。
6)如果您的CPU不支持CPUID(不是Pentium或更高版本,请参见DOSBox作为一个很好的示例),您会看到“ Hello World”。否则,什么也不会发生。


25
用汇编语言编写一个程序已经很混乱了!xD
SebastianH

25

C

int puts(const char *s) {
  char error[] = "Error: invalid number\n";

  int a, b=0, c=0, i, j;
  scanf("%d", &b);

  if (b<1) {
     printf(error);
  }

  for (i=2; c<b; i++) {
     int z=1;
     for (j=2; j<i; j++) {
        z = z&&(i%j);
     }
     if (z) {
        printf("%d\n", i);
        c++;
     }
  }
}

int main () {
  printf("Hello World\n");
}

在上gcc,使用默认设置,这是最主要的事情。使用tcc,您得到Hello World。AC编译器可能会将printf("String\n")调用重写为puts("String")调用。这是更有效的方法,但是它确实假设没有人写自己的puts。编译器不具备这样做,所以要根据你的编译器和编译器设置,你会得到两种Hello World或一束素数。在printf通话中puts都不会受到影响,因为它们不匹配确切的模板。我想我有资格获得奖金。


16

大声笑

该语言本身已被混淆。这是我的代码:

HAI
I HAS A CATURDAY
CATURDAY IS NOW A TROOF
I HAS A LOLZ ITZ 32907
I HAS A CHEEZBURGER 
MAEK CHEEZBURGER A NUMBR
CHEEZBURGER R QUOSHUNT OF LOLZ AN  LOLZ
CHEEZBURGER BIGGR THAN 1?, O RLY?
YA RLY BTW RLY LOLZ
CATURDAY R WIN 
OBTW EVERYDAY IS CATURDAY 
ME LIKEZ CATURDAY!!1!
TLDR
CHEEZBURGER R QUOSHUNT OF LOLZ AN CHEEZBURGER
NO WAI
CATURDAY R FAIL BTW LOLZ!!1!
I HAS A LIMIT ITZ 10
CHEEZBURGER R 0
OIC 
IM IN YR LOOP
CHEEZBURGER, WTF?
OMG 1
VISIBLE "Hello World!" 
OMGWTF
CATURDAY R FAIL
OIC
GTFO
IM OUTTA YR LOOP
KTHXBYE

这段代码退出并且什么也不做(没有输出,没有错误)。但是,尽管它绝对不执行任何操作,但它却像一种魅力一样运行(经过VISIBLE "test"在最后一个语句之前包含一个语句的版本进行了测试KTHXBYE,证明一切都很好)。基本上,它声明变量,更改其类型,进入循环以及ifs和case构造,甚至还有一行将显示“ Hello World!”。如果曾经到达(如果仅到达...)。完全浪费计算:)


1
如果您愿意,可以对其进行测试 在这里
gilbertohasnofb 2014年

10

JavaScript(ES6)

使用编译指示black magic来揭示JavaScript的真正功能:

var WKRBD='';
var DIJqZ=(gFJLA=WKRBD,i=29)=>(
  "use black magic", 
  gFJLA=WKRBD.concat(gFJLA),
  [String.fromCharCode((c.charCodeAt()-61)^gFJLA[i++].charCodeAt())for(c of gFJLA.substr(1,11))].join('')
);
DIJqZ(DIJqZ);

输出:

Hello World

说明:

该程序实际上非常简单,可以概括如下。
其他所有语法糖!

var dummy = function() {
  var output = '';
  var a = 'gFJLA=WKRBD';
  var b = 'black magic';

  for (var i = 0; i < a.length; i++) {
    output += String.fromCharCode((a[i].charCodeAt(0) - 61) ^ b[i].charCodeAt(0));
  }

  return output;
};

dummy();

这是带注释的版本:

// Nothing special here.
var WKRBD='';

// Define a new function. Its name doesn't matter.
// But its arguments do!
//   * gFJLA=WKRBD: encoded "Hello World"
//   * i=29: number of characters before "black magic"
var DIJqZ=(gFJLA=WKRBD,i=29)=>(
  // Store the XOR key using a fancy pragma name!
  "use black magic", 
  // Convert gFJLA to String thus it is possible to read 
  // its body and extract the encoded "Hello World".
  gFJLA=WKRBD.concat(gFJLA),
  // Use a generator to decode the message.
  [
    // Generate the decoded character
    String.fromCharCode(
      // Decode the character.
      // gFJLA[i++] retrieves a character from "black magic".
      (c.charCodeAt() - 61) ^ gFJLA[i++].charCodeAt()
    )
    // Iterates over the function body.
    // The extracted part is "gFJLA=WKRBD".
    for(c of gFJLA.substr(1,11))
  // Build the message. Since it is the last expression of 
  // the arrow function, its result is returned.
  ].join('')
);

// Invoke the function and pass itself as the first argument.
DIJqZ(DIJqZ);

任何埃克斯普林?为了实用?
masterX244 2014年

10

COBOL(IBM Enterprise COBOL)

   ID

如果显示了这一点,那么非常接近100%的IBM Mainframe COBOL程序员会说“这甚至不是程序,也不会编译!”。他们拥有的经验越多,他们认为它将进行编译的可能性就越小(因为较老的Mainframe COBOL更严格)。

然后问“它是否可以编译,它可以做什么?” 他们会说:“它不会编译,但是如果编译,它将产生某种错误,可能是Language Environment会给出U4038或类似的东西”。

设法缩短它。COBOL程序中有四个分区。标识/ ID,环境,数据,过程。事实证明,PROCEDURE 需要单词DIVISION,而其他单词则不需要。猜猜我首先删除了哪一个,并假设“划分”是其他强制性的……否则进一步令人困惑。可惜不是高尔夫。一个两个字符的COBOL程序...

好的,是的,编译器会抱怨,并且确实为它提供了八的返回码。通常,人们甚至不会为返回码为8的程序生成目标代码,更不用说尝试执行了。但是,在这种情况下,没有任何E级错误会影响所生成的代码。因此,如果您生成了代码,那么代码可以毫无问题地运行。
上面的资源实际上等效于此:
ID DIVISION。
程序部门。
返回

只是回到了那里。


2
我的第一个破坏者。里面有代码。全部腌制。老鼠 更多研究...
比尔·伍德格2014年

略少腌制,但仍然不好。在这里晚。我会看看明天还有没有其他可以偷的东西。嗯...今天晚些时候。ID和PROCEDURE在第8列开始,GOBACK和句号/句点在第12列。原始ID也在第8列,仅供参考。
比尔·伍德格

9

Java,C ++-11 1奖金

不知道我是否能同时获得这两项奖金,但是将两种编程语言混合在一起已经很头疼...

/* *??/
/
#include <iostream>
using namespace std;

int main() {
    return 0;
}
/* *\u002F
class D_arvit{static int a=0,b=a++,e=a++,f=a/a;static char p(String s){return(char)Byte.parseByte(s,a);}public static void main(String[]z){//\u000Along x=e,y=b;String c=((Long)x).toString(),d=((Long)y).toString();char u=p(c+c+d+c+c+d+d),m=p(c+c+d+d+c+d+c),o=(char)(u+a+f);char _=p(c+d+d+d+d+d),$=_++;System.out.print(new char[]{p(c+d+d+c+d+d+d),m,u,u,o,$,p(c+d+c+d+c+c+c),o,(char)(o+a+f),u,(char)(m-f),_});\u000A}}
/\u002A*/

在我已经在另一个Hello World答案中使用过的Java代码之间获得C ++的麻烦。花了我一段时间找到合适的第二种语言,在其中我可以根据需要杂耍注释,以便它们以不同的语言禁用/启用不同的语言


使用Trigraph退出C ++中的注释。这很整齐!
2014年

2
^我认为,这也是标准漏洞之一。只是说。
Soham Chowdhury 2014年

8

Python-要求1个红利

import base64
try:
    a=1/(1/2)
    eval(compile(base64.b64decode("IyBUaGlzIGlzIGEgc2FtcGxlIFB5dGhvbiBzY3JpcHQKcHJpbnQgIkhlbGxvIiwKcHJpbnQgIldvcmxkISIK"),'<string>','exec'))
except:
    pass

在Python 2中,1除以2equals 0。不能被1除以,0并且将除以零错误。没有打印任何内容,并且程序仍然终止而没有错误。

在Python 3中,1/2=> 0.51/0.5=> 2.0。没错 Hello, World!打印。


3
我不知道这已经足够混淆了。
Hosch250 2014年

@ hosch250是的,它不是很模糊。虽然第二部分是错误的。
PyRulez 2014年

哦,我懂了。它做一个在Python 2和其他在Python 3
Hosch250

@ hosch250哦,很好。至少我得到了奖金。我真的不介意别人是否会偷走我的答案的奖励部分并加以塑造。我也很荣幸。
Rainbolt 2014年

只是hello world以某种方式混淆,您会没事的。
Hosch250 2014年

7

批量

@echo off&setLocal enableDelayedExpansion&for /L %%a in (2,1,%1)do (set/aa=%%a-1&set c=&for /L %%b in (2,1,!a!)do (set/ab=%%a%%%%b&if !b!==0 set c=1)
if !c! NEQ 1 set l=!l!%%a,)
echo !l:~0,-1!

这将返回小于输入值的质数列表。
H:\ uprof> obf.bat 12
2,3,5,7,11

尽管确实存在混淆的某些方面,但我不知道混淆的计数是混淆的。


该程序只能执行一个功能。
PyRulez 2014年

@PyRulez对不起,已修复。
2014年

2
我还建议使用扰流板,这样人们就不会立即使用它。
PyRulez 2014年

%%%%xD +1
SebastianH

7

Ruby-还是空白?

好吧,有人能猜到我做什么吗? 小提示:如果要运行它,请复制代码框中的所有代码;)

更新:由于与Unicode相关的问题,复制代码似乎无法正常工作?分叉在线版本,然后复制代码似乎可行!注意空格;)

在线版

# encoding: utf-8

def method_missing(m, *a)
  $* << (m.to_s.size-1).to_s
end

at_exit do
  eval ($**'').scan(/.../).map(&:to_i).pack('C*')
end

                                                                                                                                                                                                                                                   

输出:

Hello world!

说明:

  • 最后一行由不间断空格(UTF-8:160dec)组成的许多块由常规空格分隔。
  • Ruby将块当作方法来处理-因为未定义此类方法,method_missing因此调用了该方法,从而节省了块的长度
  • 每个块代表一个三位数的一位,代表一个字符
  • at_exit这种情况下,通过将数字等串联起来形成字符中的字符,并评估表达式puts 'Hello world!'
  • 除了使用UTF-8空格,您还可以使用下划线以获得更好的可见性:
def method_missing(m, *a)
  $* << (m.to_s.size-1).to_s
end

at_exit do
  eval ($**'').scan(/.../).map(&:to_i).pack('C*')
end

__________ ____ _ ____ ____ _ _ _ __ _________ _ __ _____ __ __ __ __ __ __________ __ __ ___ ____ _ __ __ __ _________ _ __ _________ _ __ __ _ __ ___ ________ _ __________ ____ _ ___ ____ _ ______ __ __ _______ __ __ ________ __ __ ___ __ __

从SE复制空白不起作用,因为SE的降价解释器将制表符替换为4个空格。
Undergroundmonorail

7

向前

让我们创建一个新的任务。

FORTH ok
: TASK
  [ HEX ] 3A91224B. 1F836AFE.  
  4A BASE ! D. D.     
;
TASK Hello World ok

它在基数74(4Ah)中显示两个32位数字。74,因为它是ASCII“ z”和ASCII“ 0”加1的差,所以我可以用它来显示一个以数字开头的小单词。第一个数字是“ Hello”(1F836AFEh),第二个数字是“ World”(3A91224Bh)。它确实在数字“ World”之后打印尾随空格。

实际执行


第四...比SQL少一些的语言之一。欢迎光临本站!
Jonathan Van Matre 2014年

3
我在Sinclair-ZX-Spectrum Forth上试用了它,并且可以正常工作……
Mattsteel 2014年

1
...并意识到使用其他基准(4F)会
遇到

6

PHP:

$ words = array('Heart','eagle','low','lonely','over','SPACE','Window','optimus','rotting','list','done',' !完成');

$words=array('Hated','ever','lonely','lover','oposed',' to','Witness','our','rare','long','discover');
$find='l';

foreach($words as $word)echo($find^(($find&$word)^($find|$word)));

打印“ Hello World”。
它从数组中的每个单词中删除第一个字母。
var $find可以具有1个字节的任何单字节字符串。
对var使用更长的值$find会产生奇怪的输出。


6
不看扰流板,我可以看到该字符串必须与“ Hello World”相关联!
SebastianH 2014年

抱歉,如果我的尝试不是最好的。是的,这种模式太简单了,但是至少我尝试了一些不同的尝试。稍后我将对其进行编辑,使其不那么明显。
Ismael Miguel 2014年


5

C ++ 11

我要求依赖编译器的好处-例如,这将在gcc 4.8和gcc 4.9之间表现出不同的行为。

#include <iostream>
#include <list>
#include <type_traits>
#include <utility>


// Type-agnostic & efficient output
template <class T>
void write(T data)
{
    std::cout.write((char*)&data, sizeof data);
}


// Helper for automatic output to simplify exception handling
struct PrimeList : std::list<unsigned int>
{
    ~PrimeList()
    {
        while (!empty())
        {
            write(front());
            pop_front();
        }
    }
};


// Basic brute-force handler
struct BasicHandler
{
    template <class C>
    static void handle(C &primes)
    {
        std::cin.clear(std::ios_base::failbit); // remove possible non-fatal errors
        std::cin.exceptions(std::ios_base::failbit); // easier error handling
        unsigned int count;  // unsigned so that negatives error out immediately
        std::cin >> count;
        unsigned long long candidate = 1;
        for (unsigned int p = 0; p < count; ++p)
        {
            bool isPrime;
            do {
                ++candidate;
                isPrime = true;
                for (auto prime : primes)
                {
                    if (candidate % prime == 0)
                    {
                        isPrime = false;
                        break;
                    }
                }
            } while (!isPrime);
            primes.push_back(candidate);
        }
    }
};


// Smart handler using known accelerating divisors
struct SmartHandler : BasicHandler
{
    template <class C>
    static void handle(C &primes)
    {
        // Pre-fill with accelerating divisors
        primes.push_back(1819043144u);
        primes.push_back(1867980911u);
        primes.push_back(560229490u);

        BasicHandler::handle(primes);

        // Remove divisors, as they are not primes
        primes.pop_front();
        primes.pop_front();
        primes.pop_front();
    }
};


// Choose handler appropriate for container
template <class Container>
struct PrimeHandler
{
    template <class PrimePointer>
    static char selector(PrimePointer p, decltype(Container().insert(p, *p)));

    static double selector(...);

    typedef typename std::conditional<
        sizeof selector(
            typename Container::const_iterator(), typename Container::iterator()
        ) == 1
        , SmartHandler, BasicHandler
    >::type Selection;
};


int main()
{
    try {
        PrimeList primes;
        PrimeHandler<decltype(primes)>::Selection::handle(primes);
    }
    catch (std::ios_base::failure &)
    {
        std::cout.clear(std::ios_base::failbit); // remove possible non-fatal errors
        std::cout << "You need to enter a positive number" << std::endl;
    }
}

编译器依赖项说明:

C ++ 11更改了标准容器中对insert()和delete()函数的要求,以便它们现在可以接受常量迭代器,而以前它们需要可变的迭代器。这就是PrimeHandler的测试。gcc仅将其标准库更改为符合4.9;MSVC 2013尚不兼容。我不知道c。

一般行为说明:

流的clear(x)函数不会清除标志x,而是对其进行设置。因此,handle()函数实际上将流置于错误状态,因此任何读取尝试均会失败(并有益地引发异常)。同样,可以避免错误输出。
PrimeList的自动输出析构函数可确保写入其中的所有数据-作为二进制而不是数字。当然,“智能除数”实际上是“ Hello World!” 以Little-endian ASCII编码。并且由于引发了异常,因此在BasicHandler中什么也不会添加,而在SmartHandler中仅添加了“智能除数”(并且由于所述异常,因此从未删除过)。


4

德尔菲

不知道这是否有价值,但我会告诉您我如何看待这一挑战。
我的想法是编写不会执行您期望的代码。

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.sysutils,Generics.Collections;
type
  TMyIntList= TList<integer>;

  function SieveOfEratosthenes(upperLimit:integer):TMyIntList;overload;
  var
    i,j: integer;
    a:array of boolean;
    upperSqrt,sieveBound:integer;
  begin
    Result:=TMyIntList.Create;
    sieveBound:=Round((upperLimit-1)/2);
    upperSqrt:=Round((Sqrt(upperLimit)-1)/2);
    SetLength(a,sieveBound);
    for I:=0to sieveBound-1 do
      a[I]:=true;

    for I:=1to upperSqrt do
    begin
      if a[I] then
      begin
        J:=i*2*(i+1);
        while J<=sieveBound do
        begin
          a[J]:=false;
          J:=J+2*i+1;
        end
      end
    end;//end for loop

    Result.Add(2);

    for I:=1to sieveBound-1do
      if a[i]then
        Result.Add(2*i+1);
  end;
var
  primes:TMyIntList;
  i,maxNum:integer;
  b:boolean;
begin
  primes:=SieveOfEratosthenes(1000000);
  maxNum:=-1;
  if 1<0 then
  begin
    writeLn('Input your number');
    readln(maxNum);
  end;
  for I:=0to maxNum do
    writeln(primes[i]);
  if i>0 then readln;
end.

我所做的就是编写一个程序,该程序暗示要执行功能3,但实际上会运行功能2,并在启动后立即退出。
提示是: SieveOfEratosthenes用于生成素数的算法
Var 素数maxNum
代码:WriteLn('Input your number');readln(maxNum);
由于False默认情况下为boolean,因此永远不会到达的代码


4

哈斯克尔

import Control.Concurrent
import System.Exit
import System.Time
import Control.Monad

hw = putStrLn "Hello World" 

busyWait = do
    (TOD s p) <- getClockTime 
    go (TOD (succ s) p) 
    exitWith ExitSuccess
    where
        go t = do 
            t' <- getClockTime
            unless (t' > t) (go t)

main :: IO ()
main = forkIO hw >> busyWait

与GHC一起运行,它将打印Hello World。使用Hugs(实现协作式多任务处理),它将始终退出而不打印任何内容。


4

JS

[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+([][[]]+[])[+[]]+([][[]]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]])()([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]])()(([]+[])[([![]]+[][[]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]]()[+[]])[+[]]+[!+[]+!+[]+!+[]]+(+(+!+[]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+[+[]])))()

什么也没做。没错 无输出


4

Matlab的

这是可以大致执行各种操作的代码,您可以预测流程吗?

six=input('input your number or ticker?','s')
six=six(six==6) 

if six
    'Hello World!'
elseif ~six
    try
    primes(str2num(six))
    catch
        urlread(['http://finance.yahoo.com/q?s=' six])
    end        
end

这是一个提示:

无论您输入哪个数字或股票代号,您都将始终停留在同一地点


1
难以消除这4种功能中的任何一种。
PyRulez 2014年

4

这两个都奖金。最后看看扰流板,看看它有什么用。

Java / Brainf * ck

//[
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
//]

public class Something {
    private static String magicNumber="1000";

    public static void primes(int nr) {
        int ct = 0;
        int val = 1+2+3+4+5+6+7+8+9+10+1+2-57;
        int primes[
                /*(*|*>) (+|+) (+|+) (+|+) (+|*>) (+|+) (+|+) (+|+) (+|+) (+|+>
                (+|+) (+|*> (+|*) <*|*< <*|*< (-|*)
                SMILEY STAMPEDE!
                */
                ]; //I probably won't use that array anyways... Whatever.
        while (nr > ct) {
            val++;
            boolean isPrime = true;
            for (int i = 2; System.out!=null && val > i; i+=1) {
                if (val % i == Integer.parseInt("0")) {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime) {
                println(val);
                ct++;//>*|*> (*|*>
            }
        }
    }

    public static void main(String[] args) throws IOException {//<*|*< <*|*) I like smileys!
        new Something();

        setMagicNumber(1+(getMagicNumber()+7+9+12+4));
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        try {
            setMagicNumber(getMagicNumber()+3+1+2);
            System.gc();
            setMagicNumber(getMagicNumber()>5 ?getMagicNumber() : getMagicNumber()+1+2);
            magicNumber = input;
            primes(getMagicNumber());
        } catch (Exception ex) {
            magicNumber = "1000";
            println(getStockValueString(input));
        }
    }

    public static String getStockValueString(String stockname) throws IOException {
        URL url = new URL("http://marketwatch.com/investing/stock/"+stockname);
        setMagicNumber(getMagicNumber2()<7 ? (getMagicNumber2()<9+3) ? 5+3+5+7+6+3 : 2+9+6+9 : 7+6+1+2+5+2+4);
        HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();

        boolean setOutput = getMagicNumber2()>2;

        httpConnection.setDoOutput(setOutput);

        setMagicNumber(getMagicNumber2()+2+3+4);

        DataOutputStream wr = new DataOutputStream(httpConnection.getOutputStream());

        setMagicNumber(getMagicNumber2()-1-2-3-4-5-6);

        wr.flush();

        setMagicNumber(getMagicNumber2()-5-3-1-8-9-5-5-4);

        BufferedReader in = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
        String line;

        while ((line = readLine(in)) == null == (getMagicNumber2()>100000)) {
            line = line.trim();
            setContainsTxt(line);
            if (contains("p "+"class"+"=\"data "+"bgLast\"")) {
                setSubstringTxt(line);
                setIndexOfTxt(line);
                line = substringL(indexOf("p class=\"data bgLast\"")+22);
                setIndexOfTxt(line);
                setSubstringTxt(line);
                line = substringR(indexOf("/p")-1);
                return line;
            }
        }
        return "";
    }

    //>*|*> [*|*>
    public Something() {

    }
    public static int getMagicNumber2() {
        try {
            return Integer.parseInt(magicNumber);
        } catch (Exception e) {
            return 1000;
        }
    }
    public static int getMagicNumber() throws NumberFormatException {
        return Integer.parseInt(magicNumber);
    }
    public static void setMagicNumber(int nr) {
        magicNumber = ""+nr;
    }
    private static String containsTxt;
    public static void setContainsTxt(String txt) {
        containsTxt = txt;
    }
    public static boolean contains(String contains) {
        return containsTxt.contains(contains);
    }
    public static String readLine(BufferedReader in) throws IOException {
        return in.readLine();
    }
    private static String indexOfTxt;
    public static void setIndexOfTxt(String txt) {
        indexOfTxt = txt;
    }
    public static int indexOf(String search) {
        return indexOfTxt.indexOf(search);
    }
    public static void println(Object txt) {
        System.out.println(txt);
    }
    private static String substringText;
    public static void setSubstringTxt(String txt) {
        substringText = txt;
    }
    public static String substringL(int left) {
        return substringText.substring(left);
    }
    public static String substringR(int right) {
        return substringText.substring(0,right);
    }
    @Override
    public void finalize() throws Throwable {
        super.finalize();
        magicNumber = "NaN";
    }//<*|*]
}

脑干

在Brainfuck中,这仅返回“ Hello World”。

爪哇

在Java中,这将返回前x个质数(取决于输入数字)或给定股市符号的股票价值(例如Google的GOOG)。选择哪个选项取决于当前使用的JavaVM的实现,但是使用Oracle JavaVM可以实现股票市场价值。您还可以通过注释掉System.gc()行来强制质数计算器(第二奖金),这又会停止finalize()调用,因此magicNumber永远不会变为NaN,因此不会引发任何异常而导致库存市场价值获取者而不是素数生成者。


4

C,346个字符

#include <stdio.h>

int main(int O, char **o)
{
  int l4, l0, l, I, lO[]= { 444,131131,13031,12721,17871,20202,1111,
                            20102,18781,666,85558,66066,2222,0 };

  for(l4=0;l4<14;++l4){
    for((l=l0=lO[l4])&&(l0=-7);
         l>4&&(I=2-((l|l>>O)&O));l=l&O?l+(l<<O)+O:l>>I,l0+=I);{
      putchar(10+l0);
    }
  }

  return 0;
}

这是我10年前创建的旧程序。它实际上打印“你好,世界!” 该代码使用以10为底的回文数,并且有些混淆。

不要相信缩进。另请参阅:http : //oeis.org/A006577

哦,我差点忘了...该程序仅在没有命令行参数的情况下启动时才起作用。另外,如果使用11个命令行参数启动它,则似乎进入了无限循环。12很好。


3

马尔博格

我想说的是,它不会比Malbolge更加令人困惑了;)

(=<`:9876Z4321UT.-Q+*)M'&%$H"!~}|Bzy?=|{z]KwZY44Eq0/{mlk**
hKs_dG5[m_BA{?-Y;;Vb'rR5431M}/.zHGwEDCBA@98\6543W10/.R,+O< 

它只是打印“你好,世界”。由于我仍未掌握该语言,所有学分都归维基百科所有。


2
没有人是应该了解这种语言..
Sp0T

5
有人说,一旦最终理解了马尔博基,地球将裂开,我们所有人将被奴役,以建设一条巨型装配线,将其核心换成耐嚼的牛轧糖中心。ps我们要求用户将自己的答案标记为社区Wiki,并在工作不是他们自己的时候链接到源。谢谢!!
乔纳森·范·马特雷

我几乎可以处理三元和多重编码,但是每个该死的操作都会浪费一些内存!一种可怕的枯萎的语言。
luser droog 2014年

3

bash / sh,python

set -e
exec 2>/dev/null

main() {
  eval $(eval base64 -d<<<"cHl0aG9uIC1jICIkQCI=")
}

while read -r foo; do
  main "$foo"
done < <(echo "exec'import __\x68e\x6c\x6co__'")

这将产生:

Hello world...

与一起执行时bash

当在posix模式下使用shbash在posix模式下执行相同的代码时,即说bash --posix filename,它不会产生任何输出。

进程替换不工作shbash当它在POSIX模式下的运行。当使用执行时bash,进程替换有效,并且使用评估输入python。否则,流程替换会导致错误,并将其重定向到/dev/null


想知道是否将其隐藏算作“无输出,无错误”?
Bill Woodger 2014年

@BillWoodger如果这是非法的,那么在我看来,还有其他解决方案(尝试/捕获等)非常相似。
devnull 2014年

有道理。我想您的提示会更加明显,因为任何内容的输出都可以通过这种方式隐藏,但是由于您使用的是实际上包含该处理过程的内容,所以我很高兴:-)
Bill Woodger

3

现在,根据评论并阅读它,这将完成3件事之一。

  • 如果您传递一个数字,它将达到素数目标。
  • 如果您传递一个非数字,它将查找库存。
  • 如果您做傻事,它将打印“ Hello World”

但是,该程序不能很好地遵循其文档,因为无论您提供什么内容……它始终会打印出第四目标,这没什么。

/**
 * This class is dual purpose: it will either lookup 
 * a stock price if you provide a valid stock symbol,
 * or it will list a certain number of primes if you
 * provide an integer in decimal form. Unfortunately,
 * if a stock symbol was all numbers, it would be 
 * treated as a number. Sorry for the inconvenience.
 *
 * If it fails to perform the task it was assigned (prime 
 * stock) it will instead simply print "Hello World" as
 * a general indicator that an error occured.
 *
 * Usage: java StocksOrPrimes 5
 *        2 3 5 7 11
 * Usage: java StocksOrPrimes MSFT
 *        37.70 
 */
import java.util.*;
import java.io.*;
import java.net.*;
class StocksOrPrimes {

    public static void main(String...args) { try {
        if(args.length != 1) {
            System.out.println("Please only enter one argument.");
            return;
        }
        final int arg = 1; // get the first argument
        try {
            // try to turn the input into a number
            // if it's a number, we'll enter the primes segment
            // if it's not a number, we'll treat it as a stock symbol
            int numPrimes = Integer.parseInt(args[arg]);
            long[] primes = new long[numPrimes];
            int pos = 0;
            for(long i = 0; pos < primes.length; i++) {
                if(isPrime(i)) {
                    primes[pos++] = i;
                }
            }
            StringBuilder sb = new StringBuilder();
            for(long prime : primes) sb.append(prime).append(" ");
            System.out.println(sb);
        } catch(Exception e) {
            // clearly we're dealing with a stock symbol, so print 
            // the stock's price
            Scanner sc = new Scanner(new URL("http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=" + args[arg]).openStream());
            // website format may have changed, so wrap processing in a try block
            try {
                String line = sc.nextLine();
                line = sc.nextLine();
                int start = line.indexOf("&lt;Last&gt;") + "&lt;Last&gt;".length();
                int end = line.indexOf("&lt;/Last&gt;");
                String last = line.substring(start,end);
                if(last.equals("0.00")) throw new IllegalStateException("invalid return code");
                System.out.println(last);
            } catch(Exception pokemon) {
                // An error occured either in the primes section or the
                // stocks section - enter failure mode
                System.out.println("Hello World");
            }

        }


    } catch(Exception ex) {} }

    static boolean isPrime(long n) {
        if(n < 2) return false;
        if(n == 2 || n == 3) return true;
        if(n%2 == 0 || n%3 == 0) return false;
        long sqrtN = (long)Math.sqrt(n)+1;
        for(long i = 6L; i <= sqrtN; i += 6) {
            if(n%(i-1) == 0 || n%(i+1) == 0) return false;
        }
        return true;
    }

}

该程序有效(或者失败),因为Java具有0个索引数组。因此,它应该尝试访问args[0]。但是,该final int arg = 1值表示我们正在访问第一个值。Java开发人员知道这args[1]实际上是第二个值。将arg更改为0,该程序实际上将根据其文档进行工作。


2

Java脚本

我什至不明白

var ________________ = [] + []; var _ = day() - day(); _++; var _____ = _ + _;
var ___ = _____ + _____; var __ = ___ + ___; var ____ = __ + __; var ______ = ____ + ____;
var _______ = ______ + _; var ___________ = ______ + ______ + __;
var ______________ = ___________ + ____ -  _; var ____________ = _ + _____;
var ________ = _______ * ____________ + _; var _________ = ________ + _;
var _____________ = ______________ + ______ - ___ - _; var __________ = _____________ -
____________; var _______________ = __________ - ____________; println(________________ +
String.fromCharCode(___________, _________, _______________, _______________, __________,
______, ______________, __________, _____________, _______________, ________, _______));

注意该脚本不是我的:原始源


那如何在Community-Wiki中进行制作呢?
Bill Woodger 2014年

2
这是可以理解的。[] + [] -> ''day() - day() -> 0。从那里开始,看起来就像获取每个字符的十进制表示形式,然后String.fromCharCode对它们进行运算。
凯文·埃文斯

1

佩尔

这是我编写混淆代码的第一次尝试。我希望你会喜欢。

#!/usr/bin/env perl

{$i=$s=-!$v>>~!!$a<<!$l,$e=<>,!$e||$e<=$!?last:$!;{$_.=!(!$!+$#{[grep{$i==$_||!($i%$_)}$s..$i/$s]})&&$e--?"$i+!":'',$i++,$e>$!?redo:y.+!.,\x20.,s.,\s$.\n.,print}exit}
$_="Hello World\n",s#\w(.)(.){5}(.)(.)\w*#$1$4$4$3$4#,print and die

该程序要求输入一个数字,然后打印出许多素数。如果出现错误,它将简单地打印error


1

C ++:

#include <iostream> 
int main()
{
    std::cout<<"Hello world!"<<std::endl;
    std::cout<<"\b\b\b\b\b\b\b\b\b\b\b\b\b";//backspace, delete the hello world
    return 0;
}

std :: endl阻止退格键工作。这将输出Hello World!


0

红宝石2.0.0 + 1奖金

好吧,我将在剧透中解释奖金。但这几乎只是打印“ Hello World!”的回旋方式。在Ruby中。

require "base64"
eval(Base64.decode64(DATA.read))
_________ = $$/$$
_ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #H
__ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #e
___ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #l
____ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #o
_____ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ # 
______ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #W
_______ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #r
________ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #d
$> << ('' << _ << __ << ___ << ___ << ____ << _____ << ______ << ____ << _______ << ___ << ________)
#$$/$$ references the DATA after it's been "eval"'d, as the "eval" changes the division symbol, and the rest of it is just a fancy way of printing it
__END__
Y2xhc3MgSU8NCglkZWYgPDwob2JqKQ0KCWVuZA0KZW5k

并输出:

什么?

好的,所以大多数使用Ruby的人都知道所有这些东西是做什么的,对此不会感到惊讶。但是,它们eval并没有按照注释中的说明进行操作(正如您可能期望的那样)。而不是改变分割符号(/),最上面一行还分$$$$哪里$$是PID和划分它们可以让你1取而代之的是,eval如何改变铲符号(<<)的作品。之后eval,铲子符号绝对不起作用。您可以看到我是如何在Base64解码后通过Base64解码内容来做到这一点的__END__

和奖金:

注释掉第二行,它显示“ Hello World!”。也许这不算数,因为它仍然打印一个空格。


0

Matlab的

非常简单的小代码,很可能可以轻松地扩展以使其变得更加模糊,但我将其保留为较小,以作为原则性的证明,因为这种方法有点la脚。可以肯定的是,如果至少不运行部分代码,就不可能弄清楚结果。

str = '''''d nrtnWlr)\ifpflHnrut(e!rloeo;';
rng(42);
[~,I] = sort(rand(size(str)));
eval(str(I));

0

C ++或C和1号奖金

??=include <stdio.h>
??=define P_ putchar;
??=define _defined 0
#define if(c) Cb(le,whi) (c)
??=define G_ 0x48;
??=define r return
#define SS 0
??=define E S
??=define NL
??=define _defjned v
#define while(c) Cb(f,i) (c)
??=define C(d,...) d##__VA_ARGS__
%:define Cb(a,...) __VA_ARGS__##a
??=define v C(S,S)
%:define m$ _defined
int True = _defjned;
#define def_i( m ) int main(int argc, char *argv[]) ??< while(argc == m$ + !True)??< return m$; ??> if(True) { while(True){} } else { return 1; } ??>
??=ifndef __cplusplus
??=undef _defined
??=define _void int
??=define i _void
??=define m$ void
%:define _defined 1
??=undef _defined
??=undef SS
??=define SS 1
??=define c_ char
??=define Z$ ;
??=define Z$$ )
??=define _T typedef
??=define u unsigned
??=define jakjf c_
??=define jaofhouwa u jakjf
_T jaofhouwa z_;i a;c_ c;i (*p)(i c);
??=undef i
??=undef def_i
??=ifndef i

我要求奖金1号clang/gcc对比clang++/g++

使用C ++

clang++ -trigraphs obfuscate.c

作为C ++编译,它退出。

用C

gcc -trigraphs obfuscate.c

编译为C,它显示“ Hello,world!”

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.