Created
November 6, 2025 22:00
-
-
Save Shaddyjr/50dc24416c81ab1c49289aaa4ff07b93 to your computer and use it in GitHub Desktop.
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
| # Problem: https://www.hackerrank.com/challenges/alphabet-rangoli/problem? | |
| # YouTube: https://youtu.be/ZJsyQTEeiYI | |
| # char a as Unicode code | |
| start = 97 # 'a' | |
| def print_rangoli(size): | |
| lines = [] | |
| for i in range(size): | |
| line = create_line(start + i, size - i, size) | |
| lines.append(line) | |
| all_lines = lines[::-1] + lines[1:] | |
| for line in all_lines: | |
| print(line) | |
| def create_line(start_char_int, size, max_size): | |
| base_char_list = [chr(start_char_int + i) for i in range(size)] | |
| base_char_list += ['-'] * (max_size - size) | |
| full_char_list = base_char_list[::-1] + base_char_list[1:] | |
| return '-'.join(full_char_list) | |
| if __name__ == '__main__': | |
| n = int(input()) | |
| print_rangoli(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment