"""Yield successive n-sized chunks from l.""" Let's add this chunker: def chunks(l, n): However, instead of that, if you did all the chunking up front, that would make your algorithm simpler. Right now, each of your ascii_rows is the full row, and you grab the appropriate chunk as you go. That lets you avoid the found: for character in text_source:īreak # no reason to keep checking anything Next, when you're looping until you find something, and having a check if you do, you can use a for. That shortens us to: for character in text_source: Whenever you find yourself needed the index of an element and the element, use enumerate(). I didn't adhere strictly to the naming given by the assignment, since the program checking the code doesn't care anyway. And the naming probably could've been better. There's a lot of looping going around, which is probably a bad thing. My code scores 100% (which only means it's bug free for all cases ran), but it feels like it could've been more succinct. It's a programming-challenge, so the usual input validation, argument handling and over engineering was skipped. The characters which are not in the intervals or will be shown as a question mark in ASCII art.Ġ `' < | || | \ \/ / | || |. The characters a to z are shown in ASCII art by their equivalent in upper case. Line 3: The line of text T, composed of N ASCII characters.įollowing Lines: the string of characters ABCDEFGHIJKLMNOPQRSTUVWXYZ? Represented in ASCII art. Line 2: the height H of a letter represented in ASCII art. Line 1: the width L of a letter represented in ASCII art. Your mission is to write a program that can display a line of text in ASCII art. For example, the word "MANHATTAN" could be displayed as follows in ASCII art: # To be precise, in our case, these forms are words. I'll describe one of them.ĪSCII art allows you to represent forms by using characters. Today I stumbled upon CodinGame, a site with programming challenges.
0 Comments
Leave a Reply. |