This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def once(s): | |
"command_prefixes is a list of prefixes" | |
if s not in env.command_prefixes: | |
return s | |
return 'true' | |
@contextlib.contextmanager | |
def mycd(dir): | |
with prefix(once('cd %s' % dir)): | |
yield |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
1) A string is a palindrome if it reads the same from left-to-right as it does right-to-left. | |
e.g “nolemonnomelon”, “racecar” & “neveroddoreven” are all palindromes. | |
A string is an anagram of another string if it consists of exactly the same characters but in another order. | |
e.g The string “carrace” is an anagram of “racecar”. | |
Write a function `def is_anagram_of_palindrome(str):` | |
such that it returns True if the string str is an anagram of a palindrome, and otherwise returns False. | |
You may assume that str contains only lowercase characters a-z and is not empty. | |
e.g Given str = “carrace” the function should return True as it is an anagram of the palindrome “racecar”. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
import sys | |
import math | |
import random | |
# http://www.spotify.com/us/jobs/tech/ticket-lottery/ | |
def bc(n, k, f=math.factorial): | |
"""Binomial coefficient in terms of Factorials | |
(n) = ____n!____ |
NewerOlder