We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
now we know the number of rows(r=7) and columns(c=8)
what sm[i::c] means is start from sm[i] to end of sm print every character with indices i,i+c,i+2c,i+3c... till the end. After that add " ". so let's take i=0 for example that means print characters with indices 0,8,16,24,32,40,48 (till you reach the end of sm). so here it is "imtgdvs" then add " ". Same goes on on till you are done with all the columns.
i hope this helps!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Encryption
You are viewing a single comment's thread. Return to all comments →
okay. lets take example that is given in question.
input: if man was meant to stay on the ground god would have given us roots
sm=ifmanwasmeanttostayonthegroundgodwouldhavegivenusroots
now we know the number of rows(r=7) and columns(c=8)
what sm[i::c] means is start from sm[i] to end of sm print every character with indices i,i+c,i+2c,i+3c... till the end. After that add " ". so let's take i=0 for example that means print characters with indices 0,8,16,24,32,40,48 (till you reach the end of sm). so here it is "imtgdvs" then add " ". Same goes on on till you are done with all the columns.
i hope this helps!