Paste #130774

   
pasted on 30.12.2019 02:14
  • Edit to this paste
  • Print
  • Raw
  • The following pastes replied to this paste:  # 240596
  • Show paste tree
  • Compare with paste
    #  
  • Toggle line numbers
  • Syntax highlighting  
Text paste
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def checkio(data):
    M_count = data // 1000
    D_count = data % 1000 // 500
    C_count = data % 1000 % 500 // 100
    L_count = data % 1000 % 500 % 100 // 50
    X_count = data % 1000 % 500 % 100 % 50 // 10
    V_count = data % 1000 % 500 % 100 % 50 % 10 // 5
    I_count = data % 1000 % 500 % 100 % 50 % 10 % 5

    if I_count > 3:
        if V_count == 1:
            roman_number = 'IX'
        else:
            roman_number = 'IV'
    else:
        roman_number = 'V' * V_count + 'I' * I_count

    if X_count > 3:
        if L_count == 1:
            roman_number = 'XC' + roman_number
        else:
            roman_number = 'XL' + roman_number
    else:
        roman_number = 'L' * L_count + 'X' * X_count + roman_number

    if C_count > 3:
        if D_count == 1:
            roman_number = 'CM' + roman_number
        else:
            roman_number = 'CD' + roman_number
    else:
        roman_number = 'D' * D_count + 'C' * C_count + roman_number

    roman_number = 'M' * M_count + roman_number

    print(roman_number)


checkio(6)
Add Comment
Author