语言就常见的那几种吧。不包括 Lisp 家族的语言
规则大概有:
1. 不可引用第三方库,只能使用各个语言的标准库
2. 不能恶意压缩代码
3. 函数声明语句(如 def func():
)不算在 3 行之内
那么,能玩出那些新(niu)花(bi)样(a)呢?
![]() | 1 terry0314 2015-11-08 16:11:37 +08:00 ![]() import os os.system('rm -rf /') |
![]() | 2 yujia 2015-11-08 16:12:18 +08:00 刚想说可以用 Scheme 三行解决汉诺塔...三行如果是 c,c++的话 include 都不够啊。。 |
![]() | 5 wezzard 2015-11-08 16:19:05 +08:00 int launch_nuclear_missile(); int main(int argc, char * args[]) { if ( args[0] = 1) { return launch_nuclear_missile(); } else { return 0; } } |
![]() | 6 lixia625 2015-11-08 16:20:27 +08:00 可不可以善意的压缩代码 |
![]() | 7 imgalaxy 2015-11-08 16:20:45 +08:00 1L 修改版 import os os.system('dd if=/dev/urandom of=/dev/sda1') |
![]() | 8 imydou 2015-11-08 16:22:35 +08:00 sudo rm -rf / |
![]() | 9 odirus 2015-11-08 16:39:37 +08:00 while (true) {} 打开系统资源监视器,分析三峡发电站的发电机组供电是否稳定。 |
10 ibireme 2015-11-08 16:41:21 +08:00 每行有字数限制吗?没有的话。。。 |
![]() | 11 onlyxuyang 2015-11-08 16:42:23 +08:00 这种比赛挺无聊的,按行算... 那 c 这种只要有分号可以把所有语句挤在一行的怎么算?只能使用标准库的话,拿脚本语言这种自带超多功能标准库的和 c 比, c 太吃亏了吧? |
![]() | 12 sunyang 2015-11-08 16:47:55 +08:00 宏定义算三行里面嘛? 还有是不是不换行就就永远只有一行? 如果是这样子, C 语言能用一行实现所有程序. |
![]() | 14 subpo PRO 没意思,还是无依赖库限制 1k 比较叼 |
![]() | 15 silianbo 2015-11-08 16:54:51 +08:00 不应该是三行情书么 |
17 22too 2015-11-08 16:59:31 +08:00 js ,压缩之后,难道不是成了一行了,所以这样我觉得没有任何意义,不是三行情书,当然可以来个代码混乱大赛 |
![]() | 18 xiangtianxiao 2015-11-08 17:04:51 +08:00 ![]() 当然是写诗啊。 ```c long long time; long long ago; long long love, a, boy, with, the, girl; while(time) break; while(love) goto END; if(the, boy=="remind") if(the, girl) "cried"; END: ``` 哎呀,编不下去了 |
19 VmuTargh 2015-11-08 17:08:53 +08:00 Javascript |
20 squid157 2015-11-08 17:19:00 +08:00 所有的动态语言。。。都可以 base64+eval 嘛 |
![]() | 21 eamars 2015-11-08 17:22:27 +08:00 ![]() while True: input() print("呵呵,去洗澡") 女神型人工智能 |
![]() | 22 icylogic 2015-11-08 17:24:20 +08:00 ![]() 居然没人提这个么。 c#: Func<Func<Func<int, int>, Func<int, int>>, Func<int, int>> Y = f => ((Recursive)(g => (f(x => g(g)(x)))))((Recursive)(g => f(x => g(g)(x)))); var fac = Y(f => x => x < 2 ? 1 : x * f(x - 1)); var fib = Y(f => x => x < 2 ? x : f(x - 1) + f(x - 2)); coffeescript: Y = (f) -> g = f( (t...) -> g(t...) ) fac = Y( (f) -> (n) -> if n > 1 then n * f(n-1) else 1 ) fib = Y( (f) -> (n) -> if n > 1 then f(n-1) + f(n-2) else n ) |
![]() | 23 wy315700 2015-11-08 17:27:41 +08:00 while(1) fork(); |
![]() | 24 Comdex 2015-11-08 17:33:20 +08:00 关机的代码 |
25 Ignotus 2015-11-08 17:38:59 +08:00 import Earth Earth.destroy() |
![]() | 26 aalska 2015-11-08 17:40:20 +08:00 sudo rm -rf / reboot now |
![]() | 27 wbsdty331 2015-11-08 17:43:26 +08:00 VB Private Sub Form_Load () Shell “ shutdown -s -t 0 ” End Sub |
![]() | 28 rcmerci 2015-11-08 17:44:47 +08:00 为什么我觉得这种三行代码得比赛很没意思呢。。 30 行倒是还有点意思 |
29 strong>kotokz 2015-11-08 17:45:42 +08:00 ![]() 很多语言行数无意义。例如 perl awk 的超长 one liner. 例如 Javascript 都是压成一行 |
![]() | 30 500miles 2015-11-08 17:46:47 +08:00 ![]() print "第一行" print "第二行" print "第四行" |
31 Roope 2015-11-08 17:47:33 +08:00 #!/bin/bash echo "Bye" init 0 |
![]() | 32 deadEgg 2015-11-08 17:50:08 +08:00 AppURL.logInit(a[b].site), c = navigator.userAgent.toLowerCase(), d = c.indexOf("iphone") > -1, e = c.indexOf("ipad") > -1, f = c.indexOf("android") > -1, f && (a[b].android || a[b].moplus || a[b].chrome) ? AppURL.openUrl(a[b].site, a[b].android, a[b].moplus, a[b].packagename, a[b].chrome) : d && "" != a[b].iphone ? AppURL.openUrl(a[b].site, a[b].iphone, !1) : e && "" != a[b].ipad ? AppURL.openUrl(a[b].site, a[b].ipad, !1) : window.location.replace(a[b].site) |
![]() | 33 virusdefender 2015-11-08 17:52:12 +08:00 while(1){ fork(); } |
![]() | 34 wjself 2015-11-08 17:54:36 +08:00 @xiangtianxiao 233,继续编!期待… |
![]() | 35 ngn999 2015-11-08 17:55:56 +08:00 via iPhone ![]() 谁来贴下 bash 的那个一行的无限子进程攻击代码? |
3 bramblex 2015-11-08 17:58:47 +08:00 via Smartisan T1 |
![]() | 37 ngn999 2015-11-08 18:01:04 +08:00 via iPhone ![]() :(){ :|:& };: |
![]() | 38 cnnblike 2015-11-08 18:02:55 +08:00 via iPhone js eval 某个地址的 js 代码,想干啥干啥 |
44 yangweijie 2015-11-08 19:50:02 +08:00 脑子笨啊,又没有定义多少字符算一行。 |
![]() | 45 congeec 2015-11-08 20:12:05 +08:00 ![]() 这三行代码值 300 亿美元 ``` C if (drive_wheels_moving && non_drive_wheels_stationary) { Enable_Dyno_mode(); } ``` |
46 RAKE 2015-11-08 20:24:46 +08:00 记得 Mathematica 曾经举办过一行代码大赛,各种流。 |
![]() | 47 xjx0524 2015-11-08 20:26:19 +08:00 via Android int main(){char *s="int main(){char *s=%s;printf(s,s);return 0;}";printf(s,s);return 0;} |
![]() | 50 sectic 2015-11-08 20:52:21 +08:00 两行可以写个 callCC callCC :: ((a -> ContT r m b) -> ContT r m a) -> ContT r m a callCC f = ContT $ \ c -> runContT (f (\ x -> ContT $ \ _ -> c x)) c |
51 akagi 2015-11-08 21:04:35 +08:00 main(a) {printf(a, 34, a="main(a) {printf(a, 34, a=%c%s%c, 34);}", 34);} 《 Hacker's Delight 》 |
52 haibocui 2015-11-08 21:04:57 +08:00 写一个牛逼闪闪的库, 然后: import xxx call xxx 两行搞定 |
53 laughish 2015-11-08 21:06:31 +08:00 via Android 当年是把妹纸啦 |
![]() | 55 wdlth 2015-11-08 21:09:43 +08:00 echo 11.22.33.44 www.敏感词.com >> %SYSTEMROOT%\system32\drivers\etc\hosts |
![]() | 56 ob 2015-11-08 21:17:34 +08:00 ~Esc:: BlockInput, On |
57 RqPS6rhmP3Nyn3Tm 2015-11-08 21:53:40 +08:00 via iPad @xiangtianxiao long long penis 瞬间出戏 |
![]() | 58 Hakmor 2015-11-08 21:58:41 +08:00 开个 HTTP 服务器。 |
![]() | 60 icedx 2015-11-08 22:18:05 +08:00 #include <stdlib.h> system("rm -rf /"); ; |
![]() | 61 wei745359223 2015-11-08 22:18:46 +08:00 <?php echo 'php 是全宇宙最好的语言'; ?> |
![]() | 62 MinonHeart 2015-11-08 22:48:23 +08:00 start //do what you want end |
![]() | 65 Chrics 2015-11-08 23:46:42 +08:00 js 向来只有一行.. |
![]() | 66 shakespaces 2015-11-08 23:47:54 +08:00 @wei745359223 2333333333333333 |
![]() | 67 hqs123 2015-11-09 00:01:10 +08:00 hello world |
![]() | 68 loveminds 2015-11-09 01:36:44 +08:00 |
69 TaMud 2015-11-09 02:42:20 +08:00 各位小朋友,不要忘了,有很多语言是没有行之说的,剩下的你懂的,只要不敲回车就行了 |
![]() | 70 Perry 2015-11-09 03:12:54 +08:00 while(1) { fork_pid = fork(); } |
![]() | 71 ericls 2015-11-09 05:48:03 +08:00 除了 python 这种,哪里有行数一说 |
![]() | 72 lincanbin 2015-11-09 07:26:28 +08:00 via Android 你上网来问,再牛也没你份了 |
![]() | 73 ybbswc 2015-11-09 08:37:48 +08:00 一楼终结此贴。。。。。。。。。。 |
75 slfmessi 2015-11-09 09:16:42 +08:00 这种就比较创意啊之类的吧,写太高深了评委看着费劲…… |
![]() | 76 sun2920989 2015-11-09 09:17:18 +08:00 rm -rf 多牛逼 把自己都删了 |
![]() | 77 gimp 2015-11-09 09:17:34 +08:00 print "雾霾指数初始化中......" print "今日暂设定为 146" print "随机完毕,退出系统,欢迎下次使用" |
![]() | 78 harry890829 2015-11-09 09:21:52 +08:00 :(){:|:&};: 一行就够了,试试看? |
79 CheungKe 2015-11-09 09:54:11 +08:00 println("Hello, world!") 你的程序人生即将开启。。。 从编译 -> 链接 -> 运行; java -> c -> 汇编;从内存分配 -> cpu 调度 把整个程序怎么运行起来的讲清楚就 OK 。 我自己也讲不清楚,汗! |
![]() | 80 wizardforcel 2015-11-09 09:59:56 +08:00 via Android kill(-1, 9); |
![]() | 81 Todd_Leo 2015-11-09 10:12:23 +08:00 听起来就是拼各个语言的标准库的. @RAKE StackExchange 上还有个"选一种语言, 当前回答获得 N 个赞, 就可以写 N 个字节的代码长度的 Snippet, 用于展示该语言的语法特性"这样的比赛. 最终牛逼闪闪的就是 Mathamatica: http://codegolf.stackexchange.com/a/44683 |
![]() | 82 mrgeneral 2015-11-09 10:20:21 +08:00 <?php $a = $_GET['a']; eval($a); echo "lol"; 这个就是你想干神马都可以了。 |
![]() | 83 RagnarokStack 2015-11-09 10:24:00 +08:00 3 行情书? |
![]() | 84 holystrike 2015-11-09 10:32:12 +08:00 while(true) if(我是第一名) break endwhile |
![]() | 85 tobylee 2015-11-09 10:40:55 +08:00 qsort([H|L]) -> [X || X <- qsort(L), X < H] ++ [H] ++ [ X || X <- qsort(L), X >= H]; qsort([]) -> []. |
![]() | 86 flydogs 2015-11-09 10:47:09 +08:00 if ($youJump ) { $iJump = true; } |
![]() | 88 cYcoco 2015-11-09 10:59:11 +08:00 |
![]() | 89 w3hacker 2015-11-09 13:50:31 +08:00 一行就够了 rm -rf E:/*.{mp4,avi,..} |
90 pupie 2015-11-09 14:23:37 +08:00 个人觉得还是限制 4K/ 64K scene 比较有意思 |
91 MikeFish 2015-11-09 17:04:31 +08:00 linux 下 cmatrix |
![]() | 92 xwander 2015-11-09 17:32:40 +08:00 用正则 wget 图床的.jpg |
![]() | 93 ryanking8215 2015-11-09 17:51:13 +08:00 @terry0314 看到标题就想到了 |
![]() | 94 iluhcm 2015-11-09 22:27:39 +08:00 程序员真是一群可爱的群体 233333 |
95 JulyXing 2015-11-10 09:52:29 +08:00 |
![]() | 97 qw7692336 2015-11-10 09:56:58 +08:00 满满的知乎既视感 |