Saturday, May 27, 2023

📑 AGG filtering

Anti-Grain Geometry (AGG) & Matplotlib Artists





Sunday, May 21, 2023

📑 Farewell Round A 2023 Task 5 Untie

Farewell Round A 2023. Task 5

Python Only

T=int(input())
for t in range(T):
    C=input()
    if len(set(C))==1:
        count=len(C)//2+len(C)%2
    else:
        while C[0]==C[-1]:
            C=C[1:]+C[0]
        count=C.count('PP')+C.count('SS')+C.count('RR')
    print('Case #{}: {}'.format((t+1),count))
        


📑 Farewell Round A 2023 Task 4 ASCII Art

Farewell Round A 2023. Task 4

Python Only

# Competition Variant 1 (All Points)
letters='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def count26down(number):
    diff1,i,j=number,1,0
    while number>0:
        diff1=number; k1=i
        number-=i*26; i+=1
    while diff1>0:
        diff2=diff1; k2=j
        diff1-=k1; j+=1
    return k2
T=int(input())
for t in range(T):
    N=int(input())
    L=letters[count26down(N)]
    print('Case #{}: {}'.format((t+1),L))
    


Saturday, May 20, 2023

📑 Farewell Round A 2023 Task 3 Rainbow Sort

Farewell Round A 2023. Task 3

Python Only

# Competition Variant 1 (All Points)
T=int(input())
for t in range(T):
    N=int(input())
    cards=input().split()
    cards_set=set()
    result=[]
    for i in range(N):
        if cards[i] not in cards_set:
            cards_set.update([cards[i]])
            result.append(cards[i])
        elif result[-1]!=cards[i]:
            result='IMPOSSIBLE'
            break
 #       print(i,result)
    if result!='IMPOSSIBLE': result=' '.join(result)
    print('Case #{}: {}'.format((t+1),result))