Translate

Views

Friday, September 6, 2024

Solution UVA: 10878 - Decode the tape

 

 Problem  VerdictLangTimeBestRankSubmit Time
 | discuss10878 - Decode the tape AcceptedPython0.1800.00056151 mins ago

Suggest:

- In the problems decode, i think we should make doing step:

1/ Look overview and get information easy know like

+ input we have 8 char / line -> now we know need use bit
+ number of line = nuimber of char in string -> now we know every line is a present a char of output

2/ Thinking top down problem 

+ A -> 65 -> 01000001 -> |_o___.__o|


_ = input()
while True:
    s = input()
    if s == '___________':
        break

    k = 0
    n = 0
   
    for i in range(len(s)-1, 0, -1):
       
        if s[i] == 'o':
            n += 1 << k
            k += 1
       
        if s[i] == ' ':
            k += 1
           
    print(chr(n), end='')

No comments: