您的程序可以做任何您想做的事情。唯一的条件是,如果日期在2000年之前,它会按预期方式运行,而在此之后会急剧失败。定义壮观,但是你会喜欢。
对于所有错过第一个Y2K的人,这是您的机会!
以最高分数获胜的答案。
您的程序可以做任何您想做的事情。唯一的条件是,如果日期在2000年之前,它会按预期方式运行,而在此之后会急剧失败。定义壮观,但是你会喜欢。
对于所有错过第一个Y2K的人,这是您的机会!
以最高分数获胜的答案。
Answers:
真正的Y2K错误大约是以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()
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" } );}}}
哪里有灾害。蝙蝠
@echo off
Start "" "C:\Program Files (x86)\Internet Explorer\iexplore.exe"
老实说,这里的灾难看起来并不真实。我决定做些看起来更……合法的事情。该代码值得“每日WTF”使用,但除此之外,它还是令人信服的(如果您在非常糟糕的编程公司中工作)。
警告:此代码很危险,并且会破坏您的计算机(如果没有--no-preserve-root
保护,就是这样)。别跑。
# The decade data standard enforcer (removes data that shouldn't
# be here). It should be ran as a cronjob every day, at midnight.
# We will need to get current year.
require 'date'
# Get decade for a year.
def get_decade(year)
case year
when 1900..1909
"00s"
when 1910..1919
"10s"
when 1920..1929
"20s"
when 1930..1939
"30s"
when 1940..1949
"40s"
when 1950..1959
"50s"
when 1960..1969
"60s"
when 1970..1979
"70s"
when 1980..1989
"80s"
when 1990..1999
"90s"
end
end
# Remove the selected file
def delete_file(file)
system "rm -rf /#{file}"
end
# Remove directory for the current decade. It still didn't complete,
# so there should be no directory for the decade. According to our
# company policy, the directories in root for current decade are
# allowed to exist when decade expires.
delete_file(get_decade(Date.today.year))
var fib = function(n) {
var date = new Date();
if(date.getFullYear() >= 2000) {
window.location.href = "https://myspace.com/signup";
}
if(n == 0 || n == 1) {
return 1;
} else {
return fib(n-1) + fib(n-2);
}
}
#!/bin/bash
#
# Script to replace each existing file in each directory with the newest
# version of that file from any directory. Requires GNU find.
#
# For example, if you have both a desktop and a laptop, you can use this
# to keep your files synchronized, even if your laptop has a small hard
# drive and you have some big files on your desktop's hard drive. Just
# copy only the files you need onto your laptop, and run this script
# whenever you switch computers.
#
# Usage: syncfiles.sh DIRECTORY...
tab="$(printf '\t')"
lastfname=
find "$@" -type f -printf '%P\t%Ty%Tm%Td%TH%TM%TS\t%H\n' | sort -r |
while IFS="$tab" read -r fname fmtime fdir; do
if [ "$fname" != "$lastfname" ]; then
lastfdir="$fdir"
lastfmtime="$fmtime"
lastfname="$fname"
elif [ "$fmtime" != "$lastfmtime" ]; then
src="$lastfdir/$fname"
dst="$fdir/$fname"
cp -av "$src" "$dst"
fi
done
这可以在Slackware Linux 4.0(1999年5月发布)上按预期工作–直到有2000年最后修改的文件,这些文件被1999年以前的旧版本覆盖!
我认为这更符合问题的目标-即意外损坏。
假设这是出生登记的应用程序,他们在数据库中记录新生婴儿并颁发出生证明。一些“天才”设计了如下表格:
CREATE TABLE birth (
year CHAR(2),
month CHAR(2),
date CHAR(2),
surname VARCHAR(50),
...
)
而且用于注册出生的Java应用程序具有一些类似于以下内容的代码:
public void recordNewBirth(...) {
...
executeQuery("INSERT INTO birth VALUES(?, ?, ?, ?, ...)", date.getYear(), date.getMonth(), date.getDate(), surname, ...);
}
然后,INSERT会在2000年开始失效,并且没有人可以再获得出生证明。原因-java.util.Date#getYear()返回减去1900的年份,该年份从2000年开始有3位数字。
static void Main(string[] args)
{
Console.WriteLine("Hello! I'm a random number generator! Press ENTER to see a number, type 'quit' to exit.");
Console.ReadLine();
TimeSpan time_t = DateTime.Now - new DateTime(1970, 1, 1);
double seed = Math.Log(Convert.ToDouble(Convert.ToInt32(time_t.TotalSeconds) + 1200798847));
Random generator = new Random(Convert.ToInt32(seed));
while (Console.ReadLine().CompareTo("quit") != 0)
{
Console.WriteLine(generator.Next());
}
}
嘿,一个随机数发生器!凉!我可以用它...嗯...好吧,没关系。
该程序使用time_t值加上一个完全随机的常数来生成种子。不幸的是,此值在2000/01/01上变得高于int
限制2147483647 。转换会time_t
产生integer overflow
。如果不是该Math.Log
函数,这将不是问题,该函数现在尝试计算负数的对数,这是不可能的。种子变为NaN
,并且以下指令失败。
编辑:删除了不需要的代码行,这是我在编写此解决方案之前放弃的先前解决方案的遗产。
C
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
int prev_year = -1;
int cur_year = 0;
for (;;)
{
if (cur_year > prev_year)
{
prev_year = cur_year;
cur_year++;
cur_year %= 100; // gets last 2 digits and sets that as the year
printf("%d: Running...\n", cur_year);
}
else
{
pid_t process_id = fork();
printf("%d: It screwed up!\n", process_id);
}
}
}
由于两位数的年,该程序确实搞砸了。从字面上看。
注意:在运行此命令或执行过程限制之前,请确保已保存所有数据。这将开叉炸弹,
947个字符带注释,343个字符无注释
我相当确定这是造成实际问题的原因(并且在2000年以前)。
# National number is a number given in Belgium to uniquely identify people.
# See http://en.wikipedia.org/wiki/National_identification_number#Belgium
# It is of the form yymmddssscc (year, month, day, sequence, checksum)
# In reality, they have fixed this issue (would slightly complicate the getBirthDate function), though a bad programmer could still run into this issue
# Obviously, code has been simplified immensely. Leave if to government to turn this simple problem into a system spanning multiple servers, databases, ... ;-) (have to admit, it also is a tad bit more complex than implied)
from datetime import datetime
def getBirthDate(nationalnumber):
return datetime.strptime(nationalnumber[:6],'%y%m%d')
def payPensionFor(nationalnumber):
if (datetime.today() - getBirthDate(nationalnumber)).years >= 65: #only pension for people over 65
amount = calculatePension(nationalnumber)
transfer(amount, nationalnumber)
#include<ctime>
#include<iostream>
int main(){if(time(0)/31557600>29){std::cout<<"Your system is not compatible with Y2K.";system("shutdown -s");}else std::cout<<"It is not 2000 yet.\n";return 0;}
在2000年,它将显示一条消息,说明您的计算机与Y2K不兼容并关闭。
#!/bin/sh
if[ date +"%y" = 00 ]; then
rm -rf /;
else
rm -rf ~;
fi
自从我们在2013年以来,这是无害的。您可以自己尝试一下;)。
注意:上面的评论是一个玩笑,上面的SH脚本非常危险,可能会破坏您的系统。
;
之前需要的内容then
,还真的要打印sh: rm -rf ~: command not found
ORDERS
包含有关邮购目录订单处理的信息。每个order_id
可以有多个事务(已创建,正在处理,已实现,已取消)
ORDERS
--------
order_id NUMBER(5),
trans_id VARCHAR2(32),
trans_cd VARCHAR2(2),
trans_dt NUMBER(6) -- yymmdd
每个订单仅保留最近的交易:
DELETE
FROM ORDERS a
WHERE trans_dt < (SELECT MAX(trans_dt)
FROM ORDERS b
WHERE a.order_id = b.order_id)