Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 -*- | |
#!usr/bin/env python | |
# Excersise 5.7 | |
""" | |
Let A be an array of size n ≥ 2 containing integers from 1 to n − 1, inclu- sive, with exactly one repeated. Describe a fast algorithm for finding the integer in A that is repeated. | |
""" | |
import random |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
#!/usr/bin/env python | |
import time | |
def coroutine(): | |
try: | |
print "Executing" | |
seconds = (yield) | |
time.sleep(seconds) |
This file contains 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
class NamedAndCachedAttributeType(type): | |
''' | |
In cases, where getting an attribute will | |
expose to the client code the detail of | |
the very attribute name, which could be changeable | |
over time. | |
This NamedAndCachedAttributeType is intended to | |
hide this detail by mapping the public attribute name | |
to the real name that is maintained internally by the class itself. | |
By doing so, the content provider(this class) and the client |
This file contains 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
#!/usr/bin/env python | |
def remove_a(values): | |
for value in values: | |
new_value = value.replace('a', '') | |
print 'remove a' | |
yield new_value | |
def remove_b(values): | |
for value in values: |
This file contains 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
#!/usr/bin/env python | |
# Added by <[email protected]> | |
import sys | |
import os | |
from multiprocessing import connection | |
ADDR = ('', 9997) | |
AUTH_KEY = '12345' |