Skip to content

Instantly share code, notes, and snippets.

@napratin
napratin / perm.py
Last active January 2, 2016 10:39
Permutations in Python
def permutations(s):
"""Return all permutations of the characters in a string."""
res = []
for i in xrange(len(s)):
c = s[i]
rem = s[:i] + s[i+1:]
if rem:
temp = permutations(rem)
res += [c + t for t in temp]
else:
@napratin
napratin / AIND-Warmup-Problems.md
Last active September 27, 2018 21:13
AIND Warmup Problems

AIND Warmup Problems

Wheel of Chance

Wheel of Chance

In this game of chance, we have a wheel divided into 8 equal sectors or pie slices. 4 of them are marked $200, 3 are $500 and 1 is $1000.

It costs you $100 to place a bet on any one of the unique numbers on the wheel, and spin once. If the wheel stops with the arrow pointing at the number you chose, you win that amount plus your $100 back, otherwise you lose your bet.