Browse Source

Converted tabs to spaces (eww tabs)

main
Titouan Rigoudy 11 years ago
parent
commit
3ab10148e7
8 changed files with 76 additions and 76 deletions
  1. +9
    -9
      game_of_thrones_1/game_of_thrones_1.py
  2. +13
    -13
      gem_stones/gem_stones.py
  3. +6
    -6
      hr
  4. +9
    -9
      love_letter/love_letter.py
  5. +10
    -10
      max_xor/max_xor.py
  6. +20
    -20
      service_lane/service_lane.py
  7. +2
    -2
      skel.py
  8. +7
    -7
      utopian_tree/utopian_tree.py

+ 9
- 9
game_of_thrones_1/game_of_thrones_1.py View File

@ -5,16 +5,16 @@
import sys import sys
def is_palindrome_anagram(str): 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(): 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__': if __name__ == '__main__':
main()
main()

+ 13
- 13
gem_stones/gem_stones.py View File

@ -5,20 +5,20 @@
import sys import sys
def count_gems(str, gems): 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(): 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__': if __name__ == '__main__':
main()
main()

+ 6
- 6
hr View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
new() { 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 case "$1" in
"new")
new "${@:2}" ;;
"new")
new "${@:2}" ;;
esac esac

+ 9
- 9
love_letter/love_letter.py View File

@ -5,18 +5,18 @@
import sys import sys
def char_distance(ca,cb): def char_distance(ca,cb):
return abs(ord(ca) - ord(cb))
return abs(ord(ca) - ord(cb))
def palindrome_distance(str): 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(): 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() main()

+ 10
- 10
max_xor/max_xor.py View File

@ -5,17 +5,17 @@
import sys import sys
def max_xor(L,R): 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(): 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__': if __name__ == '__main__':
main()
main()

+ 20
- 20
service_lane/service_lane.py View File

@ -5,31 +5,31 @@
import sys import sys
def nextints(): 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): 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): 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(): 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() main()

+ 2
- 2
skel.py View File

@ -7,7 +7,7 @@ import sys
# INSERT CODE # INSERT CODE
def main(): def main():
pass
pass
if __name__ == '__main__': if __name__ == '__main__':
main()
main()

+ 7
- 7
utopian_tree/utopian_tree.py View File

@ -5,14 +5,14 @@
import sys import sys
def calcsize(cycles): 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(): 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() main()

Loading…
Cancel
Save