CODINGAME: TABLE OF CONTENTS
You are writing a book, and the table of contents is the only thing left to do. Sadly, the necessary packages are not working well, so you will have to implement one yourself.
EXPLANATION CODE:
1) First, the program takes input from the user for the length of the line and the number of titles. Then, it creates an empty list called titleList to store the titles and their page numbers.
2) Next, the program reads in each title and page number, splits them on the space character, and adds them as a sub-list to titleList.
3) After this, the program loops over each title in titleList. For each title, it generates a table of contents line based on the number of greater than characters in the title
4) The number of greater than characters in the title is counted using the count() method, and this number is stored in the counter variable. The titles list keeps track of how many titles have been seen at each level of indentation so that the table of contents can be generated correctly.
5) If there are counter greater than characters, the program sets the titles[counter] value to 0 to reset the count of titles at that level of indentation.
6) Next, the program increments the titles[counter] value to count the current title at that level of indentation.
7) After that, the program generates the table of contents line by adding counter times 4 spaces (to match the level of indentation), then the current titles[counter] value, the title text (with all greater than characters removed), enough dots to fill up the rest of the line to lengthofline, and finally the page number for the current title.
8) Finally, the program prints the completed table of contents line.
Contents:
0:00 - Reading
1:55 - Solving
9:31 - Explaining
#codingame #coding #game #programming #easy #difficulty #reading #arithmetic #python #pythonprogramming #learntocode #tutorial #education #problemsolving #algorithmic #asmr #asmrtyping #table #of #contents #strings #parsing
Other Videos By One Person Studio
2023-04-16 | BATMAN #shorts #art #drawing |
2023-04-16 | GON #shorts #art #drawing |
2023-04-16 | SIMPLE GAME |
2023-04-16 | HULK #shorts #art #drawing |
2023-04-16 | T.T.T.32: COUNT WITH YOUR FINGERS |
2023-04-16 | SKETCHBOOK TOUR PART C (100) #shorts #art #drawing |
2023-04-15 | ALIEN II #shorts #unrealengine #animation |
2023-04-15 | SYLVEON #shorts #art #drawing |
2023-04-15 | KAKASHI SENSEI #shorts #art #drawing |
2023-04-15 | KAZUMA SATOU #shorts #art #drawing |
2023-04-15 | CODINGAME: TABLE OF CONTENTS |
2023-04-14 | BORUTO #shorts #art #drawing |
2023-04-14 | FOXY #shorts #art #drawing |
2023-04-14 | MINI MAX SUM |
2023-04-14 | JUSTIN BIEBER #shorts #art #drawing |
2023-04-14 | STAIRCASE |
2023-04-14 | ALIEN #shorts #unrealengine #animation |
2023-04-13 | EDWARD ELRIC #shorts #art #drawing |
2023-04-13 | MICKEY MOUSE #shorts #art #drawing |
2023-04-13 | SQUIRTLE #shorts #art #drawing |
2023-04-13 | PALINDROME NUMBER |