Skip to content

Instantly share code, notes, and snippets.

View yuheiomori's full-sized avatar

Yuhei Omori yuheiomori

View GitHub Profile
@yuheiomori
yuheiomori / main.go
Created August 18, 2014 08:44
RollerCoaster (CodeEval) in go
package main
import (
"bufio"
"fmt"
"log"
"os"
"unicode"
)
@yuheiomori
yuheiomori / main.py
Created August 17, 2014 11:30
Age Distribution (CodeEval) in Python 3.x
# 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'
@yuheiomori
yuheiomori / main.py
Created August 16, 2014 04:34
Roller Coaster (CodeEval) in Python 3.x
# 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():
@yuheiomori
yuheiomori / main.py
Created August 15, 2014 10:38
Juglling with zeros (CodeEval) in Python 3.x
# coding=utf-8
import sys
def convert1(s):
elements = s.split(" ")
b = []
for flag, seq in zip(*[iter(elements)] * 2):
if flag == "0":
@yuheiomori
yuheiomori / main.py
Created August 14, 2014 08:40
Lettercase Percentage Ratio (CodeEval) in Python 3.x
# 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():
@yuheiomori
yuheiomori / main.py
Last active August 29, 2015 14:05
Data Recovery (CodeEval) in Python 3.x
# 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)
@yuheiomori
yuheiomori / main.py
Created August 12, 2014 11:24
Working Experience (CodeEval) in Python 3.x
# coding=utf-8
import queue
import sys
import time
class Time(object):
def __init__(self, epoch, start=True):
self.epoch = epoch
self.start = start
@yuheiomori
yuheiomori / main.py
Created August 11, 2014 09:48
Racing Chars (CodeEval) in Python 3.x
# coding=utf-8
import sys
PASSING_TYPE_STRAIGHT = '|'
PASSING_TYPE_LEFT_TURN = '\\'
PASSING_TYPE_RIGHT_TURN = '/'
ROAD_TYPE_GATE = '_'
ROAD_TYPE_CHECKPOINT = 'C'
@yuheiomori
yuheiomori / main.py
Created August 10, 2014 10:46
The Major Element(CodeEval) in Python 3.x
# coding=utf-8
import sys
def major_element(elements):
m = dict()
for e in elements:
m.setdefault(e, 0)
m[e] += 1
@yuheiomori
yuheiomori / main.py
Created August 9, 2014 08:02
Split The Number (CodeEval) in Python 3.x
# 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: