Created
April 15, 2024 13:04
-
-
Save morganabc/d6b44b5f3f858a923ba79c890dc24b4e 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
import os | |
def plot(data, row=30): | |
buf = "" | |
tb, M = [], max(data) | |
for i in data: | |
tb.append(int(row*i/M)) | |
rows = [[] for _ in range(max(tb))] | |
for p, i in enumerate(rows): | |
for n, j in enumerate(tb): | |
if j > p: i.append(n) | |
for i in reversed(rows): | |
buf += "".join(["*" if k in i else " " for k in range(len(tb))]) + "\n" | |
buf += "^"*len(tb) | |
print(buf) | |
import random | |
A = [0 for _ in range(101)] | |
for i in range(2**800): | |
val = sum([ random.randint(0,i) for i in [1,1,1,1,1,2,3,4,6,10,25,45] ]) | |
A[val] += 1 | |
if not(i%5000): | |
plot(A) | |
print(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment