The TransCompilator

Solved LeetCode program · 680 of 1,000

#0913 · Cat and Mouse

Hard Math chunk-14.md

Original English source

Keep a shared edges holding 1, 3, 0, 3, 0, and 2. Keep a shared starts holding 0, 2, 3, and 4. Keep a shared counts holding 2, 1, 1, and 2. Keep a shared catdegrees holding 0, 0, 0, and 0. Keep a shared colors as an empty list of whole numbers.
For every spot from 0 to 31.
Place 0 into colors.

Keep a shared remaining as an empty list of whole numbers.
For every spot from 0 to 31.
Place 0 into remaining.

Keep a shared queue as an empty list of whole numbers. Keep a shared count of 0. Keep a shared champion of 0. Keep a shared nowmouse of 0. Keep a shared nowcat of 0. Keep a shared nowturn of 0.
To relax from pred (a whole number) with winner (a whole number). If item pred of colors is not 0, return. The actor is pred modulo 2. If actor is 0 and winner is 1, set item pred of colors to winner, Place pred into queue, add 1 to count, return. If actor is 1 and winner is 2, set item pred of colors to winner, Place pred into queue, add 1 to count, return. Decrease item pred of remaining by 1. If item pred of remaining is 0, set item pred of colors to winner, Place pred into queue, add 1 to count.

To catparents from mouse (a whole number) with cat (a whole number) and winner (a whole number). The begin is item cat of starts. The total is item cat of counts.
For every slot from begin to begin plus total minus 1.
The step is item slot of edges.
If step is not 0.
The pred is (mouse times 4 plus step) times 2 plus 1. Relax from pred with winner.

To mouseparents from mouse (a whole number) with cat (a whole number) and winner (a whole number). The begin is item mouse of starts. The total is item mouse of counts.
For every slot from begin to begin plus total minus 1.
The step is item slot of edges.
If step is not 0 and step is not cat.
The pred is (step times 4 plus cat) times 2. Relax from pred with winner.

For every cat from 1 to 3.
The begin is item cat of starts. The total is item cat of counts.
For every slot from begin to begin plus total minus 1.
If item slot of edges is not 0, set item cat of catdegrees to item cat of catdegrees plus 1.

For every mouse from 0 to 3.
For every cat from 0 to 3.
For every turn from 0 to 1.
If mouse is 0, The index is (mouse times 4 plus cat) times 2 plus turn, set item index of colors to 1, Place index into queue, add 1 to count.

For every mouse from 0 to 3.
For every cat from 0 to 3.
For every turn from 0 to 1.
If mouse is more than 0 and mouse is cat, The index is (mouse times 4 plus cat) times 2 plus turn, set item index of colors to 2, Place index into queue, add 1 to count.

For every mouse from 1 to 3.
For every cat from 0 to 3.
For every turn from 0 to 1.
If mouse is not cat and cat is not 0.
The index is (mouse times 4 plus cat) times 2 plus turn. If turn is 0, set item index of remaining to item mouse of counts. If turn is 1, set item index of remaining to item cat of catdegrees.

The head is 0.
Repeat while head is less than count.
The state is item head of queue. Add 1 to head. Set champion to item state of colors. Set nowmouse to state divided by 8. The rest is state modulo 8. Set nowcat to rest divided by 2. Set nowturn to rest modulo 2. If nowturn is 0, Catparents from nowmouse with nowcat and champion. If nowturn is 1, Mouseparents from nowmouse with nowcat and champion.

The start is (1 times 4 plus 2) times 2. Show item start of colors.

Open in Playground Browse all 1,000 problems

Expected stdout

1