The TransCompilator

Solved LeetCode program · 43 of 1,000

#0043 · Multiply Strings

Medium String chunk-01.md

Original English source

The first is "123". The second is "456". The lastfirst is the last position of first. The lastsecond is the last position of second. The firstdigits is an empty list of whole numbers. The seconddigits is an empty list of whole numbers.
For every position from 0 to lastfirst.
The at is lastfirst minus position. The digit is the digit value of character at of first. Place digit into firstdigits.

For every position from 0 to lastsecond.
The at is lastsecond minus position. The digit is the digit value of character at of second. Place digit into seconddigits.

The total is lastfirst plus lastsecond plus 2. The result is a list of total zeros.
For every left from 0 to lastfirst.
For every right from 0 to lastsecond.
The product is item left of firstdigits times item right of seconddigits. The index is left plus right. The sum is item index of result plus product. Set item index of result to sum modulo 10. Increase item (index plus 1) of result by sum divided by 10.

The resultlast is total minus 1. The output is empty text. The started is 0.
For every step from 0 to resultlast.
The at is resultlast minus step. The digit is item at of result.
If digit is more than 0 or started is 1 or step is resultlast.
Place the character for digit into output. Set started to 1.

Display output.

Open in Playground Browse all 1,000 problems

Expected stdout

56088