Skip to content

Instantly share code, notes, and snippets.

View ajm188's full-sized avatar

Andrew Mason ajm188

View GitHub Profile
@brenns10
brenns10 / alphabet.py
Created November 18, 2015 20:08
Determine Ordering of Alphabet
"""
Code to return the alphabet in which a list of words is sorted.
Imagine that you are given a list of words (eg: best friends forever), along
with the claim that these words are lexicographically sorted for *some*
alphabet. Your job is to determine whether this is true, and if it is, return
an example of such an alphabet.
This module implements an algorithm to solve this problem. It creates a graph
of dependencies between letters, performs a topological sort, and then returns
@brenns10
brenns10 / gambler.py
Last active October 16, 2015 12:06
Gambling Chip Algorithm
"""
Finds optimal strategy for gambling chip game.
Problem: two players (Alice and Bob) play a game where gambling chips (with
numeric values) are laid out in a line. They alternate turns. During their
turn, a player picks up a chip on either end of the line, but not from anywhere
in the middle, and adds that chip to their collection. At the end, the player
with the higher valued collection of chips wins.
This is a dynamic programming algorithm for solving the problem. It runs in
@holman
holman / BRAINSTORMING.md
Created December 9, 2014 22:29
Examples you could use in order to better explain your programming language inheritance and OOP syntax instead of using cars, animals, and shapes.
  • Cats, as defined by how important they were as plot devices (the cat from The Matrix would inherit from ImportantCat, whereas the cat from Boondock Saints would inherit from DeadCat)
  • Batman (primarily as a way to describe situations in which a child has no parents)
  • Presidents of the United States (Nixon vs Cheney vs Garfield)
  • Zombies (Walking Dead vs World War Z vs Zombieland)
  • Zombie Presidents of the United States
  • Children in television shows, as grouped by whether they actually did cause their parents' separation
  • Radioactive attack squirrels bent on global hegemony, beamed down to Earth from the mirror universe USS Enterprise
  • George Carlins by decade
  • Cocaine
  • Metropolises, cities, towns, villages, and Detroits
@aras-p
aras-p / preprocessor_fun.h
Last active July 16, 2024 02:50
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,