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
from collections import defaultdict | |
def load_words(filename='/usr/share/dict/american-english'): | |
with open(filename) as f: | |
for word in f: | |
yield word.rstrip() | |
def get_anagrams(source): | |
d = defaultdict(list) | |
for word in source: |
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
require 'open-uri' | |
require 'nokogiri' | |
require 'mechanize' | |
require 'csv' | |
def scrape(row) | |
puts '_________start_________' | |
mechanize = Mechanize.new | |
page = mechanize.get('http://www.aircraftbluebook.com/Tools/HVR/Calculate.do') | |
# find login form and add credentials |
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
""" | |
make the loop go through each character in the text, | |
and see if you've got a palindrome when extending with the left and right character of your current character. | |
This way you'll stop checking when it's not a palindrome and don't waste time checking non-palindromes. | |
""" | |
DEFAULT_TEXT = "racecarenterelephantmalayalam" | |
def all_palindromes(text=DEFAULT_TEXT): |
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
""" | |
short coding test to take a list of movies and | |
their year and rturn the most popular decade | |
""" | |
def movies(): | |
frequency_of_decade = { | |
'1900': 0, |
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
""" | |
Our robots are always working to improve their linguistic skills. For this mission, they research the latin alphabet and its applications. | |
The alphabet contains both vowel and consonant letters (yes, we divide the letters). | |
Vowels -- A E I O U Y | |
Consonants -- B C D F G H J K L M N P Q R S T V W X Z | |
You are given a block of text with different words. These words are separated by white-spaces and punctuation marks. Numbers are not considered words in this mission (a mix of letters and digits is not a word either). You should count the number of words (striped words) where the vowels with consonants are alternating, that is; words that you count cannot have two consecutive vowels or consonants. The words consisting of a single letter are not striped -- do not count those. Casing is not significant for this mission. | |
""" | |
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
def checkio(text): | |
text = text.lower() | |
check_list = sorted(set(text)) | |
store_no = 0 | |
store_letter = '' | |
for letter in check_list: | |
if letter.isalpha(): | |
ans = text.count(letter) | |
if ans > store_no : | |
store_letter = letter |
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
def checkio(number): | |
counter =0 | |
ans = str(bin(number)) | |
for num in ans: | |
if num == '1': | |
counter+=1 | |
return counter | |
#These "asserts" using only for self-checking and not necessary for auto-testing | |
if __name__ == '__main__': |
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
t0= time.clock() | |
do_something() | |
t= time.clock() - t0 # t is wall seconds elapsed (floating point) |
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 FileEntity | |
{ | |
// members common to File & Folder | |
// create, copy, delete, move, getInfo, open, etc | |
}; | |
class Folder : public FileEntity | |
{ | |
// a folder can have multiple FileEntity (folders or files) | |
vector<FileEntity> m_VecFileEntity; |
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 CNode: | |
left , right, data = None, None, 0 | |
def __init__(self, data): | |
# initializes the data members | |
self.left = None | |
self.right = None | |
self.data = data |
NewerOlder