Skip to content

Instantly share code, notes, and snippets.

@Syncrossus
Created July 4, 2022 13:57
Show Gist options
  • Save Syncrossus/ddbabb9f31e0ea31125060891c85eae7 to your computer and use it in GitHub Desktop.
Save Syncrossus/ddbabb9f31e0ea31125060891c85eae7 to your computer and use it in GitHub Desktop.
def histogram(in_list):
hist = [[0] * len(in_list) for _ in range(max(in_list))]
for i in range(len(hist)):
for j, val in enumerate(in_list):
if val > i:
hist[i][j] = 1
out_str = ''
for subl in hist[::-1]:
for val in subl:
if val:
out_str += '|'
else:
out_str += ' '
out_str += '\n'
print(out_str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment