Created
July 4, 2022 13:57
-
-
Save Syncrossus/ddbabb9f31e0ea31125060891c85eae7 to your computer and use it in GitHub Desktop.
This file contains 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
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