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 datetime import datetime | |
import csv | |
label = """ | |
@relation whatever | |
@attribute AGE numeric | |
@attribute GENDER {M,F} | |
@attribute HOSPITAL string | |
@attribute DIAGNOSISCODE string | |
@attribute DATEOFADM date "yyyy-MM-dd HH:mm:ss" |
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 datetime import datetime | |
import csv | |
cpi = {} | |
cpi['2012'] = 1.09 | |
cpi['2011'] = 1.043 | |
cpi['2010'] = 1.019 | |
cpi['2009'] = 1 | |
cpi['2008'] = 0.98 | |
cpi['2007'] = 0.929 |
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
import unittest | |
class SampleTestCase(unittest.TestCase): | |
def __init__(self, *args, **kwargs): | |
self.account_id = kwargs['account_id'] | |
del kwargs['account_id'] | |
super(SampleTestCase, self).__init__(*args, **kwargs) | |
def test_a(self): |
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 find_second_largest(arr): | |
if len(arr) < 2: | |
return None | |
largest = max(arr[0], arr[1]) | |
sec_largest = min(arr[0], arr[1]) | |
for item in arr[2:]: | |
if item > largest: | |
sec_largest = largest | |
largest = item | |
elif item <= largest and item > sec_largest: |
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
''' | |
Notes about this problem: | |
- Try to analyze the formation of the result & a way to construct it | |
''' | |
M = [[1, 2, 3], | |
[4, 5, 6], | |
[7, 8, 9]] | |
def mat_diagonal(M): |
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
# Enter your code here. Read input from STDIN. Print output to STDOUT | |
import sys | |
import fileinput | |
input = fileinput.input() | |
s1 = input[0].replace('\n', '') | |
s2 = input[1].replace('\n', '') | |
dict_s1 = {} | |
dict_s2 = {} | |
# Gather character dictionary of the two strings |
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
import sys | |
test_cases = open(sys.argv[1], 'r') | |
bst = { | |
'datum': 30, | |
'left': { | |
'datum': 8, | |
'left': { | |
'datum': 3, | |
'left': None, |
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
import sys | |
test_cases = open(sys.argv[1], 'r') | |
def generate_char_dict(str): | |
char_dict = {} | |
for c in str: | |
char_dict[c] = char_dict.get(c, 0) + 1 | |
return char_dict | |
def LCS(strA, strB): |
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
import sys | |
test_cases = open(sys.argv[1], 'r') | |
def eval_postfix(exp): | |
stack = [] | |
for i in exp: | |
try: | |
val = int(i) | |
stack.append(val) | |
except: |
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
import sys | |
import pprint | |
test_cases = open(sys.argv[1], 'r') | |
for test in test_cases: | |
str_val = test.replace('\n', '') | |
n,p = [int(k) for k in str_val.split(' ')] | |
res = {} |
OlderNewer