79208170

Date: 2024-11-20 16:42:08
Score: 0.5
Natty:
Report link

Let's see how to achieve the proposed result:

def pattern( char1, char2, n ):
     # first we save the base pattern 
    out =  char1 + char2 
    for i in range( n ):
         # in each iteration, we add to it its inverted version
        out += invert( out )
    return out
    
def invert( char ):
    out = ""
    for i in range( len( char )):
         # only in the odd numbers we add to **out** the reversed items
        if i % 2 != 0:
            out +=  char[ i ] + char[ i - 1 ]
    return out
Reasons:
  • Blacklisted phrase (1): how to achieve
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Marce Puente