Skip to content

Instantly share code, notes, and snippets.

View natemcintosh's full-sized avatar

Nate McIntosh natemcintosh

  • Centers for Disease Control and Prevention / Center for Forecasting and Outbreak Analytics
  • Toleldo, OH
View GitHub Profile
@natemcintosh
natemcintosh / tic-tac-deal.jl
Created October 10, 2025 15:08
tic-tac-deal
### A Pluto.jl notebook ###
# v0.20.19
using Markdown
using InteractiveUtils
# ╔═╡ 87b56f06-a5e7-11f0-bc5d-fd4c15c7ba48
begin
using Pkg
Pkg.activate(".")
@natemcintosh
natemcintosh / main.rs
Last active September 19, 2025 21:17
Can Your Team Self-Organize?
use itertools::Itertools;
use rayon::prelude::*;
/// For a given list of numbers, try counting all the possible ways of pulling out all
/// possible numbers of elements, see if it is sorted, and if so, collect the one with
/// the maximum length.
fn calc_max_score(nums: &[usize]) -> usize {
// Use the power set to go through all possible combos of all possible elements,
// while retaining the order of the elements
nums.iter()
@natemcintosh
natemcintosh / fiddler_graph_pyramid.jl
Last active May 21, 2025 03:15
Julia solution for paths in a triangular bipyramid
### A Pluto.jl notebook ###
# v0.20.8
using Markdown
using InteractiveUtils
# ╔═╡ 446b951f-049b-441a-a869-03529b1ef965
using Graphs, GraphMakie, CairoMakie
# ╔═╡ fc389c8e-771e-430d-866e-4188cd9d8c3f
### A Pluto.jl notebook ###
# v0.19.46
using Markdown
using InteractiveUtils
# ╔═╡ de87c273-9da1-403f-b0c0-af180e67f743
using Chairmarks
# ╔═╡ 751fe577-314a-43fb-bf79-6d6444642390
### A Pluto.jl notebook ###
# v0.19.29
using Markdown
using InteractiveUtils
# ╔═╡ dff33215-c1f4-47db-bfd1-24de63c9f67d
using Distributions
# ╔═╡ 5d67bf6a-6a9d-11ee-3858-5be18c658ac6
using Combinatorics
using Test
#=
https://thefiddler.substack.com/i/135704603/making-the-rounds
Sixteen chocolates sit in a four-by-four box. Can you remove six from the box so
that an even number is left in each row and each column?
Once you’ve solved it, you can further challenge yourself by counting how many
@natemcintosh
natemcintosh / middle_square_method.jl
Created June 21, 2023 15:27
Solution to a riddler
"""
# [Middle Square Method](https://fivethirtyeight.com/features/can-you-solve-middle-square-madness/)
Thanks to Twitter, I recently became aware of the “middle-square method” for generating
pseudorandom numbers (numbers that appear random, but are derived in a deterministic
sequence).
This week, let's look at the middle-square method for generating pseudorandom four-digit
numbers. First, we start with a four-digit number, such as 9,876. If we square it, we
get the eight-digit number 97,535,376. Our next pseudorandom number is taken from the
from itertools import permutations, pairwise
from pprint import pprint
from typing import Iterable
"""
https://fivethirtyeight.com/features/can-you-turn-digits-into-numbers/
From Jeremy Dixon comes a “toasty” treat of a puzzle:
You have a toast rack with five slots, arranged in an array. Each slot has a slice of
toasted bread, which you are removing one at a time. However, you are quite
@natemcintosh
natemcintosh / basketball.jl
Created January 6, 2023 19:16
Solution for a Riddler Express
using Combinatorics
"""
Riddler Express (https://fivethirtyeight.com/features/can-you-fend-off-the-alien-armada/)
You and a friend are shooting some hoops at your local basketball court when she issues
a challenge: She will name a number, which we'll call N. Your goal is to score exactly N
points in as many ways as possible using only 2-point and 3-point shots. The order of
your shots does not matter.
"""
https://fivethirtyeight.com/features/can-you-make-it-to-2023/
From Dean Ballard comes a puzzle to help us ring in the new year, 2023:
The Fibonacci sequence begins with the numbers 1 and 1,2 with each new term in the
sequence equal to the sum of the preceding two. The first few numbers of the Fibonacci
sequence are 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 and so on.
One can also make variations of the Fibonacci sequence by starting with a different pair