Skip to content

Instantly share code, notes, and snippets.

sorted([(2, 3), (2, 2), (1, 1)])
# => [(1, 1), (2, 2), (2, 3)]
@peroon
peroon / Stable Neigh-bors.py
Last active April 23, 2017 14:58
Google Code Jam Online Round 1: Sub-Round B-B-large April 22, 2017 16:00 UTC – 18:30 UTC https://code.google.com/codejam/contest/8294486/dashboard#s=p1
# -*- coding: utf-8 -*-
import sys
import os
input_text_path = __file__.replace('.py', '.txt')
fd = os.open(input_text_path, os.O_RDONLY)
os.dup2(fd, sys.stdin.fileno())
f = open('submit.txt', 'w')
# -*- coding: utf-8 -*-
import mxnet as mx
import numpy as np
import mxlib
if __name__ == '__main__':
# get model
mxlib.get_model('http://data.mxnet.io/models/imagenet/resnext/101-layers/resnext-101', 0)
def is_prime(n):
if n == 2: return True
if n < 2 or n % 2 == 0: return False
return pow(2, n - 1, n) == 1
import re
s = 'yahyahooiurhgsbnfkcfhbi'
pattern = r'[bcdefgijklmnpqrstuvwxz]'
t = re.sub(pattern, '', s)
print(t)
# => yahhh
>>> s = 'abacde'
>>> s.count('a')
2
for s in iter(input, "0"):
print(s)
# Input
# 123
# 55
# 1000
# 0
# Output
# buildings[4][3][10]
buildings = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
a = 123.456789
b = round(a, 3)
print(b)
# => 123.457
a = divmod(10, 3)
print(a)
# => (3, 1)