Skip to content

Instantly share code, notes, and snippets.

@morgan9e
Created April 15, 2024 13:04
Show Gist options
  • Save morgan9e/d6b44b5f3f858a923ba79c890dc24b4e to your computer and use it in GitHub Desktop.
Save morgan9e/d6b44b5f3f858a923ba79c890dc24b4e to your computer and use it in GitHub Desktop.
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