# The TransCompilator — Solved Programs · Chunk 18

Programs #1140–#1240 · 50 of 1,000 solved programs.

[Static catalog](https://ponvasanthpon.github.io/TransCompilator/problems/) · [llms.txt](https://ponvasanthpon.github.io/TransCompilator/llms.txt) · [Sitemap](https://ponvasanthpon.github.io/TransCompilator/sitemap.xml) · [Playground](https://ponvasanthpon.github.io/TransCompilator/)

Each entry contains the original natural-English `.eng` source and the
expected stdout. No LeetCode problem statement is copied.

---

## #1140 · Stone Game II

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1140) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1140.html)

```text
Keep a shared stones holding 2, 7, 9, 4, and 4. Keep a shared count of 5. Keep a shared tail as a list of 6 zeros. The spot is count minus 1.
Repeat while spot is at least 0.
The after is spot plus 1. Set item spot of tail to item after of tail plus item spot of stones. Subtract 1 from spot.

Keep a shared table as an empty list of whole numbers. For every slot from 0 to 35, Place -1 into table. Keep a shared gathered of 0.

To gather from start (a whole number) with limit (a whole number). The slot is start times 6 plus limit. If item slot of table is at least 0, set gathered to item slot of table, return. If start is at least count, set gathered to 0, set item slot of table to 0, return. The reach is limit times 2. If reach is more than count minus start, set reach to count minus start. The best is 0.
For every take from 1 to reach.
The grown is limit. If take is more than grown, set grown to take. Gather from start plus take with grown. The offered is item start of tail minus gathered. If offered is more than best, set best to offered. Set item slot of table to best. Set gathered to best.

Gather from 0 with 1. Show gathered.
```

**Expected stdout**

```text
10
```

## #1143 · Longest Common Subsequence

**Medium · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1143) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1143.html)

```text
The first is "abcde". The second is "ace". The firstsize is the number of characters in first. The secondsize is the number of characters in second. The width is secondsize plus 1. The size is (firstsize plus 1) times width. The lengths is a list of size zeros.
For every left from 1 to firstsize.
For every right from 1 to secondsize.
The here is left times width plus right. The same is 0. If character (left minus 1) of first is character (right minus 1) of second, set same to 1. The upper is item (left times width plus right minus width) of lengths. The western is item (left times width plus right minus 1) of lengths. The diagonal is item (left times width plus right minus width minus 1) of lengths. The best is the larger of upper and western. If same is 1, set item here of lengths to diagonal plus 1. If same is 0, set item here of lengths to best.

The answer is item (firstsize times width plus secondsize) of lengths. Show answer.
```

**Expected stdout**

```text
3
```

## #1144 · Decrease Elements To Make Array Zigzag

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1144) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1144.html)

```text
Keep a shared numbers holding 9, 6, 1, 6, and 2. Keep a shared count of 5. Keep a shared trial as a list of 5 zeros. Keep a shared cost of 0.

To score with parity (a whole number). For every spot from 0 to count minus 1, set item spot of trial to item spot of numbers. Set cost to 0.
For every spot from 1 to count minus 1.
If spot modulo 2 is parity and item spot of trial is at most item (spot minus 1) of trial, The gap is item (spot minus 1) of trial minus item spot of trial plus 1, add gap to cost, set item (spot minus 1) of trial to item spot of trial minus 1. If spot modulo 2 is not parity and item spot of trial is at least item (spot minus 1) of trial, The gap is item spot of trial minus item (spot minus 1) of trial plus 1, add gap to cost, set item spot of trial to item (spot minus 1) of trial minus 1.

Score with 0. The evencost is cost. Score with 1. The oddcost is cost. The answer is the smaller of evencost and oddcost. Show answer.
```

**Expected stdout**

```text
4
```

## #1145 · Binary Tree Coloring Game

**Medium · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1145) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1145.html)

```text
The values is a list of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, and 11. The count is 11. Keep a shared lefts as an empty list of whole numbers. Keep a shared rights as an empty list of whole numbers.
For every node from 0 to 10.
The left is node times 2 plus 1. The right is node times 2 plus 2. If left is at least count, set left to -1. If right is at least count, set right to -1. Place left into lefts. Place right into rights.

Keep a shared counted of 0.

To tally from node (a whole number). If node is less than 0, set counted to 0, return. The left is item node of lefts. The right is item node of rights. Tally from left. The leftsize is counted. Tally from right. The rightsize is counted. Set counted to leftsize plus rightsize plus 1.

The chosen is 3. The red is chosen minus 1. Tally from item red of lefts. The leftsize is counted. Tally from item red of rights. The rightsize is counted. Tally from red. The redsize is counted. The rest is count minus redsize. The bigger is the larger of leftsize and rightsize. The biggest is the larger of bigger and rest. If biggest times 2 is more than count, show true, otherwise show false.
```

**Expected stdout**

```text
true
```

## #1147 · Longest Chunked Palindrome Decomposition

**Hard · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1147) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1147.html)

```text
Keep a shared text as empty text. Place "ghiabcdefhelloadamhelloabcdefghi" into text. Keep a shared left of 0. Keep a shared right of the last position of text. Keep a shared pieces of 0. Keep a shared found of 0.

To seek. Set found to 0. The reach is (right minus left plus 1) divided by 2.
For every span from 1 to reach.
The front is the slice of text from left to left plus span. The back is the slice of text from right minus span plus 1 to right plus 1. The equal is 0. If front matches back, set equal to 1. If equal is 1 and found is 0, add 2 to pieces, set left to left plus span, set right to right minus span, set found to 1, stop.

Repeat while left is at most right.
If left is right, add 1 to pieces, set left to right plus 1, stop. Seek. If found is 0, add 1 to pieces, set left to right plus 1.

Show pieces.
```

**Expected stdout**

```text
7
```

## #1154 · Day of the Year

**Easy · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1154) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1154.html)

```text
The date is "2019-02-10". The lengths is a list of 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, and 31. The digit is 0. The year is the digit value of character 0 of date. Set digit to the digit value of character 1 of date. Set year to year times 10 plus digit. Set digit to the digit value of character 2 of date. Set year to year times 10 plus digit. Set digit to the digit value of character 3 of date. Set year to year times 10 plus digit. The month is the digit value of character 5 of date. Set digit to the digit value of character 6 of date. Set month to month times 10 plus digit. The day is the digit value of character 8 of date. Set digit to the digit value of character 9 of date. Set day to day times 10 plus digit. The leap is 0. If year modulo 4 is 0 and year modulo 100 is not 0, set leap to 1. If year modulo 400 is 0, set leap to 1. The total is 0.
For every which from 0 to month minus 2.
Increase total by item which of lengths. Increase total by day. If leap is 1 and month is more than 2, add 1 to total.

Show total.
```

**Expected stdout**

```text
41
```

## #1155 · Number of Dice Rolls With Target Sum

**Medium · Dynamic Programming** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1155) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1155.html)

```text
The dice is 2. The faces is 6. The wanted is 7. The width is wanted plus 1. The size is (dice plus 1) times width. The ways is a list of size zeros. Set item 0 of ways to 1.
For every die from 1 to dice.
For every sum from 1 to wanted.
For every face from 1 to faces.
If sum is at least face.
The earlier is sum minus face. The here is die times width plus sum. The before is (die minus 1) times width plus earlier. The gain is item before of ways. Set item here of ways to (item here of ways plus gain) modulo 1000000007.

The answer is item (dice times width plus wanted) of ways. Show answer.
```

**Expected stdout**

```text
6
```

## #1156 · Swap For Longest Repeated Character Substring

**Medium · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1156) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1156.html)

```text
Keep a shared text as empty text. Place "aaabaaa" into text. Keep a shared wanted as empty text. Keep a shared total of 0. Keep a shared best of 0. Keep a shared lastindex of the last position of text.
To tally from spot (a whole number). If spot is more than lastindex, return. If the slice of text from spot to spot plus 1 matches wanted, add 1 to total. Tally from spot plus 1.

To scan from seed (a whole number). Set wanted to the slice of text from seed to seed plus 1. Set total to 0. Tally from 0.
For every start from 0 to lastindex.
The matching is 0.
For every finish from start to lastindex.
If the slice of text from finish to finish plus 1 matches wanted, add 1 to matching. The span is finish minus start plus 1. The spare is total minus matching. The cap is total. If spare is more than 0, set cap to total plus 1. The candidate is span. If candidate is more than cap, set candidate to cap. If span minus matching is at most 1 and candidate is more than best, set best to candidate.

For every seed from 0 to lastindex.
Scan from seed.

Show best.
```

**Expected stdout**

```text
6
```

## #1160 · Find Words That Can Be Formed by Characters

**Easy · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1160) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1160.html)

```text
The words is a list of "cat", "bt", "hat", and "tree". The available is "atach". The total is 0.
For each word in words.
The good is 1. The last is the last position of word.
For every spot from 0 to last.
The symbol is the slice of word from spot to spot plus 1. The needed is 0. The offered is 0. For every other from 0 to last, if the slice of word from other to other plus 1 matches symbol, add 1 to needed. For every other from 0 to the last position of available, if the slice of available from other to other plus 1 matches symbol, add 1 to offered. If needed is more than offered, set good to 0. If spot is last and good is 1, add (last plus 1) to total.

Show total.
```

**Expected stdout**

```text
6
```

## #1161 · Maximum Level Sum of a Binary Tree

**Medium · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1161) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1161.html)

```text
The values is a list of 1, 7, 0, 7, -8, -1000000, and -1000000. The count is 7. The empty is -1000000. The lefts is an empty list of whole numbers. The rights is an empty list of whole numbers.
For every node from 0 to 6.
The left is node times 2 plus 1. The right is node times 2 plus 2. If left is at least count, set left to -1. If right is at least count, set right to -1. Place left into lefts. Place right into rights.

The queue is an empty list of whole numbers. The depths is an empty list of whole numbers. Place 0 into queue. Place 1 into depths. The head is 0. The held is 1. The level is 1. The leveltotal is 0. The best is -1000000. The answer is 1.
Repeat while head is less than held.
The front is head. The node is item front of queue. The depth is item front of depths. If depth is not level, Set best to the larger of best and leveltotal, Set answer to level, Set level to depth, Set leveltotal to 0. Increase leveltotal by item node of values. The left is item node of lefts. The right is item node of rights. If left is at least 0 and item left of values is not -1000000, Place left into queue, Place (depth plus 1) into depths, add 1 to held. If right is at least 0 and item right of values is not -1000000, Place right into queue, Place (depth plus 1) into depths, add 1 to held. Add 1 to head.

If leveltotal is more than best, Set best to leveltotal, Set answer to level. Show answer.
```

**Expected stdout**

```text
2
```

## #1162 · As Far from Land as Possible

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1162) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1162.html)

```text
Keep a shared active of 0. Keep a shared size of 3. The lands is a list of 1, 0, 1, 0, 0, 0, 1, 0, and 1. Keep a shared distances as an empty list of whole numbers. For every cell from 0 to 8, Place -1 into distances. Keep a shared queue as an empty list of whole numbers. Keep a shared count of 0.
For every cell from 0 to 8.
If item cell of lands is 1, set item cell of distances to 0, Place cell into queue, add 1 to count.

To relax with target (a whole number). The here is active. If item target of distances is at least 0, return. Set item target of distances to item here of distances plus 1. Place target into queue. Add 1 to count.

To spread. The band is active divided by size. The column is active modulo size. If band is more than 0, Relax with active minus size. If band is less than size minus 1, Relax with active plus size. If column is more than 0, Relax with active minus 1. If column is less than size minus 1, Relax with active plus 1.

The head is 0.
Repeat while head is less than count.
The front is head. Set active to item front of queue. Add 1 to head. Spread.

The best is -1.
For every cell from 0 to 8.
If item cell of distances is more than best, set best to item cell of distances.

If best is 0, show -1, otherwise show best.
```

**Expected stdout**

```text
2
```

## #1163 · Last Substring in Lexicographical Order

**Hard · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1163) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1163.html)

```text
The text is "abab". The last is the last position of text. The best is the slice of text from 0 to last plus 1.
For every start from 1 to last.
The candidate is the slice of text from start to last plus 1. The better is 0. If best comes before candidate, set better to 1. If better is 1, Set best to a copy of candidate.

Show best.
```

**Expected stdout**

```text
bab
```

## #1169 · Invalid Transactions

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1169) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1169.html)

```text
The records is a list of "alice,20,800,mtv", and "alice,50,100,beijing". The names is an empty list of text. The times is an empty list of whole numbers. The amounts is an empty list of whole numbers. The cities is an empty list of text. The invalid is an empty list of whole numbers. The lastrecord is the last position of records.
For each record in records.
The parts is split record by ",". The name is item 0 of parts. The timepiece is item 1 of parts. The amountpiece is item 2 of parts. The city is item 3 of parts. The time is the digit value of character 0 of timepiece. The digit is 0. If the length of timepiece is more than 1, Set digit to the digit value of character 1 of timepiece, Set time to time times 10 plus digit. If the length of timepiece is more than 2, Set digit to the digit value of character 2 of timepiece, Set time to time times 10 plus digit. If the length of timepiece is more than 3, Set digit to the digit value of character 3 of timepiece, Set time to time times 10 plus digit. The amount is the digit value of character 0 of amountpiece. If the length of amountpiece is more than 1, Set digit to the digit value of character 1 of amountpiece, Set amount to amount times 10 plus digit. If the length of amountpiece is more than 2, Set digit to the digit value of character 2 of amountpiece, Set amount to amount times 10 plus digit. If the length of amountpiece is more than 3, Set digit to the digit value of character 3 of amountpiece, Set amount to amount times 10 plus digit. Place name into names. Place time into times. Place amount into amounts. Place city into cities. Place 0 into invalid.

For every left from 0 to lastrecord.
If item left of amounts is more than 1000, set item left of invalid to 1.
For every right from 0 to lastrecord.
The gap is item left of times minus item right of times. Set gap to the absolute value of gap. The samecity is 0. The samename is 0. If item left of cities matches item right of cities, set samecity to 1. If item left of names matches item right of names, set samename to 1. If left is not right and samename is 1 and samecity is 0 and gap is at most 60, set item left of invalid to 1.

For every left from 0 to lastrecord.
If item left of invalid is 1, Show item left of records.
```

**Expected stdout**

```text
alice,20,800,mtv
alice,50,100,beijing
```

## #1170 · Compare Strings by Frequency of the Smallest Character

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1170) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1170.html)

```text
Keep a shared current as empty text. Keep a shared weight of 0.

To weigh. The ordered is sort characters of current. The smallest is character 0 of ordered. The total is 0. For every spot from 0 to the last position of ordered, if character spot of ordered is smallest, add 1 to total. Set weight to total.

The queries is a list of "bbb", and "cc". The words is a list of "a", "aa", "aaa", and "aaaa". The wordlast is the last position of words.
For each query in queries.
Set current to a copy of query. Weigh. The wanted is weight. The total is 0.
For every which from 0 to wordlast.
Set current to item which of words. Weigh. If weight is more than wanted, add 1 to total. If which is wordlast, Show total.
```

**Expected stdout**

```text
1
2
```

## #1171 · Remove Zero Sum Consecutive Nodes from Linked List

**Medium · Linked List** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1171) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1171.html)

```text
Keep a shared values holding 1, 2, -3, 3, and 1.

Keep a shared nexts holding 1, 2, 3, 4, -1, and 0.

Keep a shared keys as an empty list of whole numbers. Keep a shared places as an empty list of whole numbers. Place 0 into keys. Place 5 into places. Keep a shared running of 0. Keep a shared found of 0.

To seek from target (a whole number) with node (a whole number). Set found to 0. The size is the last position of keys.
For every seen from 0 to size.
If item seen of keys is target, set item (item seen of places) of nexts to item node of nexts, set found to 1, stop. If found is 0, Place target into keys, Place node into places.

For every node from 0 to 4.
The value is item node of values. Increase running by value. Seek from running with node.

The line is empty text. The node is item 5 of nexts.
Repeat while node is at least 0.
The value is item node of values. The word is format whole number value as text. If the length of line is more than 0, Place "," into line. Place word into line. Set node to item node of nexts.

Show line.
```

**Expected stdout**

```text
3,1
```

## #1175 · Prime Arrangements

**Easy · Math** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1175) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1175.html)

```text
Keep a shared prime of 0.

To check from value (a whole number). Set prime to 0. If value is less than 2, return. Set prime to 1. The limit is value minus 1.
For every divisor from 2 to limit.
If value modulo divisor is 0, set prime to 0, stop.

The size is 100. The primes is 0. The rest is 0.
For every value from 1 to size.
Check from value. If prime is 1, add 1 to primes. If prime is 0, add 1 to rest.

The modulus is 1000000007. The answer is 1.
For every value from 2 to primes.
Set answer to (answer times value) modulo modulus.

For every value from 2 to rest.
Set answer to (answer times value) modulo modulus.

Show answer.
```

**Expected stdout**

```text
682289015
```

## #1177 · Can Make Palindrome from Substring

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1177) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1177.html)

```text
Keep a shared alphabet as empty text. Place "abcdefghijklmnopqrstuvwxyz" into alphabet. Keep a shared symbol as empty text. Keep a shared position of 0. Keep a shared odd of 0. Keep a shared mask of 0. Keep a shared source as empty text. Place "abcda" into source.

To locate from spot (a whole number). The letter is the slice of alphabet from spot to spot plus 1. If letter matches symbol, set position to spot, return. Locate from spot plus 1.

To count from left (a whole number) with right (a whole number). Set odd to 0. Set mask to 0.
For every spot from left to right.
The piece is the slice of source from spot to spot plus 1. Set symbol to piece. Locate from 0. The bit is shift 1 left by position. The was is bitwise and of mask and bit. If was is more than 0, subtract 1 from odd. If was is 0, add 1 to odd. Set mask to exclusive or of mask and bit.

The queries is a list of 3, 3, 0, 1, 2, 0, 0, 3, 1, 0, 3, 2, 0, 4, and 1.
For every query from 0 to 4.
The left is item (query times 3) of queries. The right is item (query times 3 plus 1) of queries. The budget is item (query times 3 plus 2) of queries. Count from left with right. The pairs is odd divided by 2. If pairs is at most budget, show true, otherwise show false.
```

**Expected stdout**

```text
true
false
false
true
true
```

## #1178 · Number of Valid Words for Each Puzzle

**Hard · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1178) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1178.html)

```text
Keep a shared wordmasks holding 1, 262145, 2067, 17303811, 524293, 671749, and 262165. Keep a shared puzzlemasks holding 52445203, 50479115, 1837075, 50741251, 34471957, and 63176769. Keep a shared firstbits holding 1, 1, 1, 1, 1, and 64. Keep a shared counts as an empty list of whole numbers. Keep a shared count of 0.
To judge from puzzle (a whole number) with word (a whole number). If word is more than 6, Place count into counts, return. The pmask is item puzzle of puzzlemasks. The pfirst is item puzzle of firstbits. The wmask is item word of wordmasks. The firstok is bitwise and of wmask and pfirst. The subset is bitwise and of wmask and pmask. If firstok is not 0 and subset is wmask, add 1 to count. Judge from puzzle with word plus 1.

For every puzzle from 0 to 5.
Set count to 0. Judge from puzzle with 0.

For each entry in counts, show entry.
```

**Expected stdout**

```text
1
1
3
2
4
0
```

## #1184 · Distance Between Bus Stops

**Easy · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1184) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1184.html)

```text
The gaps is a list of 1, 2, 3, and 4. The start is 0. The finish is 1. The size is 0. The total is 0.
For each gap in gaps.
Add 1 to size. Add gap to total.

The clockwise is 0. The spot is start.
Repeat while spot is not finish.
Increase clockwise by item spot of gaps. Set spot to (spot plus 1) modulo size.

The other is total minus clockwise. The best is clockwise. If other is less than best, set best to other.

Show best.
```

**Expected stdout**

```text
1
```

## #1185 · Day of the Week

**Easy · Math** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1185) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1185.html)

```text
The day is 31. The month is 8. The year is 2019.

If month is less than 3.
Increase month by 12. Decrease year by 1.

The century is year divided by 100. The short is year modulo 100. The step is (13 times (month plus 1)) divided by 5. The index is day plus step plus short plus (short divided by 4) plus (century divided by 4) plus (5 times century). Set index to index modulo 7.

The names is a list of "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", and "Friday".

Show item index of names.
```

**Expected stdout**

```text
Saturday
```

## #1186 · Maximum Subarray Sum with One Deletion

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1186) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1186.html)

```text
The numbers is a list of 1, -2, 0, and 3. The keep is item 0 of numbers. The skip is item 0 of numbers. The best is item 0 of numbers.

For every spot from 1 to 3.
The value is item spot of numbers. The fresh is keep plus value. If value is more than fresh, set fresh to value. The bent is skip plus value. If keep is more than bent, set bent to keep. Set keep to fresh. Set skip to bent. If keep is more than best, set best to keep. If skip is more than best, set best to skip.

Show best.
```

**Expected stdout**

```text
4
```

## #1187 · Make Array Strictly Increasing

**Hard · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1187) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1187.html)

```text
Keep a shared firsts holding 1, 5, 3, 6, and 7.

Keep a shared seconds holding 1, 3, 2, and 4.

Keep a shared ways as an empty list of whole numbers.
For every spot from 0 to 24.
Place 999 into ways.

Keep a shared best of 0.

To relax from row (a whole number) with option (a whole number). Set best to 999. The value is item row of firsts. If option is more than 0, set value to item (option minus 1) of seconds. The previous is row minus 1.
For every prior from 0 to 4.
The old is item (previous times 5 plus prior) of ways. The before is item previous of firsts. If prior is more than 0, set before to item (prior minus 1) of seconds. If old is less than best and before is less than value, set best to old.

Set item 0 of ways to 0. Set item 1 of ways to 1. Set item 2 of ways to 1. Set item 3 of ways to 1. Set item 4 of ways to 1.

For every row from 1 to 4.
For every option from 0 to 4.
Relax from row with option. The cost is best. If option is more than 0, add 1 to cost. Set item (row times 5 plus option) of ways to cost.

The answer is 999.
For every option from 0 to 4.
If item (20 plus option) of ways is less than answer, set answer to item (20 plus option) of ways.

If answer is at least 999, show -1, otherwise show answer.
```

**Expected stdout**

```text
1
```

## #1189 · Maximum Number of Balloons

**Easy · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1189) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1189.html)

```text
The word is "loonbalxballpoon". The last is the last position of word. The bees is 0. The ayes is 0. The elles is 0. The ohs is 0. The ens is 0.

For every spot from 0 to last.
The piece is the slice of word from spot to spot plus 1. If piece matches "b", add 1 to bees. If piece matches "a", add 1 to ayes. If piece matches "l", add 1 to elles. If piece matches "o", add 1 to ohs. If piece matches "n", add 1 to ens.

Set elles to elles divided by 2. Set ohs to ohs divided by 2. The answer is bees. If ayes is less than answer, set answer to ayes. If elles is less than answer, set answer to elles. If ohs is less than answer, set answer to ohs. If ens is less than answer, set answer to ens.

Show answer.
```

**Expected stdout**

```text
2
```

## #1190 · Reverse Substrings Between Each Pair of Parentheses

**Medium · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1190) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1190.html)

```text
Keep a shared stack as an empty list of text. Keep a shared current as empty text. Keep a shared word as empty text. Keep a shared flipped as empty text.

To turn. Set flipped to empty text. The last is the last position of word.
For every step from 0 to last.
The source is last minus step. The piece is the slice of word from source to source plus 1. Place piece into flipped.

To fold. The size is the last position of stack. The opened is item size of stack. remove the last item from stack. Set word to current. Turn. Place flipped into opened. Set current to opened.

The source is "(u(love)i)". The last is the last position of source.
For every spot from 0 to last.
The piece is the slice of source from spot to spot plus 1. If piece matches "(", Place current into stack, set current to empty text. If piece matches ")", fold. If piece does not match "(", If piece does not match ")", Place piece into current.

Show current.
```

**Expected stdout**

```text
iloveu
```

## #1191 · K-Concatenation Maximum Sum

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1191) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1191.html)

```text
The numbers is a list of 1 and 2. The rounds is 3. The total is 0.
For each value in numbers.
Add value to total.

The current is 0. The best is 0.
For each value in numbers.
Set current to the larger of current plus value and value. Set best to the larger of best and current.

The answer is best. If rounds is more than 1 and total is more than 0, set answer to best plus (total times (rounds minus 1)).

Show answer.
```

**Expected stdout**

```text
9
```

## #1192 · Critical Connections in a Network

**Hard · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1192) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1192.html)

```text
Keep a shared adjacency as an empty list of whole numbers. Keep a shared disc as an empty list of whole numbers. Keep a shared low as an empty list of whole numbers. Keep a shared parent as an empty list of whole numbers. Keep a shared bridges as an empty list of whole numbers. Keep a shared timer of 0.

For every spot from 0 to 15.
Place 0 into adjacency.

For every spot from 0 to 3.
Place 0 into disc. Place 0 into low. Place 0 into parent.

To visit from node (a whole number) with next (a whole number). Set item next of parent to node. Explore from next. The lownext is item next of low. If lownext is less than item node of low, set item node of low to lownext. If lownext is more than item node of disc, Place node into bridges, Place next into bridges.

To revisit from node (a whole number) with next (a whole number). If next is item node of parent, return. If item next of disc is less than item node of low, set item node of low to item next of disc.

To explore from node (a whole number). Add 1 to timer. Set item node of disc to timer. Set item node of low to timer.
For every next from 0 to 3.
If item (node times 4 plus next) of adjacency is 1.
If item next of disc is 0, Visit from node with next, otherwise Revisit from node with next.

The edges is a list of 0, 1, 1, 2, 2, 0, and 1, 3.
For every edge from 0 to 3.
The origin is item (edge times 2) of edges. The target is item (edge times 2 plus 1) of edges. Set item (origin times 4 plus target) of adjacency to 1. Set item (target times 4 plus origin) of adjacency to 1.

Explore from 0.

The last is the last position of bridges.
For every spot from 0 to last by 2.
The line is empty text. The first is item spot of bridges. The second is item (spot plus 1) of bridges. The word is format whole number first as text. Place word into line. Place "," into line. The other is format whole number second as text. Place other into line. Show line.
```

**Expected stdout**

```text
1,3
```

## #1200 · Minimum Absolute Difference

**Easy · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1200) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1200.html)

```text
The numbers is a list of 4, 2, 1, and 3. The last is the last position of numbers.
For every left from 0 to last.
For every right from left to last.
If item right of numbers is less than item left of numbers, swap item left of numbers and item right of numbers.

The best is 1000000.
For every spot from 1 to last.
The gap is item spot of numbers minus item (spot minus 1) of numbers. If gap is less than best, set best to gap.

For every spot from 1 to last.
The gap is item spot of numbers minus item (spot minus 1) of numbers.
If gap is best.
The line is empty text. The first is item (spot minus 1) of numbers. The second is item spot of numbers. The word is format whole number first as text. Place word into line. Place "," into line. The other is format whole number second as text. Place other into line. Show line.
```

**Expected stdout**

```text
1,2
2,3
3,4
```

## #1201 · Ugly Number III

**Medium · Math** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1201) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1201.html)

```text
Keep a shared firstdiv of 0. Keep a shared seconddiv of 0. Keep a shared thirddiv of 0. Set firstdiv to 2. Set seconddiv to 3. Set thirddiv to 5. Keep a shared divisor of 0. Keep a shared multiple of 0. Keep a shared tally of 0.

To gcd from first (a whole number) with second (a whole number). If second is 0, set divisor to first, return. Gcd from second with (first modulo second).

To lcm from first (a whole number) with second (a whole number). Gcd from first with second. Set multiple to (first divided by divisor) times second.

To count from value (a whole number). Set tally to value divided by firstdiv. Increase tally by (value divided by seconddiv). Increase tally by (value divided by thirddiv). Lcm from firstdiv with seconddiv. The ab is multiple. Lcm from firstdiv with thirddiv. The ac is multiple. Lcm from seconddiv with thirddiv. The bc is multiple. Lcm from ab with thirddiv. The abc is multiple. Decrease tally by (value divided by ab). Decrease tally by (value divided by ac). Decrease tally by (value divided by bc). Increase tally by (value divided by abc).

The rank is 3. The low is 1. The high is 6.
Repeat while low is less than high.
The middle is (low plus high) divided by 2. Count from middle. If tally is at least rank, set high to middle. If tally is less than rank, set low to middle plus 1.

Show low.
```

**Expected stdout**

```text
4
```

## #1202 · Smallest String With Swaps

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1202) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1202.html)

```text
Keep a shared source as empty text. Place "dcab" into source. Keep a shared parent as an empty list of whole numbers. Keep a shared groups as an empty list of text. Keep a shared taken as an empty list of whole numbers. Keep a shared result as empty text. Keep a shared root of 0.

The size is 4.
For every spot from 0 to size minus 1.
Place spot into parent. Place "" into groups. Place 0 into taken.

To locate from spot (a whole number). Set root to spot. The cursor is spot.
Repeat while item cursor of parent is not cursor.
Set cursor to item cursor of parent. Set root to cursor.

To gather from spot (a whole number). Locate from spot. The place is root. The piece is the slice of source from spot to spot plus 1. The current is item place of groups. Place piece into current. Set item place of groups to current.

To pick from spot (a whole number). Locate from spot. The place is root. The start is item place of taken. The upper is start plus 1. The block is item place of groups. The piece is the slice of block from start to upper. Place piece into result. Set item place of taken to upper.

The pairs is a list of 0, 3, 1, and 2.
For every pair from 0 to 1.
The one is item (pair times 2) of pairs. The two is item (pair times 2 plus 1) of pairs. Locate from one. The firstroot is root. Locate from two. The secondroot is root. If firstroot is not secondroot, set item firstroot of parent to secondroot.

For every spot from 0 to size minus 1.
Gather from spot.

For every spot from 0 to size minus 1.
The current is item spot of groups. The ordered is sort characters of current. Set item spot of groups to ordered.

For every spot from 0 to size minus 1.
Pick from spot.

Show result.
```

**Expected stdout**

```text
bacd
```

## #1203 · Sort Items by Groups Respecting Dependencies

**Hard · Depth-First Search** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1203) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1203.html)

```text
Keep a shared group holding -1, -1, 1, 0, 0, 1, 0, and -1.

Keep a shared homes holding 2, 3, 1, 0, 0, 1, 0, and 4.

Keep a shared withins as an empty list of whole numbers. Keep a shared needs as an empty list of whole numbers. Keep a shared taken as an empty list of whole numbers. Keep a shared ranked as an empty list of whole numbers. Keep a shared sizes as an empty list of whole numbers. Keep a shared ordernext as an empty list of whole numbers. Keep a shared orderneed as an empty list of whole numbers. Keep a shared chosen of 0. Keep a shared solos holding 0, 1, and 7.

For every spot from 0 to 63.
Place 0 into withins.

For every spot from 0 to 7.
Place 0 into needs. Place 0 into taken.

For every spot from 0 to 15.
Place 0 into ranked.

For every spot from 0 to 1.
Place 0 into sizes.

For every spot from 0 to 24.
Place 0 into ordernext.

For every spot from 0 to 4.
Place 0 into orderneed.

The links is a list of 6, 1, 5, 2, 6, 3, 3, 4, 6, and 4.

For every edge from 0 to 4.
The before is item (edge times 2) of links. The after is item (edge times 2 plus 1) of links. The one is item before of group. The two is item after of group. If one is two and one is not -1, set item (before times 8 plus after) of withins to 1, set item after of needs to item after of needs plus 1.

For every item from 0 to 7.
The team is item item of group. If team is not -1, set item team of sizes to item team of sizes plus 1.

To choose from team (a whole number). Set chosen to -1.
For every item from 0 to 7.
If item item of group is team and item item of taken is 0 and item item of needs is 0 and chosen is -1, set chosen to item, stop.

To release from pick (a whole number).
For every other from 0 to 7.
If item (pick times 8 plus other) of withins is 1, set item other of needs to item other of needs minus 1.

To arrange from team (a whole number). Set count to 0.
For every slot from 0 to 7.
If count is less than item team of sizes.
Choose from team. The pick is chosen.
If pick is at least 0.
Set item (team times 8 plus count) of ranked to pick. Add 1 to count. Set item pick of taken to 1. Release from pick.

To attach from first (a whole number) with second (a whole number). If item (first times 5 plus second) of ordernext is 1, return. Set item (first times 5 plus second) of ordernext to 1. Increase item second of orderneed by 1.

For every edge from 0 to 4.
The before is item (edge times 2) of links. The after is item (edge times 2 plus 1) of links. The one is item before of homes. The two is item after of homes. If one is not two, Attach from one with two.

Arrange from 0. Arrange from 1.

The queue is an empty list of whole numbers. The order is an empty list of whole numbers. The head is 0. The followed is 0.
For every block from 0 to 4.
If item block of orderneed is 0, Place block into queue, add 1 to followed.

Repeat while head is less than followed.
The node is item head of queue. Add 1 to head. Place node into order.
For every next from 0 to 4.
If item (node times 5 plus next) of ordernext is 1.
Decrease item next of orderneed by 1. If item next of orderneed is 0, Place next into queue, add 1 to followed.

To showgroup from block (a whole number). The count is item block of sizes. The bottom is block times 8.
For every within from 0 to count minus 1.
The spot is bottom plus within. Show item spot of ranked.

To showone from block (a whole number). The solo is block minus 2. Show item solo of solos.

To showblock from block (a whole number). If block is less than 2, Showgroup from block. If block is at least 2, Showone from block.

For every spot from 0 to 4.
The block is item spot of order. Showblock from block.
```

**Expected stdout**

```text
6
3
4
5
2
0
7
1
```

## #1207 · Unique Number of Occurrences

**Easy · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1207) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1207.html)

```text
Keep a shared numbers holding 1, 2, 2, 1, 1, and 3.

Keep a shared distinct as an empty list of whole numbers. Keep a shared counts as an empty list of whole numbers. Keep a shared total of 0. Keep a shared known of 0.

To count from value (a whole number). Set total to 0. The last is the last position of numbers.
For every spot from 0 to last.
If item spot of numbers is value, add 1 to total.

To check from value (a whole number). Set known to 0. The last is the last position of distinct.
For every spot from 0 to last.
If item spot of distinct is value, set known to 1, stop.

For every spot from 0 to 5.
The value is item spot of numbers. Check from value.
If known is 0.
Count from value. Place value into distinct. Place total into counts.

The same is 0. The last is the last position of counts.
For every left from 0 to last.
For every right from left plus 1 to last.
If item left of counts is item right of counts, set same to 1.

If same is 0, show true, otherwise show false.
```

**Expected stdout**

```text
true
```

## #1208 · Get Equal Substrings Within Budget

**Medium · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1208) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1208.html)

```text
Keep a shared alphabet as empty text. Place "abcdefghijklmnopqrstuvwxyz" into alphabet. Keep a shared symbol as empty text. Keep a shared position of 0.

To locate from spot (a whole number). The letter is the slice of alphabet from spot to spot plus 1. If letter matches symbol, set position to spot, return. Locate from spot plus 1.

Keep a shared costs as an empty list of whole numbers. Keep a shared total of 0. Keep a shared left of 0. Keep a shared budget of 0. Keep a shared best of 0. Set budget to 3.

The first is "abcd". The second is "bcdf". The last is the last position of first.
For every spot from 0 to last.
The piece is the slice of first from spot to spot plus 1. Set symbol to piece. Locate from 0. The leftspot is position. The other is the slice of second from spot to spot plus 1. Set symbol to other. Locate from 0. The gap is leftspot minus position. If gap is less than 0, set gap to 0 minus gap. Place gap into costs.

To shrink from spot (a whole number).
Repeat while total is more than budget.
Decrease total by item spot of costs. Add 1 to spot. Set left to spot.

For every right from 0 to last.
Increase total by item right of costs. Shrink from left. The width is right minus left plus 1. If width is more than best, set best to width.

Show best.
```

**Expected stdout**

```text
3
```

## #1209 · Remove All Adjacent Duplicates in String II

**Medium · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1209) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1209.html)

```text
Keep a shared letters as an empty list of text. Keep a shared counts as an empty list of whole numbers. Keep a shared answer as empty text. Place "#" into letters. Place 0 into counts.

To extend from spot (a whole number). The piece is item spot of letters. The times is item spot of counts.
For every copy from 1 to times.
Place piece into answer.

The source is "deeedbbcccbdaa". The limit is 3. The last is the last position of source.

For every spot from 0 to last.
The piece is the slice of source from spot to spot plus 1. The size is the last position of letters. The top is item size of letters. The same is 0. If top matches piece, set same to 1. If same is 1, set item size of counts to item size of counts plus 1. If same is 0, Place piece into letters, Place 1 into counts. If same is 1 and item size of counts is limit, remove the last item from letters, remove the last item from counts.

The last is the last position of letters.
For every spot from 1 to last.
Extend from spot.

Show answer.
```

**Expected stdout**

```text
aa
```

## #1210 · Minimum Moves to Reach Target with Rotations

**Hard · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1210) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1210.html)

```text
Keep a shared grid holding 0, 0, 0, and 0. Keep a shared seen as an empty list of whole numbers. Keep a shared queue as an empty list of whole numbers. Keep a shared distances as an empty list of whole numbers. Keep a shared last of 1. Keep a shared count of 0.

For every spot from 0 to 15.
Place 0 into seen.

To enqueue from state (a whole number) with distance (a whole number). If item state of seen is 1, return. Set item state of seen to 1. Place state into queue. Place distance into distances. Add 1 to count.

To turn from state (a whole number) with distance (a whole number). The headcol is state modulo 2. The rest is state divided by 2. The headrow is rest modulo 2. The rest is rest divided by 2. The tailcol is rest modulo 2. The tailrow is rest divided by 2. The horizontal is 0. If tailrow is headrow and headcol is tailcol plus 1, set horizontal to 1.
If horizontal is 1 and headrow is less than last.
The cell is item (headrow times 2 plus headcol plus 2) of grid. The fresh is ((headrow times 2 plus headcol) times 2 plus headrow plus 1) times 2 plus headcol. If cell is 0, Enqueue from fresh with distance plus 1.

To bend from state (a whole number) with distance (a whole number). The headcol is state modulo 2. The rest is state divided by 2. The headrow is rest modulo 2. The rest is rest divided by 2. The tailcol is rest modulo 2. The tailrow is rest divided by 2. The vertical is 0. If tailcol is headcol and headrow is tailrow plus 1, set vertical to 1.
If vertical is 1 and headcol is more than 0.
The cell is item (headrow times 2 plus headcol minus 1) of grid. The fresh is ((headrow times 2 plus headcol) times 2 plus headrow) times 2 plus headcol minus 1. If cell is 0, Enqueue from fresh with distance plus 1.

To advance from state (a whole number) with distance (a whole number). The headcol is state modulo 2. The rest is state divided by 2. The headrow is rest modulo 2. The rest is rest divided by 2. The tailcol is rest modulo 2. The tailrow is rest divided by 2. The horizontal is 0. If tailrow is headrow and headcol is tailcol plus 1, set horizontal to 1.
If horizontal is 1 and headcol is less than last.
The cell is item (headrow times 2 plus headcol plus 1) of grid. The fresh is ((tailrow times 2 plus tailcol plus 1) times 2 plus headrow) times 2 plus headcol plus 1. If cell is 0, Enqueue from fresh with distance plus 1.

To descend from state (a whole number) with distance (a whole number). The headcol is state modulo 2. The rest is state divided by 2. The headrow is rest modulo 2. The rest is rest divided by 2. The tailcol is rest modulo 2. The tailrow is rest divided by 2. The vertical is 0. If tailcol is headcol and headrow is tailrow plus 1, set vertical to 1.
If vertical is 1 and headrow is less than last.
The cell is item (headrow times 2 plus headcol plus 2) of grid. The fresh is ((tailrow times 2 plus tailcol plus 2) times 2 plus headrow plus 1) times 2 plus headcol. If cell is 0, Enqueue from fresh with distance plus 1.

Set item 1 of seen to 1. Place 1 into queue. Place 0 into distances. Set count to 1. The head is 0. The answer is -1.

Repeat while head is less than count.
The state is item head of queue. The travel is item head of distances. Add 1 to head. If state is 11 or state is 14, set answer to travel, stop. Turn from state with travel. Bend from state with travel. Advance from state with travel. Descend from state with travel.

Show answer.
```

**Expected stdout**

```text
2
```

## #1217 · Minimum Cost to Move Chips to The Same Position

**Easy · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1217) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1217.html)

```text
The positions is a list of 1, 2, and 3. The evens is 0. The odds is 0.
For each value in positions.
If value modulo 2 is 0, add 1 to evens, otherwise add 1 to odds.

If evens is less than odds, show evens, otherwise show odds.
```

**Expected stdout**

```text
1
```

## #1218 · Longest Arithmetic Subsequence of Given Difference

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1218) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1218.html)

```text
The readings is a list of 1, 5, 7, 8, 5, 3, 4, 2, and 1. The step is -2. The lengths is a list of 9 zeros.
For every finish from 0 to 8.
Set item finish of lengths to 1.
For every prior from 0 to finish minus 1.
If item prior of readings plus step is item finish of readings and item prior of lengths plus 1 is more than item finish of lengths, set item finish of lengths to item prior of lengths plus 1.

The longest is 1.
For every finish from 0 to 8.
If item finish of lengths is more than longest, set longest to item finish of lengths.

Show longest.
```

**Expected stdout**

```text
4
```

## #1219 · Path with Maximum Gold

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1219) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1219.html)

```text
Keep a shared gold holding 0, 6, 0, 5, 8, 7, 0, 9, and 0. Keep a shared best of 0. Keep a shared width of 3. Keep a shared height of 3.

To Explore from cell (a whole number) with total (a whole number). The here is item cell of gold. If here is 0, return. The band is cell divided by width. The col is cell modulo width. Set item cell of gold to 0. The gained is total plus here. If gained is more than best, set best to gained.
If cell is at least width and item (cell minus width) of gold is more than 0, Explore from cell minus width with gained. If cell is less than height times width minus width and item (cell plus width) of gold is more than 0, Explore from cell plus width with gained. If col is more than 0 and item (cell minus 1) of gold is more than 0, Explore from cell minus 1 with gained. If col is less than width minus 1 and item (cell plus 1) of gold is more than 0, Explore from cell plus 1 with gained. Set item cell of gold to here.

For every cell from 0 to 8.
Explore from cell with 0.

Show best.
```

**Expected stdout**

```text
24
```

## #1220 · Count Vowels Permutation

**Hard · Dynamic Programming** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1220) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1220.html)

```text
The count is 5. The alpha is 1. The echo is 1. The india is 1. The oscar is 1. The uniform is 1. The round is 2.
Repeat while round is at most count.
The nextalpha is echo plus india plus uniform. The nextecho is alpha plus india. The nextindia is echo plus oscar. The nextoscar is india. The nextuniform is india plus oscar. Set alpha to nextalpha. Set echo to nextecho. Set india to nextindia. Set oscar to nextoscar. Set uniform to nextuniform. Add 1 to round.

The total is alpha plus echo plus india plus oscar plus uniform. Show total modulo 1000000007.
```

**Expected stdout**

```text
68
```

## #1221 · Split a String in Balanced Strings

**Easy · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1221) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1221.html)

```text
The symbols is "RLRRLLRLRL". The balance is 0. The pieces is 0.
For every spot from 0 to the last position of symbols.
The symbol is character spot of symbols. If symbol is "R", add 1 to balance, otherwise subtract 1 from balance. If balance is 0, add 1 to pieces.

Show pieces.
```

**Expected stdout**

```text
4
```

## #1222 · Queens That Can Attack the King

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1222) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1222.html)

```text
The queenrows is a list of 0, 1, 4, 0, 3, and 2. The queencols is a list of 1, 0, 0, 4, 3, and 4. The kingrow is 0. The kingcol is 0. The nearest is a list of 9 zeros. The pickrow is a list of 9 zeros. The pickcol is a list of 9 zeros.
For every spot from 0 to 5.
The queenrow is item spot of queenrows. The queencol is item spot of queencols. The down is queenrow minus kingrow. The across is queencol minus kingcol. The aligned is 0. If down is 0 or across is 0 or the absolute value of down is the absolute value of across, set aligned to 1.
If aligned is 1.
The stepdown is 0. If down is less than 0, set stepdown to -1. If down is more than 0, set stepdown to 1. The stepacross is 0. If across is less than 0, set stepacross to -1. If across is more than 0, set stepacross to 1. The slot is (stepdown plus 1) times 3 plus stepacross plus 1. The distance is the absolute value of down plus the absolute value of across. The better is 0. If item slot of nearest is 0, set better to 1. If distance is less than item slot of nearest, set better to 1. If better is 1 and distance is more than 0, set item slot of nearest to distance, set item slot of pickrow to queenrow, set item slot of pickcol to queencol.

The board is a list of 64 zeros.
For every slot from 0 to 8.
If item slot of nearest is more than 0, set item (item slot of pickrow times 8 plus item slot of pickcol) of board to 1.

The rows is an empty list of whole numbers. The cols is an empty list of whole numbers.
For every depth from 0 to 7.
For every column from 0 to 7.
If item (depth times 8 plus column) of board is 1, Place depth into rows, Place column into cols.

The line is empty text. Place "[" into line.
For every spot from 0 to the last position of rows.
If spot is more than 0, Place "," into line. The rowtext is format whole number item spot of rows as text. The coltext is format whole number item spot of cols as text. Place "[" into line. Place rowtext into line. Place "," into line. Place coltext into line. Place "]" into line.

Place "]" into line. Show line.
```

**Expected stdout**

```text
[[0,1],[1,0],[3,3]]
```

## #1223 · Dice Roll Simulation

**Hard · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1223) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1223.html)

```text
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.
```

**Expected stdout**

```text
181
```

## #1224 · Maximum Equal Frequency

**Hard · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1224) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1224.html)

```text
The numbers is a list of 2, 2, 1, 1, 5, 3, 3, and 5. Keep a shared seen as an empty list of whole numbers. Keep a shared counts as an empty list of whole numbers. Keep a shared incoming of 0. Keep a shared position of 0. Keep a shared high of 0. Keep a shared highcount of 0. Keep a shared singles of 0. Keep a shared distinct of 0. Keep a shared best of 0.

To Seek from spot (a whole number). If spot is more than the last position of seen, set position to -1, return. If item spot of seen is incoming, set position to spot, return. Seek from spot plus 1.

To Survey from spot (a whole number). If spot is more than the last position of counts, return. The tally is item spot of counts. If tally is more than high, set high to tally. If tally is 1, add 1 to singles. Survey from spot plus 1.

To Count from spot (a whole number). If spot is more than the last position of counts, return. If item spot of counts is high, add 1 to highcount. Count from spot plus 1.

To Size from spot (a whole number). If spot is more than the last position of counts, return. Add 1 to distinct. Size from spot plus 1.

The length is 0.
For every spot from 0 to 7.
Add 1 to length. Set incoming to item spot of numbers. Seek from 0. The slot is position. If slot is less than 0, Place incoming into seen, Place 1 into counts. If slot is at least 0, set item slot of counts to item slot of counts plus 1. Set high to 0. Set highcount to 0. Set singles to 0. Set distinct to 0. Survey from 0. Count from 0. Size from 0. The without is length minus 1. The flattened is distinct times (high minus 1). The trimmed is (distinct minus 1) times high. The okay is 0. If high is 1, set okay to 1. If highcount is 1 and without is flattened, set okay to 1. If singles is 1 and without is trimmed, set okay to 1. If okay is 1, set best to length.

Show best.
```

**Expected stdout**

```text
7
```

## #1227 · Airplane Seat Assignment Probability

**Medium · Math** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1227) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1227.html)

```text
The seats is 2. If seats is 1, show "1.00000", otherwise show "0.50000".
```

**Expected stdout**

```text
0.50000
```

## #1232 · Check If It Is a Straight Line

**Easy · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1232) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1232.html)

```text
The points is a list of 1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 7, and 7. The firstx is item 0 of points. The firsty is item 1 of points. The secondx is item 2 of points. The secondy is item 3 of points. The valid is 1.
For every spot from 1 to 5.
The herex is item (spot times 2) of points. The herey is item (spot times 2 plus 1) of points. The along is (herex minus firstx) times (secondy minus firsty) minus (herey minus firsty) times (secondx minus firstx). If along is not 0, set valid to 0, stop.

If valid is 1, show true, otherwise show false.
```

**Expected stdout**

```text
false
```

## #1233 · Remove Sub-Folders from the Filesystem

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1233) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1233.html)

```text
The folders is a list of "/a", "/a/b", "/c/d", "/c/d/e", and "/c/f". The removed is a list of 5 zeros.
For every left from 0 to the last position of folders.
For every right from 0 to the last position of folders.
The parent is item left of folders. The current is item right of folders. The parentsize is the length of parent. The currentsize is the length of current.
If parentsize is less than currentsize.
The same is 1.
For every index from 0 to parentsize minus 1.
The first is character index of current. The second is character index of parent. If first is not second, set same to 0.
If index is parentsize minus 1 and same is 1.
The edge is character parentsize of current. If edge is "/", set item right of removed to 1.

The kept is an empty list of text.
For every spot from 0 to the last position of folders.
If item spot of removed is 0, Place item spot of folders into kept.

The line is empty text. Place "[" into line.
For every spot from 0 to the last position of kept.
If spot is more than 0, Place "," into line. Place "\"" into line. Place item spot of kept into line. Place "\"" into line.

Place "]" into line. Show line.
```

**Expected stdout**

```text
["/a","/c/d","/c/f"]
```

## #1234 · Replace the Substring for Balanced String

**Medium · String** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1234) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1234.html)

```text
The text is "QQQW". Keep a shared total holding 0, 0, 0, and 0. Keep a shared window holding 0, 0, 0, and 0. Keep a shared target of 0. Keep a shared fit of 0.

To Check. Set fit to 1.
For every kind from 0 to 3.
The outside is item kind of total minus item kind of window. If outside is more than target, set fit to 0.

The size is 0.
For every spot from 0 to the last position of text.
Add 1 to size.

Set target to size divided by 4.
For every spot from 0 to the last position of text.
The symbol is character spot of text. The kind is 0. If symbol is "W", set kind to 1. If symbol is "E", set kind to 2. If symbol is "R", set kind to 3. Increase item kind of total by 1.

The best is size. The left is 0. The right is 0. Check. If fit is 1, set best to 0.
Repeat while right is less than size.
Add 1 to right. The at is right minus 1. The symbol is character at of text. The kind is 0. If symbol is "W", set kind to 1. If symbol is "E", set kind to 2. If symbol is "R", set kind to 3. Increase item kind of window by 1. Check.
Repeat while fit is 1 and left is less than right.
The span is right minus left. If span is less than best, set best to span. The old is character left of text. The oldkind is 0. If old is "W", set oldkind to 1. If old is "E", set oldkind to 2. If old is "R", set oldkind to 3. Decrease item oldkind of window by 1. Add 1 to left. Check.

Show best.
```

**Expected stdout**

```text
2
```

## #1235 · Maximum Profit in Job Scheduling

**Hard · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1235) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1235.html)

```text
Keep a shared begins holding 1, 2, 3, and 3. Keep a shared ends holding 3, 4, 5, and 6. Keep a shared gains holding 50, 10, 40, and 70. Keep a shared best of 0. Keep a shared ready of 0.

To Walk from spot (a whole number) with total (a whole number). If spot is more than the last position of begins and total is more than best, set best to total. If spot is more than the last position of begins, return. Walk from spot plus 1 with total. If item spot of begins is at least ready, Improve from spot with total.

To Improve from spot (a whole number) with total (a whole number). The finish is item spot of ends. The gained is total plus item spot of gains. The old is ready. Set ready to finish. Walk from spot plus 1 with gained. Set ready to old.

Set ready to 0. Walk from 0 with 0. Show best.
```

**Expected stdout**

```text
120
```

## #1238 · Circular Permutation in Binary Representation

**Medium · Math** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1238) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1238.html)

```text
The width is 2. The start is 3. The amount is 1.
For every step from 1 to width.
Set amount to amount times 2.

The line is empty text. Place "[" into line.
For every spot from 0 to amount minus 1.
The shifted is shift spot right by 1. The mixed is exclusive or of spot and shifted. The value is exclusive or of mixed and start. If spot is more than 0, Place "," into line. The piece is format whole number value as text. Place piece into line.

Place "]" into line. Show line.
```

**Expected stdout**

```text
[3,2,0,1]
```

## #1239 · Maximum Length of a Concatenated String with Unique Characters

**Medium · Array** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1239) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1239.html)

```text
Keep a shared words holding "un", "iq", and "ue". Keep a shared alphabet as empty text. Place "abcdefghijklmnopqrstuvwxyz" into alphabet. Keep a shared letter of 0. Keep a shared found of 0. Keep a shared masks as an empty list of whole numbers. Keep a shared usable as an empty list of whole numbers. Place 0 into masks. Place 0 into masks. Place 0 into masks. Place 0 into usable. Place 0 into usable. Place 0 into usable. Keep a shared chosen of 0. Keep a shared best of 0.

To Locate from index (a whole number). If index is more than 25, set found to -1, return. The symbol is character index of alphabet. If symbol is letter, set found to index, return. Locate from index plus 1.

To Weigh from bit (a whole number) with total (a whole number). If bit is more than 25 and total is more than best, set best to total. If bit is more than 25, return. The place is shift 1 left by bit. The overlap is bitwise and of chosen and place. If overlap is more than 0, Weigh from bit plus 1 with total plus 1. If overlap is 0, Weigh from bit plus 1 with total.

To Finish with picked (a whole number). Set chosen to picked. Weigh from 0 with 0.

To Take from spot (a whole number) with picked (a whole number). The mixed is exclusive or of picked and item spot of masks. Gather from spot plus 1 with mixed.

To Try from spot (a whole number) with picked (a whole number). The overlap is bitwise and of picked and item spot of masks. If overlap is 0, Take from spot with picked.

To Gather from spot (a whole number) with picked (a whole number). If spot is more than the last position of words, Finish with picked, return. Gather from spot plus 1 with picked. If item spot of usable is 1, Try from spot with picked.

For every spot from 0 to 2.
Set item spot of masks to 0. Set item spot of usable to 1. The word is item spot of words.
For every index from 0 to the last position of word.
Set letter to character index of word. Locate from 0. The bit is shift 1 left by found. The overlap is bitwise and of item spot of masks and bit. If overlap is more than 0, set item spot of usable to 0, stop. Increase item spot of masks by bit.

Gather from 0 with 0. Show best.
```

**Expected stdout**

```text
4
```

## #1240 · Tiling a Rectangle with the Fewest Squares

**Hard · Backtracking** · [Open in Playground](https://ponvasanthpon.github.io/TransCompilator/#problem=1240) · [Static page](https://ponvasanthpon.github.io/TransCompilator/problems/1240.html)

```text
Keep a shared best of 99. Keep a shared open of 0. Keep a shared masks holding 27, 54, 1, 2, 4, 8, 16, and 32.

To Find from spot (a whole number) with taken (a whole number). If spot is more than 5, set open to -1, return. The bit is shift 1 left by spot. The overlap is bitwise and of taken and bit. If overlap is 0, set open to spot, return. Find from spot plus 1 with taken.

To Cover from filled (a whole number) with used (a whole number). If used is at least best, return. If filled is 63 and used is less than best, set best to used. If filled is 63, return. Find from 0 with filled.
For every place from 0 to 7.
The square is item place of masks. The bit is shift 1 left by open. The covers is bitwise and of square and bit. The hits is bitwise and of filled and square. If covers is more than 0 and hits is 0, Cover from filled plus square with used plus 1.

Cover from 0 with 0. Show best.
```

**Expected stdout**

```text
3
```

[Chunk 19 →](chunk-19.md)
