Skip to content

Instantly share code, notes, and snippets.

@Shaddyjr
Created November 6, 2025 22:00
Show Gist options
  • Save Shaddyjr/50dc24416c81ab1c49289aaa4ff07b93 to your computer and use it in GitHub Desktop.
Save Shaddyjr/50dc24416c81ab1c49289aaa4ff07b93 to your computer and use it in GitHub Desktop.
# 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