I've implemented a greedy algorithm that simulates every voter in the office being able to vote for any combination of options A, B, or C. By adding voters until the percentages are reached, we can find the least number of voters possible.
import numpy as np | |
import matplotlib.pyplot as plt | |
# Note that each inning is independent, so we only need to simulate one inning at a time | |
moonwalkers = { | |
'name': "Mississippi Moonwalkers", | |
'color': 'blue', |
Late night quick coding challenge. Read in all the pixels of the scrambled images, rudimentarily sort them, and then send them back out as images. This will give you a much better idea of what colors you are actually looking at, and can eyeball what the answers might be.
Code runs on both png and gif filetypes, so you can just download the images and go!
def get_chance_of_better_than_next_on_next_roll(num): | |
# this is a sliding scale | |
return (42 - num - 1) / 100 | |
def get_prob(num): | |
if num == 41: | |
return 0 | |
prob = get_chance_of_better_than_next_on_next_roll(num) | |
return prob + ((1 - prob) * get_prob(num +1)) |
stay_value 0.377298 | |
switch_value 0.500682 | |
dtype: float64 |
From Austin Shapiro comes a story of stacking that may stump you:
Mira has a toy with five rings of different diameters and a tapered column. Each ring has a “correct” position on the column, from the largest ring that fits snugly at the bottom to the smallest ring that fits snugly at the top.
Each ring she places will slide down to its correct position, if possible. Otherwise, it will rest on what was previously the topmost ring.
>For example, if Mira stacks the smallest ring first, then she cannot stack any more rings on top. But if she stacks the second-smallest ring first, then she can stack any one of the remaining four rings above it, after which she cannot stack any more rings.