Skip to content

Instantly share code, notes, and snippets.

View lukasvermeer's full-sized avatar

Lukas Vermeer lukasvermeer

View GitHub Profile
# Simulation to estimate emperical odds to win the Haba game "Boomgaard".
# Set number of games to play
NUM.SIM = 10000
# Simulate one turn. Roll die and pick fruit or move bird.
# Input: game state.
# Output: game state after this turn.
turn <- function(state) {
roll <- sample(1:6,1)
This file has been truncated, but you can view the full file.
's anderendaags
's avonds
's middags
's nachts
's ochtends
's-Gravenhage
's-Hertogenbosch
06-nummer
1 aprilgek
1 aprilgrap
@lukasvermeer
lukasvermeer / circle_flips.jl
Created January 24, 2019 13:33
Simple Julia simulation to solve puzzle posed in https://www.twitter.com/jben0/status/1088146700735139840
# simulation to solve puzzle posed in https://www.twitter.com/jben0/status/1088146700735139840
k = 10
# enumerate all potential combinations of flips
# (also copies first two students to end of the string to fake a circle)
f = map(x->(x^2)[1:k+2],[ bitstring(n)[65-k:64] for n in 0:2^k-1 ])
# condition on at least one student with heads on either side
c = filter(l->size(collect(eachmatch(r"1.1",l)),1)>0,f)