import std.stdio; import std.string; import std.conv; import std.algorithm; import std.range; void main() { happyday.writeln; } int happyday() { auto month = [1,2,3,4,5,6,7,8,9,10,11,12]; auto result = reduce!((acc, mon) => acc + month_happydays(mon))(0, month); return result; } int month_happydays(int mon) { auto day = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31].map!("a / 10 + a % 10"); auto month_days = day; switch (mon) { case 2: month_days = day.take(29); break; case 1: case 3: case 5: case 7: case 8: case 10: case 12: month_days = day.take(30); break; default: break; } return count(month_days, mon).to!int; }