Skip to content

Commit

Permalink
Converted tabs to spaces (eww tabs)
Browse files Browse the repository at this point in the history
  • Loading branch information
letitz committed Sep 27, 2014
1 parent f2c49d8 commit 3ab1014
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 76 deletions.
18 changes: 9 additions & 9 deletions game_of_thrones_1/game_of_thrones_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
import sys

def is_palindrome_anagram(str):
chars = [ False ] * 26
for c in str:
chars[ord(c) - 97] ^= True
return sum(chars) <= 1
chars = [ False ] * 26
for c in str:
chars[ord(c) - 97] ^= True
return sum(chars) <= 1

def main():
if is_palindrome_anagram(sys.stdin.readline().strip()):
print('YES')
else:
print('NO')
if is_palindrome_anagram(sys.stdin.readline().strip()):
print('YES')
else:
print('NO')

if __name__ == '__main__':
main()
main()
26 changes: 13 additions & 13 deletions gem_stones/gem_stones.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
import sys

def count_gems(str, gems):
tmp = [ False ] * 26
for c in str:
tmp[ord(c) - 97] = True
for i in range(26):
if not tmp[i]:
gems[i] = False
tmp = [ False ] * 26
for c in str:
tmp[ord(c) - 97] = True
for i in range(26):
if not tmp[i]:
gems[i] = False

def main():
N = int(sys.stdin.readline())
gems = [ True ] * 26
for _ in range(N):
str = sys.stdin.readline().strip()
count_gems(str, gems)
print(sum(gems))
N = int(sys.stdin.readline())
gems = [ True ] * 26
for _ in range(N):
str = sys.stdin.readline().strip()
count_gems(str, gems)
print(sum(gems))

if __name__ == '__main__':
main()
main()
12 changes: 6 additions & 6 deletions hr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

new() {
case "$1" in
"py")
mkdir "$2" && cp skel.py "$2/$2.py" ;;
esac
case "$1" in
"py")
mkdir "$2" && cp skel.py "$2/$2.py" ;;
esac
}

case "$1" in
"new")
new "${@:2}" ;;
"new")
new "${@:2}" ;;
esac
18 changes: 9 additions & 9 deletions love_letter/love_letter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
import sys

def char_distance(ca,cb):
return abs(ord(ca) - ord(cb))
return abs(ord(ca) - ord(cb))

def palindrome_distance(str):
length = len(str)
dist = 0
for i in range(length // 2):
dist += char_distance(str[i], str[-i-1])
return dist
length = len(str)
dist = 0
for i in range(length // 2):
dist += char_distance(str[i], str[-i-1])
return dist

def main():
T = int(sys.stdin.readline())
for _ in range(T):
print(palindrome_distance(sys.stdin.readline().strip()))
T = int(sys.stdin.readline())
for _ in range(T):
print(palindrome_distance(sys.stdin.readline().strip()))

main()
20 changes: 10 additions & 10 deletions max_xor/max_xor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
import sys

def max_xor(L,R):
res = 1
n = L ^ R
while n > 0:
n >>=1
res <<= 1
return res - 1
res = 1
n = L ^ R
while n > 0:
n >>=1
res <<= 1
return res - 1

def main():
L = int(sys.stdin.readline())
R = int(sys.stdin.readline())
print(max_xor(L,R))
L = int(sys.stdin.readline())
R = int(sys.stdin.readline())
print(max_xor(L,R))

if __name__ == '__main__':
main()
main()
40 changes: 20 additions & 20 deletions service_lane/service_lane.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
import sys

def nextints():
return [int(x) for x in sys.stdin.readline().split()]
return [int(x) for x in sys.stdin.readline().split()]

def maxwidth_aux(width, i, j):
res = 3
for w in width[i:j+1]:
if w == 1:
return 1
res = min(res,w)
return res
res = 3
for w in width[i:j+1]:
if w == 1:
return 1
res = min(res,w)
return res

def maxwidth(width, i, j, memo):
res = memo.get((i,j), None)
if res:
return res
res = maxwidth_aux(width, i, j)
memo[(i,j)] = res
return res
res = memo.get((i,j), None)
if res:
return res
res = maxwidth_aux(width, i, j)
memo[(i,j)] = res
return res

def main():
[N,T] = nextints()
width = nextints()
memo = dict()
for _ in range(T):
[i,j] = nextints()
print(maxwidth(width, i, j, memo))
[N,T] = nextints()
width = nextints()
memo = dict()
for _ in range(T):
[i,j] = nextints()
print(maxwidth(width, i, j, memo))

main()
4 changes: 2 additions & 2 deletions skel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# INSERT CODE

def main():
pass
pass

if __name__ == '__main__':
main()
main()
14 changes: 7 additions & 7 deletions utopian_tree/utopian_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import sys

def calcsize(cycles):
tmp = 2**((cycles+3)//2)
if cycles % 2 == 1:
return tmp - 2
return tmp - 1
tmp = 2**((cycles+3)//2)
if cycles % 2 == 1:
return tmp - 2
return tmp - 1

def main():
total = int(sys.stdin.readline())
for i in range(total):
print(calcsize(int(sys.stdin.readline())))
total = int(sys.stdin.readline())
for i in range(total):
print(calcsize(int(sys.stdin.readline())))

main()

0 comments on commit 3ab1014

Please sign in to comment.