Problem 240775 · easy · Level 02 Linear Data Structures

Ticket Numbers to Seats

py-builtins · divmod · py-join

A small theatre numbers its tickets 0, 1, 2, ... from the front-left seat: row A holds tickets 0 to width - 1 from left to right, row B the next width tickets, and so on. Seats within a row are numbered from 1.

Write seat_labels(tickets, width) that returns the seat label, such as "C7", for every ticket number in tickets, in the same order.

Examples

Input:  tickets = [0, 9, 10, 27], width = 10
Output: ["A1", "A10", "B1", "C8"]
Explanation: Ticket 27 is in row 27 // 10 = 2, which is C, at position 27 % 10 = 7, seat 8.

Input:  tickets = [5, 4], width = 1
Output: ["F1", "E1"]

Constraints

  • 0 <= len(tickets) <= 10**5, 1 <= width <= 1000
  • 0 <= tickets[i] < 26 * width (rows A to Z)

Goals

  • Split a number into a quotient and a remainder at once with `divmod`
  • Turn a number into a letter with `chr` and `ord`
  • Format each label with an f-string
Starting Python…