一道简单的题目,如何“出人意料”地打印hello world,比如说用更机器native的方式。语言无所谓,也无所谓代码长短。
我自己想到的一种:
# Python
ls = [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
s = ''.join(map(lambda x: chr(x), ls))
print(s)
一道简单的题目,如何“出人意料”地打印hello world,比如说用更机器native的方式。语言无所谓,也无所谓代码长短。
我自己想到的一种:
# Python
ls = [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
s = ''.join(map(lambda x: chr(x), ls))
print(s)
javascript:
゚ω゚ノ= /`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) +(o^_^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^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (゚Θ゚)+ (゚Д゚)[゚o゚]) (゚Θ゚)) ('_');
我大php也来凑个热闹:
<?php
@define(_,'chr(');
@define(__,').');
@define(___,"print ");
@define(____,"'!';");
@define(_____,_."0x48".__._."0x65".__._."0x6C".__._."0x6C".__);
@define(______,_."0x6F".__._."0x20".__._."0x77".__._."0x6F".__);
@define(_______,_."0x72".__._."0x6C".__._."0x64".__);
@define(________,_____.______._______);
@define(_________,___.________.____);
eval(_________);
# Python3
ls = [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
print(bytes(ls))
#b'hello world'
Java
import java.util.Random;
public class HelloWorld {
public static void main(String ... args) {
System.out.println(randomString(-229985452)+' '+randomString(-147909649));
}
public static String randomString(int seed) {
Random rand = new Random(seed);
StringBuilder sb = new StringBuilder();
while(true) {
int n = rand.nextInt(27);
if (n == 0) break;
sb.append((char) ('`' + n));
}
return sb.toString();
}
}
public static void main(String[] args) throws InterruptedException {
for (int i = 1; i <= 7; i++) {
Thread.sleep(86400000);
System.out.println("周" + i + ":" + "好吓人的:hello,world");
}
}
你若能等全部结果打完,我服。
brainf**k
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++
..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
//Java
for(int i=10;i>0;i--){
System.out.println("让你大吃一惊 "+(i)+".....");
TimeUnit.SECONDS.sleep(1);
}
System.out.println("Hello world!");
我再正经来一个 之前自己写的加密算法正好拿来用一下
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
/**
* Created by DCJS
* 把所有字符转成digits代表的32进制
* 2016/11/17.
*/
public class AllToAZ {
private static char[] digits = {
'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l',
'm', 'n', 'o', 'p',
'q', 'r', 's', 't',
'u', 'v', 'w', 'x',
'y', 'z', 'A', 'B',
'C', 'D', 'E', 'F'
};
public static String parseToAZStr(String str) {
if (!Strings.isNullOrEmpty(str)) {
StringBuilder result = new StringBuilder();
int index = 0;
for (int c : str.toCharArray()) {
result.append("_").append(toUnsignedString(c));
}
return result.toString();
}
return null;
}
public static String formatAZToStr(String str) {
StringBuilder result = new StringBuilder();
if (!Strings.isNullOrEmpty(str)) {
for (String s : Splitter.on("_").omitEmptyStrings().split(str)) {
int charNum = 0;
int max = s.toCharArray().length;
for (char c : s.toCharArray()) {
int currentNum = indexOf(c);
for (int time = 0; time < max - 1; time++) {
currentNum = currentNum << 5;
}
charNum += currentNum;
max--;
}
result.append((char) charNum);
}
}
return result.toString();
}
private static int indexOf(char c) {
int index = 0;
for (char d : digits) {
if (c == d) {
return index;
}
index++;
}
return 0;
}
public static void main(String[] args) {
System.out.println(formatAZToStr("_ci_df_dm_dm_dp_ba_cx_dp_ds_dm_de"));
}
private static String toUnsignedString(int i) {
int shift = 5;
char[] buf = new char[32];
int charPos = 32;
int radix = 1 << shift;
int mask = radix - 1;
do {
buf[--charPos] = digits[i & mask];
i >>>= shift;
} while (i != 0);
return new String(buf, charPos, (32 - charPos));
}
}
8 回答4.6k 阅读✓ 已解决
3 回答2.6k 阅读✓ 已解决
6 回答3.3k 阅读✓ 已解决
3 回答4.1k 阅读✓ 已解决
5 回答2.8k 阅读✓ 已解决
5 回答6.3k 阅读✓ 已解决
3 回答3.1k 阅读✓ 已解决
javascript:
方案一:
方案二:
方案三: