The point of the for loop is to create the next row of the triangle by comparing every two adjacent characters.
The next row is stored in the variable reduced. In the 4th line two consecutive characters are compared, and if
they are the same, that character is added to reduced. If they are different, both are removed form the string 'RGB',
and the remaining character is added to reduced. Let's say row[i] = 'R' and row[i+1] = 'B'. First, 'RGB'.replace(row[i], '')
will return 'GB'. The second replace method will be called on 'GB'. It will replace 'B' with nothing and return 'G'.
Wow, i aim for this level of skill
Great
Hey, thanks gotcha! If i'm not wrong this is an example of recursion.
The point of the for loop is to create the next row of the triangle by comparing every two adjacent characters.
The next row is stored in the variable reduced. In the 4th line two consecutive characters are compared, and if
they are the same, that character is added to reduced. If they are different, both are removed form the string 'RGB',
and the remaining character is added to reduced. Let's say row[i] = 'R' and row[i+1] = 'B'. First, 'RGB'.replace(row[i], '')
will return 'GB'. The second replace method will be called on 'GB'. It will replace 'B' with nothing and return 'G'.
Can somebody explain, what is happening in line number 4 , 'RGB'.replace(row[i], '').replace(row[i+1], '');