The TransCompilator

Solved LeetCode program · 410 of 1,000

#0554 · Brick Wall

Medium Array chunk-09.md

Original English source

The bricks is a list of 1, 2, 2, 1, 3, 1, 2, 1, 3, 2, 2, 4, 3, 1, 2, 1, 3, 1, and 1. The offsets is a list of 0, 4, 7, 10, 12, and 15. The sizes is a list of 4, 3, 3, 2, 3, and 4. The joints is a list of 6 zeros.
For every edge from 1 to 5.
For every row from 0 to 5.
The base is item row of offsets. The size is item row of sizes. The total is 0.
For every step from 0 to size minus 1.
The brick is item (base plus step) of bricks. Add brick to total. If total is edge, set item edge of joints to item edge of joints plus 1.

The best is 0.
For every spot from 1 to 5.
If item spot of joints is more than best, set best to item spot of joints.

The answer is 6 minus best. Show answer.

Open in Playground Browse all 1,000 problems

Expected stdout

2