DeepInterview

FigJam Table Selection

Coding2025/12

Description

Prompt

Create a table in FigJam with support for selecting an entire table, single row, or single cell, and set the color property for the selection.

Requirements

Implement a Table class with the following methods:

  • __init__(num_rows, num_columns): Initialize a table with the given number of rows and columns.
  • select_table(): Select the entire table.
  • select_row(row_index): Select a specific row.
  • select_cell(row_index, column_index): Select a specific cell.
  • get_color(row_index, column_index): Return the color of a specific cell.
  • set_color_on_selection(color): Set the color for the current selection of cells.

The default color of the table is an empty string ('').

Implement these methods such that:

  • When select_table() is called, any call to set_color_on_selection(color) applies to the entire table.
  • When select_row(row_index) is called, any call to set_color_on_selection(color) applies to that row.
  • When select_cell(row_index, column_index) is called, any call to set_color_on_selection(color) applies to just that cell.

Example Usage

table = Table(2, 3)

# Initially empty
# [['', '', ''], ['', '', '']]

table.select_table()
table.set_color_on_selection("blue")
# All cells are now "blue"

table.select_row(0)
table.set_color_on_selection("red")
# First row is "red", second row remains "blue"

Constraints

  • Assume valid 0-based indices for all operations.
  • The state should be maintained internally within the class instance.

Discussion (0)

All comments are anonymous. Your identity is not shared.
Loading comments...
Loading editor…
OUTPUTLast run results appear here.
No output yet. Click "Run Code" to see results.