Problem 190776 · medium · Phase 01 Prerequisites & Setup

Month Calendar Rows

loops · strings · formatting · arithmetic

Lay out a month as calendar rows. days is the number of days in the month and start is the weekday of the 1st (0 = Monday ... 6 = Sunday). Each row has 7 cells; every cell is 2 characters wide (day numbers right-aligned, empty cells are two spaces) and cells are joined by a single space. Finally strip trailing spaces from every row. Return the list of rows.

Examples

Input:  days = 10, start = 1
Output: ["    1  2  3  4  5  6", " 7  8  9 10"]

Input:  days = 7, start = 0
Output: [" 1  2  3  4  5  6  7"]

Constraints

  • 1 <= days <= 31, 0 <= start <= 6

Goals

  • Place items in a fixed-width grid starting at an offset
  • Cut a sequence into rows of seven and trim the last row
Starting Python…