復活節最短原始碼比賽
create or replace package easter is
function f(y number) return varchar2;
procedure showAllEasterDay;
procedure showMaxOccurenceEasterDay;
procedure showLeapEasterDay;
procedure showFoolEasterDay;
end easter;
/
function f(y number) return varchar2;
procedure showAllEasterDay;
procedure showMaxOccurenceEasterDay;
procedure showLeapEasterDay;
procedure showFoolEasterDay;
end easter;
/
create or replace package body easter is
function f(y number) return varchar2 is
n number;
m number;
begin
n := y - 1900;
m := mod(11 * mod(n, 19) + 4 - floor((7 * mod(n, 19) + 1) / 19), 29);
return to_char(to_date('0425', 'mmdd') - m -
mod(n + floor(n / 4) + 31 - m, 7),
'mm-dd');
end;
procedure p(v varchar2) is
begin
dbms_output.put_line(v);
end;
procedure showAllEasterDay is
i number;
begin
p('YEAR DAY');
for i in 2011 .. 2099 loop
p(i || ' ' || f(i));
end loop;
end;
function q(u varchar2, v varchar2) return varchar2 is
r varchar2(200);
i number;
begin
r := '';
for x in (with q as (select d, count(*) c
from (select f(2010 + level) d
from dual
connect by level < 90)
where substr(d, 1, 2) in (u, v)
group by d)select *
from q
where c = (select max(c) from q)
order by 1) loop
i := x.c;
r := r || '/' || x.d;
end loop;
return substr(r, 2) || ' ' || i || ' ';
end;
procedure showMaxOccurenceEasterDay is
begin
p('MAXOCC MO_CNT MAXOCC_3 MO3_CNT MAXOCC_4 MO4_CNT');
p(q('03', '04') || q('03', '') || q('', '04'));
end;
procedure showLeapEasterDay is
begin
p('ABSENT_START ABSENT_END');
for x in (select min(d) s, max(d) e
from (select d, l - rownum g
from (select level l,
to_char(to_date('0321', 'mmdd') + level,
'mm-dd') d
from dual
connect by level < 36)
where d not in (select f(2010 + level)
from dual
connect by level < 90))
group by g
order by 1) loop
p(x.s || ' ' || x.e);
end loop;
end;
procedure showFoolEasterDay is
begin
p('YEAR TOTAL');
for x in (select 2010 + level y, count(*) over() d
from dual
where f(2010 + level) = '04-01'
connect by level < 90) loop
p(x.y || ' ' || x.d);
end loop;
end;
end easter;
/
function f(y number) return varchar2 is
n number;
m number;
begin
n := y - 1900;
m := mod(11 * mod(n, 19) + 4 - floor((7 * mod(n, 19) + 1) / 19), 29);
return to_char(to_date('0425', 'mmdd') - m -
mod(n + floor(n / 4) + 31 - m, 7),
'mm-dd');
end;
procedure p(v varchar2) is
begin
dbms_output.put_line(v);
end;
procedure showAllEasterDay is
i number;
begin
p('YEAR DAY');
for i in 2011 .. 2099 loop
p(i || ' ' || f(i));
end loop;
end;
function q(u varchar2, v varchar2) return varchar2 is
r varchar2(200);
i number;
begin
r := '';
for x in (with q as (select d, count(*) c
from (select f(2010 + level) d
from dual
connect by level < 90)
where substr(d, 1, 2) in (u, v)
group by d)select *
from q
where c = (select max(c) from q)
order by 1) loop
i := x.c;
r := r || '/' || x.d;
end loop;
return substr(r, 2) || ' ' || i || ' ';
end;
procedure showMaxOccurenceEasterDay is
begin
p('MAXOCC MO_CNT MAXOCC_3 MO3_CNT MAXOCC_4 MO4_CNT');
p(q('03', '04') || q('03', '') || q('', '04'));
end;
procedure showLeapEasterDay is
begin
p('ABSENT_START ABSENT_END');
for x in (select min(d) s, max(d) e
from (select d, l - rownum g
from (select level l,
to_char(to_date('0321', 'mmdd') + level,
'mm-dd') d
from dual
connect by level < 36)
where d not in (select f(2010 + level)
from dual
connect by level < 90))
group by g
order by 1) loop
p(x.s || ' ' || x.e);
end loop;
end;
procedure showFoolEasterDay is
begin
p('YEAR TOTAL');
for x in (select 2010 + level y, count(*) over() d
from dual
where f(2010 + level) = '04-01'
connect by level < 90) loop
p(x.y || ' ' || x.d);
end loop;
end;
end easter;
/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/81227/viewspace-693627/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 復活賽
- 打贏復活賽,我活過來了
- 微信活碼系統程式原始碼原始碼
- 復活
- NRF:2023年美國人復活節支出240 億美元
- NRF:2022年美國復活節支出達208億美元
- 《超級馬里奧大逃殺》被玩家復活 原始碼公開隨便玩原始碼
- HAVE FUN | 原始碼解析活動進展原始碼
- 比賽vp
- 近期比賽
- thinkphp微信商城原始碼年終活動PHP原始碼
- 百戰沙場,動感地帶5G電競大賽新疆賽區復活賽開啟突圍之路
- UnderScore原始碼看防抖和節流原始碼
- 【筆記】jQuery原始碼(節點遍歷)筆記jQuery原始碼
- 歷時 37 年,Windows 1.0 復活節彩蛋終於曝光:主角竟是“G 胖”!Windows
- Android熱修復原理(一)熱修復框架對比和程式碼修復Android框架
- xView2 比賽冠軍程式碼解讀View
- 原始碼分析:Phaser 之更靈活的同步屏障原始碼
- CCF NLP比賽
- Java HashMap和Go map原始碼對比JavaHashMapGo原始碼
- curl 作者表示永遠不會在軟體中嵌入復活節彩蛋:boring is goodGo
- 原始碼閱讀之LinkedList實現細節原始碼
- 原始碼閱讀之ArrayList實現細節原始碼
- MapReduce —— MapTask階段原始碼分析(Input環節)APT原始碼
- MapReduce —— MapTask階段原始碼分析(Output環節)APT原始碼
- 死磕hyperledger fabric原始碼|Order節點概述原始碼
- redux真的不復雜——原始碼解讀Redux原始碼
- 教師節活動來啦!
- 剝開比原看程式碼04:如何連上一個比原節點
- 高二前復活感想
- AI時代RSS復活?AI
- yum安裝與原始碼安裝比較原始碼
- WordPress柒比貳B2模板原始碼原始碼
- 猿人學web端爬蟲攻防大賽賽題第1題——js 混淆 - 原始碼亂碼Web爬蟲JS原始碼
- 最近比賽的wp
- 20240405比賽總結
- 比賽小技巧(1)
- 20240502比賽總結
- 20241020比賽總結