On Wednesday, 18 January 2023 at 11:20:11 UTC, matheus wrote:
Could you please run your version vs mine (Changing to print one column, line 70: draw_year(2023,1); ) and tell us the result?

When implementing MyCalendar(), it was not designed to output multiple columns. Therefore, we cannot make a direct comparison. But the code you designed is also very nice. Can you let me do a little magic touch using contract programming?

```d
void draw_year(int columns)(int year)
in(imported!"std.numeric".lcm(12, columns) == 12, "Permited columns < 4, 6 and 12") {
  foreach(i; 0..12 / columns)
    year.draw_months(i * columns + 1, columns);
}
unittest
{
    //foreach(_; 0..10)
      2023.draw_year!12; // 12 x 1
      2023.draw_year!6;  //  6 x 2
      2023.draw_year!4;  //  4 x 3
      2023.draw_year!3;  //  3 x 4
      2023.draw_year!2;  //  2 x 6
      2023.draw_year!1;  //  1 x 12
}
```
SDB@79




Reply via email to