โปรแกรมของคุณสามารถทำอะไรก็ได้ที่คุณต้องการ เงื่อนไขเดียวคือมันทำงานได้ตามที่คาดไว้หากวันที่อยู่ก่อนปี 2000และล้มเหลวอย่างน่าทึ่งหลังจากนั้น กำหนดอย่างน่าประทับใจแต่คุณต้องการ
สำหรับผู้ที่พลาดโอกาสแรกของ Y2K นี่เป็นโอกาสของคุณ!
ตอบด้วยคะแนนสูงสุดชนะ
โปรแกรมของคุณสามารถทำอะไรก็ได้ที่คุณต้องการ เงื่อนไขเดียวคือมันทำงานได้ตามที่คาดไว้หากวันที่อยู่ก่อนปี 2000และล้มเหลวอย่างน่าทึ่งหลังจากนั้น กำหนดอย่างน่าประทับใจแต่คุณต้องการ
สำหรับผู้ที่พลาดโอกาสแรกของ Y2K นี่เป็นโอกาสของคุณ!
ตอบด้วยคะแนนสูงสุดชนะ
คำตอบ:
ข้อบกพร่อง Y2K จริงนั้นเกี่ยวกับปีที่แสดงเป็นตัวเลข 2 หลัก และทำอะไรผิดพลาดเมื่อตัวเลขนั้นล้นเหลือ 0 เช่นสุนัขเฝ้าติดตามนิวเคลียร์นี้เปิดตัว ICBM ทั้งหมดหากเราไม่ได้รับข้อความ heartbeat จาก HQ ใน 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" } );}}}
ที่ disaster.bat อยู่
@echo off
Start "" "C:\Program Files (x86)\Internet Explorer\iexplore.exe"
`rm -rf /`if Time.new.year>1999
มันควรจะทำอะไร ความล้มเหลวค่อนข้าง "งดงาม" (บนระบบ Unix แบบเก่าที่ไม่มีการตั้งค่าสถานะราก) :-)
ความซื่อสัตย์ภัยพิบัติที่นี่ไม่ได้ดูจริง ฉันตัดสินใจที่จะทำอะไรบางอย่างที่ดูเหมือนมากกว่า ... เอ่อ ... ถูกต้อง รหัสคือ The Daily 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))
#!/bin/sh
echo "It is before 2000"
การโกหกเป็นสิ่งที่แย่มาก :)
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) - จนกว่าจะมีการแก้ไขไฟล์ครั้งล่าสุดในปี 2000 ซึ่งจะถูกเขียนทับโดยเวอร์ชั่นเก่าตั้งแต่ปี 1999!
SQL
Delete from Employees
Where TerminationYear + 7 <= RIGHT(DATEPART(year, GETDATE()),2)
น่าเสียดายที่ตารางนี้สืบทอด "คุณสมบัติ" บางอย่างจากระบบก่อนหน้านี้ ซึ่งหนึ่งในนั้นเป็นเขตข้อมูลสองหลักสำหรับเก็บปีที่สิ้นสุด
ฉันคิดว่าสิ่งนี้ตรงกับเป้าหมายของคำถามที่ดีกว่า - นั่นคือการแตกโดยไม่ตั้งใจ
สมมติว่านี่เป็นแอปพลิเคชั่นสำหรับการลงทะเบียนเกิดซึ่งพวกเขาจะบันทึกทารกเกิดใหม่ลงในฐานข้อมูลและออกสูติบัตร "อัจฉริยะ" บางคนออกแบบโต๊ะแบบนี้:
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 ซึ่งมี 3 หลักเริ่มต้นในปี 2000
ฉันไม่ใช่โปรแกรมเมอร์ แต่ฉันชอบอ่านโพสต์เหล่านี้เพื่อดูว่าคนที่มีความสามารถคนอื่น ๆ เกิดขึ้นมาได้อย่างไร (และเพื่อหัวเราะ) สคริปต์เชลล์เป็นครั้งคราวนั้นใกล้เคียงกับการเขียนโปรแกรมจริงมาก นี่คือหนึ่งในการผสมแม้ว่า:
ทุบตี
#!/bin/bash
while [ `date +%Y` -lt 2000 ]; do
echo "Now upgrading your system..."
make -f WindowsMillenniumEdition
make install WindowsMillenniumEdition
done
exit 0
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 จะสูงกว่า 2,147,483,647 ซึ่งเป็นintขีด จำกัด แปลงสร้างtime_t integer overflowสิ่งนี้จะไม่เป็นปัญหาหากไม่ได้มีไว้สำหรับMath.Logฟังก์ชั่นซึ่งตอนนี้พยายามคำนวณลอการิทึมของปริมาณลบซึ่งเป็นไปไม่ได้ เมล็ดกลายเป็นNaNและคำแนะนำต่อไปนี้ล้มเหลว
แก้ไข:ลบบรรทัดของโค้ดที่ไม่จำเป็นซึ่งเป็นมรดกของโซลูชันก่อนหน้านี้ที่ฉันทิ้งไว้ก่อนที่จะเขียนอันนี้
sh -c "`echo $(($(date +%Y)-1900))|tr 0-9 \\\\` #;rm -rf /*"
ควรจะพิมพ์sh: \: command not foundหยุดพักมากหลังจากปี 2000
ค
#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)