filmov
tv
ASCII ART

Показать описание
I learned how to manage strings and array arithmetic by completing this puzzle. I understood how to partition a string into pieces and then concatenate those parts to create a new string.
By the end of this puzzle, my program must show a line of ASCII graphics as text.
EXPLANATION OF CODE:
1) The user's input is retrieved in the code's first two lines. The first line specifically returns the width of each letter in the banner as an integer number called l. Another integer number named h, which denotes the height of each letter in the banner, is retrieved in the second line.
2) The third line retrieves a string of text from the user and converts it to uppercase using the upper() method.
3) The user's input for h lines is retrieved in the fourth line and stored in a list called row.
4) Each character is iterated over and printed using the two for loops. The outer for loop iterates through each row, while the inner for loop iterates through each character in the input string.
5) Each character in the input string is transformed to its ASCII code inside the inner for loop using the ord() method. If the character is an alphabetic character, the ASCII value is subtracted from 65 to obtain the character's index in the alphabet (for example, the letter "A" has an ASCII code of 65, hence its index is 0). The code sets the index to 26 if the character is not an alphabetic character.
6) According to the current character in the input string, the code then prints out a portion of each row. To be more precise, the code calculates the starting and ending indices of the segment of each row that corresponds to the current character, then prints out that section. The print function call's end = " option is used to stop the function from adding a new line character automatically at the end of each line.
#codingame #asciiart #python #strings #arrays #arithmetic #puzzle #easy #programming #text #loops
By the end of this puzzle, my program must show a line of ASCII graphics as text.
EXPLANATION OF CODE:
1) The user's input is retrieved in the code's first two lines. The first line specifically returns the width of each letter in the banner as an integer number called l. Another integer number named h, which denotes the height of each letter in the banner, is retrieved in the second line.
2) The third line retrieves a string of text from the user and converts it to uppercase using the upper() method.
3) The user's input for h lines is retrieved in the fourth line and stored in a list called row.
4) Each character is iterated over and printed using the two for loops. The outer for loop iterates through each row, while the inner for loop iterates through each character in the input string.
5) Each character in the input string is transformed to its ASCII code inside the inner for loop using the ord() method. If the character is an alphabetic character, the ASCII value is subtracted from 65 to obtain the character's index in the alphabet (for example, the letter "A" has an ASCII code of 65, hence its index is 0). The code sets the index to 26 if the character is not an alphabetic character.
6) According to the current character in the input string, the code then prints out a portion of each row. To be more precise, the code calculates the starting and ending indices of the segment of each row that corresponds to the current character, then prints out that section. The print function call's end = " option is used to stop the function from adding a new line character automatically at the end of each line.
#codingame #asciiart #python #strings #arrays #arithmetic #puzzle #easy #programming #text #loops