def solution(a, b):
    answer = 0
    if a < b:
        for i in range(a, b+1):
            answer += i
    else:
        for i in range(b, a+1):
            answer += i
            
    return answer

 

def solution(n):
    total = 0
    for idx in range(1, n+1):
        answer = 0
        while answer < n:
            answer += idx
            idx += 1
        if answer == n:
            total += 1

    return total

def solution(n):
    answer = 0
    F = [0, 1]
    
    for i in range(n-1):
        F.append(F[i] + F[i+1])
        
    answer = F[n] % 1234567
    return answer

def solution(n, lost, reserve):
    answer = 0
    total = list()
    
    for i in range(n):
        total.append(1)
    
    for i in lost:
        total[i-1] -= 1
    
    for i in reserve:
        total[i-1] += 1 
  
    for i in range(len(total)):
        if total[i] == 2:
            if i-1 >= 0:
                if total[i-1] == 0:
                    total[i-1] += 1
                    total[i] -= 1
        if total[i] == 2:
            if i+1 < len(total):
                if total[i+1] == 0:
                    total[i+1] += 1
                    total[i] -= 1
                    
    for student in total:
        if student >= 1:
            answer += 1
                    
    return answer

+ Recent posts