Created
May 5, 2026 02:58
-
-
Save adityashah1603/77c0aec2cc723d3dafa5c9437d95ebba to your computer and use it in GitHub Desktop.
Polka Dots Avantos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This takes input txt file for the ascii pattern | |
| import sys | |
| def compute_polkadot_score(ascii_art): | |
| lines = ascii_art.split('\n') | |
| # 1. Find lips x-range: ('''''' ®'''''''') | |
| # No ' , or - in lips → boundary chars are ( and ) | |
| lips_start = lips_end = -1 | |
| for line in lines: | |
| idx = line.find("(''''''") | |
| if idx != -1: | |
| lips_start = idx | |
| lips_end = line.find("'''''''')", idx) + 8 | |
| break | |
| # 2. Pupils: the two • on the face line "• ; •" | |
| # Explicitly 2 chars (one per eye) | |
| num_pupil_chars = 2 | |
| # 3. Count O polkadots on the dress (lines >= 18) | |
| DRESS_START = 18 | |
| inside = outside = 0 | |
| for line in lines[DRESS_START:]: | |
| for col, ch in enumerate(line): | |
| if ch == 'O': | |
| if lips_start <= col <= lips_end: | |
| inside += 1 | |
| else: | |
| outside += 1 | |
| # 4. Score | |
| score = outside + inside * num_pupil_chars | |
| print(f"Lips range : cols {lips_start}-{lips_end}") | |
| print(f"Pupil chars : {num_pupil_chars}") | |
| print(f"O dots inside : {inside}") | |
| print(f"O dots outside: {outside}") | |
| print(f"Score : {outside} + ({inside} x {num_pupil_chars}) = {score}") | |
| return score | |
| if __name__ == "__main__": | |
| if len(sys.argv) != 2: | |
| print("Usage: python3 compute_polkadot_score.py <input.txt>") | |
| sys.exit(1) | |
| with open(sys.argv[1], encoding='utf-8') as f: | |
| art = f.read() | |
| compute_polkadot_score(art) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment