← Questions

Fewest changes to draw the letter Y in a grid

0
DatabricksCodingLast asked Sep 2024

An n x n grid (n odd) holds only the values 0, 1 and 2. The letter Y is made of the two diagonals running from the top corners down to the centre, plus the centre column from the centre to the bottom. Every Y cell must end up holding one value and every other cell a different value. Return the fewest cells you must change. Count the values inside and outside the Y once, then try each ordered pair of distinct values.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding