Some solutions for basic 100 questions in codeup.kr

https://codeup.kr/problemsetsol.php?psid=23 provides basic p-sets for algo tests.
They might be very helpful for the implementation problems. (such as 1097 and 1099) These are the ones that are not familiar with me. Get used to it !!

1019: Using {}.format() for multiple variables with decimal specification

a, b, c = map(int, input().split('.'))
print("{}.{:02d}.{:02d}".format(a,b,c))

1020: Example for using replace method for string

print(input().replace('-',''))

1025: Input/output application

a = input()
for i in range(len(a)):
    print('[' + a[i] + '0'*(len(a)-i-1) + ']' )

1033: Decimal -> hexadecimal (using {}.format)

print("{:X}".format(int(input())))

1034: Octal -> decimal (using int)

print(int(input(), 8))

1035: Hexadecimal -> octal (using oct())

print(oct(int(input(), 16))[2:])

1036: Ascii char -> decimall

print(ord(input()))

1037: Decimal -> Ascii character

print(chr(int(input())))

1065: Using ‘‘.join()

Note that join’s parameter must be string

print('\n'.join(str(i) for i in map(int, input().split()) if i % 2 == 0))

1078: Using itertools library for accumulate sum

import itertools
n = [i for i in range(int(input())+1) if i % 2 == 0]
ans = list(itertools.accumulate(n))
print(ans[-1])

1082: Implementation (String)

n = input()
for i in range(1,16):
    print(n + '*' + str(hex(i)[2:]).upper() + '=' + str(hex(int(n, 16)*i).upper()[2:]))

1096: Printing 2D array

g = [[0] * 19 for _ in range(19)]
for _ in range(int(input())):
    i, j = map(int, input().split())
    g[i-1][j-1] = 1
for i in range(19):
    print(' '.join(str(j) for j in g[i]))

1097: Implementation (2D array)

g = [[0] * 19 for _ in range(19)]
for i in range(19):
    g[i] = list(map(int, input().split()))
for _ in range(int(input())):
    a, b = map(int, input().split())
    for i in range(19):
        for j in range(19):
            if i == b-1 or j == a-1:
                g[j][i] = 1 if g[j][i] == 0 else 0
    g[a-1][b-1] = 1 if g[a-1][b-1] == 0 else 0
for i in range(19):
    print(' '.join(str(j) for j in g[i]))
# Using direction vector and dfs for optimization
g = [0]*10
for i in range(10):
    g[i] = list(map(int, input().split()))
visited = [[0]*10 for _ in range(10)]
dx, dy = [1,0], [0, 1]
def dfs(x, y):
    if g[y][x] == 2:
        g[y][x] = 9
        return
    visited[y][x] = 1
    g[y][x] = 9
    for i in range(2):
        xx, yy = x + dx[i], y + dy[i]
        if xx < 10 and yy < 10:
            if g[yy][xx] != 1 and not visited[yy][xx]:
                dfs(xx,yy)
                return
dfs(1,1)
for i in range(10): print(' '.join(str(i) for i in g[i]))
# # timeout
# while i != 9 or j != 9:
#     g[i][j] = 9
#     if g[i][j+1] == 0:
#         j += 1
#     elif g[i][j+1] == 2:
#         g[i][j+1] = 9
#         break
#     elif g[i+1][j] == 0:
#         i += 1
#     elif g[i+1][j] == 2:
#         g[i+1][j] = 9
#         break