@coriander my superpower in education was that i tested very well.
god made sure i never experienced test anxiety, but at the cost making sure i had anxiety in absolutely everything else
I encountered a fun coding challenge while programming today.
Suppose you are teaching a class and you brought with yourself a bag of candy to hand out to your students. You want to hand out every piece of candy, but do it in a way that disperses the candy provided to each student as evenly as possible. No student should have more than 1 extra piece of candy than any other student. Exactly which students get the extra pieces of candy does not matter.
Task: Write a function that takes N students and M pieces of candy, where M > N, and returns an array of length N showing the amount candy given to each student.
Followup Task: Generate this array in O(N) time, where N is the number of students (NOT the amount of candy!)
I stitched two scripts together using python and it was weirdly annoying to do, when in bash it would have just been a simple one-liner with a command substitution
fine, i'll do it myself:
import matplotlib.pyplot as plt
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)
import csv
import math
y_star = [0]
y_ancient = [0]
x = [0]
with open('./output/1-plant-125-casks-448-days-1-sim.csv', mode='r') as file:
reader = csv.reader(file, delimiter=',')
for day, ancient, star in reader:
x.append(int(day))
y_ancient.append(int(ancient))
y_star.append(int(star))
_, ax = plt.subplots()
ax.plot(x, y_ancient)
ax.plot(x, y_star)
ax.set(xlabel='days since initial planting', ylabel='profit (g)',
title='Ancient Fruit vs Star Fruit profits')
ax.grid()
ax.xaxis.set_major_locator(MultipleLocator(112))
ax.xaxis.set_minor_locator(MultipleLocator(28))
ax.yaxis.set_major_locator(MultipleLocator(math.floor(max(y_ancient) / 10)))
plt.show()
the clodvestigator
i go by Clodsire, Clodboy and Bumby.
videogame enjoyer. mathematics hobbyist and recovering physicist. software engineer. professional wonk. prophet of The Truth. the walking embodiment of "not diagnosed, but somethings wrong". i like animals that wear cowboy hats.
number of fat cock awards received: 56
header is by @vaporeon_
"i regret ever allowing him here" ~aescling
"oh you're one of those weird movie likers" ~Ti
"the thing you need to understand about @wallhackio is that he is utterly sick in the head. this is partially a compliment. but not entirely" ~aescling
30+
he/him