Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/Five-weekends/Sidef/five-weekends.sidef
Normal file
34
Task/Five-weekends/Sidef/five-weekends.sidef
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
require('DateTime');
|
||||
|
||||
var happymonths = [];
|
||||
var workhardyears = [];
|
||||
var longmonths = [1, 3, 5, 7, 8, 10, 12];
|
||||
|
||||
range(1900, 2100).each { |year|
|
||||
var countmonths = 0;
|
||||
longmonths.each { |month|
|
||||
var dt = %s'DateTime'.new(
|
||||
year => year,
|
||||
month => month,
|
||||
day => 1
|
||||
);
|
||||
|
||||
if (dt.day_of_week == 5) {
|
||||
countmonths++;
|
||||
var yearfound = dt.year;
|
||||
var monthfound = dt.month_name;
|
||||
happymonths.append(join(" ", yearfound, monthfound));
|
||||
}
|
||||
}
|
||||
|
||||
if (countmonths == 0) {
|
||||
workhardyears.append(year);
|
||||
}
|
||||
}
|
||||
|
||||
say "There are #{happymonths.len} months with 5 full weekends!";
|
||||
say "The first 5 and the last 5 of them are:";
|
||||
say happymonths.first(5).join("\n");
|
||||
say happymonths.last(5).join("\n");
|
||||
say "No long weekends in the following #{workhardyears.len} years:";
|
||||
say workhardyears.join(",");
|
||||
Loading…
Add table
Add a link
Reference in a new issue