Skip to content

Instantly share code, notes, and snippets.

View chrismilson's full-sized avatar

Chris Milson-Tokunaga chrismilson

  • In Transit
View GitHub Profile
@chrismilson
chrismilson / README.md
Last active April 11, 2020 01:06
Matt Parker's Maths Puzzles - 3 - Scrabble

Scrabble Puzzle

Problem:

In a game of Scrabble™, how many distinct sets of 7 tiles are worth 46 points?

This puzzle is the third of its kind from Matt Parker's Maths Puzzles.

@chrismilson
chrismilson / README.md
Last active April 16, 2020 05:29
Matt Parker's Card Flip Game

This is based on Matt Parker's Youtube Video

Card Flip Game

The card flip game is played by two players.

The first player will place n (usually four) cards face down in a row and then flip some of the cards face up.

The second player will now attempt to flip individual cards in order to make all

@chrismilson
chrismilson / README.md
Last active May 19, 2020 03:57
Million Dollar Bank Prize - MPMP

This problem is from the series of Matt Parker's Maths Puzzles and the video

Million Pound Bank Prize

A bank is offering a promotion! Patrons are able to open an account and make a single deposit on the first and second days. Each day the account earns the previous day's balance in interest. The bank stipulates that if the account ever holds exaclty one million pounds then the account holder will be able to withdraw the one million pounds. In order to reduce risk the bank adds a clause

@chrismilson
chrismilson / README.md
Last active February 3, 2021 00:22
Numbers to Words

Numbers to Words

demo

I am currently an English teacher at some schools in Japan and recently my students have been learning how to write the numbers in words in English. For example, if they were given the number 12 they are learning to write 'twelve'.

One of the questions I set the students was to find the number with the longest length (in characters; 4 would be bigger than 10 because four has more

@chrismilson
chrismilson / PAPER_FOLDING.md
Last active June 12, 2020 08:24
Folding Puzzle

This puzzle is part of the Matt Parker's Maths Puzzles series.

Paper Folding

Given a piece of paper with eight marked out regions:

 _______________
| | | | |
@chrismilson
chrismilson / Board.py
Last active July 10, 2020 05:55
MPMP10 - Avoid the Square
class Board:
def __init__(self, n):
self.n = n
self.tiles = [x[:] for x in [[' '] * n] * n]
def __getitem__(self, point):
return self.tiles[point.x][point.y]
def __setitem__(self, point, value):
self.tiles[point.x][point.y] = value
@chrismilson
chrismilson / Chromosome.py
Created July 22, 2020 03:37
My first genetic algorithm
from random import random
def countBits(num):
result = 0
while num:
result += 1
num &= num - 1
return result
def likelihood(probability):
@chrismilson
chrismilson / david-and-anton.md
Last active July 27, 2020 02:19
David and Anton Puzzle - MPMP11

This puzzle is the eleventh puzzle from the Matt Parker's Maths Puzzles series.

David And Anton

David and Anton's ages combined equals 65. David is currently three times as old as Anton was when David was half as old as Anton will be when Anton is three times as old as David was when David was three times as old as Anton.

How old is David?

@chrismilson
chrismilson / green-bananas.md
Created July 31, 2020 06:42
An inspirational story

Green Bananas

When I was younger i had a great friend, Little Johnny. He was a very good boy. He woke up every morning at six sharp and promptly had a shower, ate his breakfast, and brushed his teeth before either leaving for school, or starting a shift in his mother's bakery on the weekends.

On one particular day at school the teacher annouced that we were going to have no more than two weeks to write speeches, which we would then have to present in front of the rest of the class. Johnny was stumped. He had absolutely

@chrismilson
chrismilson / Power-of-a-Power.md
Last active August 6, 2020 01:33
Interview Question

Power of a Power

Write a program to determine whether a number, n, is a power of 2k.

clarification: n, k ≥ 0

Follow up: Can you do it with O(1) time and space complexity?

Examples