1. Problem
2. My Solution
import sys
n = sys.stdin.readline().strip()
result = eval('+'.join(sys.stdin.readline().strip()))
print(result)
1. Problem
2. My Solution
import sys
s = sys.stdin.readline().strip()
result = []
for i in range(ord('a'), ord('z')+1):
try:
result.append(s.index(chr(i)))
except:
result.append(-1)
for i in range(len(result)):
print(result[i], end=' ')
import sys
word = sys.stdin.readline().strip()
alphabet = [-1] * 26
for i in word:
alphabet[ord(i)-97] = word.index(i)
print(' '.join(map(str,alphabet)))
3. Learned
1. Problem
2. My Solution
import sys
n = int(sys.stdin.readline().strip())
for i in range(n):
rep, str = sys.stdin.readline().strip().split()
result = ""
for j in range(len(str)):
result += (str[j]* int(rep))
print(result)
3. Others' Solutions
import sys
n = int(sys.stdin.readline().strip())
for i in range(n):
rep, str = sys.stdin.readline().strip().split()
result = ""
for j in str:
result += j * int(rep)
print(result)
4. Learned
1. Problem
2. My Solution
import sys
word = [char.lower() for char in sys.stdin.readline().strip()]
alpha_count = []
for i in range(ord('a'), ord('z')+1):
alpha_count.append(word.count(chr(i)))
if alpha_count.count(max(alpha_count)) > 1 :
print("?")
else:
print(chr(alpha_count.index(max(alpha_count))+97).upper())
3. Others' Solutions
mport sys
word = sys.stdin.readline().upper()
alpha_count = []
for i in range(ord('A'), ord('Z')+1):
alpha_count.append(word.count(chr(i)))
if alpha_count.count(max(alpha_count)) > 1 :
print("?")
else:
print(chr(alpha_count.index(max(alpha_count))+65))
import sys
word = sys.stdin.readline().strip().upper()
char_list = list(set(word))
alpha_count = []
for char in char_list:
alpha_count.append(word.count(char))
if alpha_count.count(max(alpha_count)) > 1 :
print("?")
else:
print(char_list[alpha_count.index(max(alpha_count))])
4. Learned
1. Problem
2. My Solution
import sys
a,b = sys.stdin.readline().strip().split()
a,b = a[::-1], b[::-1]
if int(a) > int(b):
print(a)
else:
print(b)
3. Others' Solutions
print(max(input()[::-1].split()))
4. Learned
1. Problem
2. My Solution
import sys
alpha_num = [['A','B','C'],['D','E','F'],['G','H','I'],['J','K','L'],['M','N','O'],['P','Q','R','S'],['T','U','V'],['W','X','Y','Z']]
word = list(sys.stdin.readline().strip())
total_time = 0
for i in word:
for j in range(len(alpha_num)):
if i in alpha_num[j]:
total_time += j+3
print(total_time)
4. Learned
import sys
alpha_num = [['A','B','C'],['D','E','F'],['G','H','I'],['J','K','L'],
['M','N','O'],['P','Q','R','S'],['T','U','V'],['W','X','Y','Z']]
word = list(sys.stdin.readline().strip())
total_time = 0
for i in word:
for j in range(len(alpha_num)):
if i in alpha_num[j]:
total_time += j+3
print(total_time)