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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"log" | |
"os" | |
"unicode" | |
) |
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 | |
import sys | |
def age_distribution(age): | |
""" | |
If they're from 0 to 2 the child should be with parents print : 'Still in Mama's arms' | |
If they're 3 or 4 and should be in preschool print : 'Preschool Maniac' | |
If they're from 5 to 11 and should be in elementary school print : 'Elementary school' | |
From 12 to 14: 'Middle school' |
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 | |
import sys | |
def main(): | |
with open(sys.argv[1], "r") as f: | |
for line in f: | |
upper_flg = True | |
for s in line: | |
if s.isalpha(): |
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 | |
import sys | |
def convert1(s): | |
elements = s.split(" ") | |
b = [] | |
for flag, seq in zip(*[iter(elements)] * 2): | |
if flag == "0": |
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 | |
import sys | |
def main(): | |
with open(sys.argv[1], "r") as f: | |
for line in f: | |
lower_count = 0 | |
upper_count = 0 | |
for c in line.rstrip(): |
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 | |
import sys | |
def find_lost(l): | |
l = sorted(l, key=lambda x: int(x)) | |
for i, hint in enumerate(l): | |
if hint != str(i + 1): | |
return str(i + 1) | |
return str(len(l) + 1) |
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 | |
import queue | |
import sys | |
import time | |
class Time(object): | |
def __init__(self, epoch, start=True): | |
self.epoch = epoch | |
self.start = start |
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 | |
import sys | |
PASSING_TYPE_STRAIGHT = '|' | |
PASSING_TYPE_LEFT_TURN = '\\' | |
PASSING_TYPE_RIGHT_TURN = '/' | |
ROAD_TYPE_GATE = '_' | |
ROAD_TYPE_CHECKPOINT = 'C' |
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 | |
import sys | |
def major_element(elements): | |
m = dict() | |
for e in elements: | |
m.setdefault(e, 0) | |
m[e] += 1 |
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 | |
import sys | |
import re | |
CALC_PATTERN = re.compile("([a-z]+)([+-])[a-z]+") | |
def main(): | |
with open(sys.argv[1], "r") as f: | |
for line in f: |