The TransCompilator

Solved LeetCode program · 891 of 1,000

#1223 · Dice Roll Simulation

Hard Array chunk-18.md

Original English source

The count is 3. The limits is a list of 1, 1, 1, 2, 2, and 3. The width is 16. The stride is 96. The table is a list of 384 zeros.
For every face from 0 to 5.
Set item (stride plus face times width plus 1) of table to 1.

For every round from 2 to count.
For every face from 0 to 5.
For every run from 1 to width minus 1.
For every target from 0 to 5.
The ways is item ((round minus 1) times stride plus face times width plus run) of table. The other is round times stride plus target times width plus 1. If target is not face and ways is more than 0, set item other of table to item other of table plus ways. If target is face and run is less than item target of limits and ways is more than 0, set item (other plus run) of table to item (other plus run) of table plus ways.

The total is 0.
For every face from 0 to 5.
For every run from 1 to width minus 1.
The portion is item (count times stride plus face times width plus run) of table. Add portion to total.

Show total.

Open in Playground Browse all 1,000 problems

Expected stdout

181