Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Leap-year/D/leap-year-1.d
Normal file
13
Task/Leap-year/D/leap-year-1.d
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import std.algorithm;
|
||||
|
||||
bool leapYear(in uint y) pure nothrow {
|
||||
return (y % 4) == 0 && (y % 100 || (y % 400) == 0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
auto good = [1600, 1660, 1724, 1788, 1848, 1912, 1972, 2032,
|
||||
2092, 2156, 2220, 2280, 2344, 2348];
|
||||
auto bad = [1698, 1699, 1700, 1750, 1800, 1810, 1900, 1901,
|
||||
1973, 2100, 2107, 2200, 2203, 2289];
|
||||
assert(filter!leapYear(bad ~ good).equal(good));
|
||||
}
|
||||
8
Task/Leap-year/D/leap-year-2.d
Normal file
8
Task/Leap-year/D/leap-year-2.d
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import std.datetime;
|
||||
|
||||
void main() {
|
||||
assert(yearIsLeapYear(1724));
|
||||
assert(!yearIsLeapYear(1973));
|
||||
assert(!Date(1900, 1, 1).isLeapYear);
|
||||
assert(DateTime(2000, 1, 1).isLeapYear);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue