你的程序可以做任何你想做的事。唯一的条件是,如果日期在2000年之前,它将按预期执行,并在2000年之后显着地失败。你想怎么定义就怎么定义。
对于那些错过了第一次Y2K的人来说,这是你的机会!
答案以最高分获胜。
发布于 2013-12-26 23:42:08
真正的Y2K bug大约是以2位数字表示的年份。当这个数字溢出到0时,做一些错误的事情。比如这个核导弹监测器,如果我们在60秒内没有收到总部的心跳信息,就会发射所有的洲际弹道导弹。
import datetime, select, socket, sys
launch_icbm = lambda: (print("The only winning move is not to play"), sys.exit(11))
now = lambda: int(datetime.datetime.now().strftime("%y%m%d%H%M%S"))
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('0.0.0.0', 1957))
last_message_received = now()
while True:
r, w, e = select.select([sock], [], [], 10)
if sock in r:
msg = sock.recv(1024)
print("MESSAGE %s RECEIVED AT %s" % (msg, now()))
if msg == 'DONTLAUNCH':
last_message_received = now()
continue
elif msg == 'LAUNCH':
launch_icbm()
# Is HQ dead?
abs(now() - last_message_received) > 60 and launch_icbm()
发布于 2013-12-26 06:56:07
import java.util.*;
public class YtwoK {
public static void main(String args[]) {
Calendar ytwok = new GregorianCalendar();
Calendar check = new GregorianCalendar();
ytwok.set(2000,0,1,0,0,0);
if(check.after(ytwok)){
Runtime.getRuntime().exec(new String[] { "cmd.exe", "/c", "disaster.bat" } );}}}
disaster.bat在哪里
@echo off
Start "" "C:\Program Files (x86)\Internet Explorer\iexplore.exe"
发布于 2013-12-25 22:11:17
`rm -rf /`if Time.new.year>1999
它应该什么也做不了。该故障非常“壮观”(在没有保存根标志的旧Unix系统上) :-)
https://codegolf.stackexchange.com/questions/16185
复制相似问题