URI Online Judge Solution 1168 LED Using C, Python Programming Language.
John wants to set up a panel containing different numbers of LEDs. He does not have many leds, he is not sure if he will be able to mount the desired number. Considering the configuration of the LEDs of the numbers below, make an algorithm that helps John to discover the number of LEDs needed to set the value.
Input
The input contains an integer N, (1 ≤ N ≤ 2000) corresponding to the number of test cases, followed by N lines, each line containing a number (1 ≤ V ≤ 10100) corresponding to the value that John wants to set with the leds.
Output
The input contains an integer N, (1 ≤ N ≤ 2000) corresponding to the number of test cases, followed by N lines, each line containing a number (1 ≤ V ≤ 10100) corresponding to the value that John wants to set with the leds.
Output
For each test case, print one line containing the number of LEDs that John needs to set the desired value, followed by the word "leds".
Input Sample | Output Sample |
3 | 27 leds |
Solution Using Python:
Dic = {'0': 6,'1': 2,'2': 5,'3': 5,'4': 4,'5': 5,'6': 6,'7': 3,'8': 7,'9': 6}
T = int(input())
while T>0:
C = 0
S = list(input())
for i in S:
C = C + Dic[i]
print("%d leds"%C)
T-=1
Comments
Post a Comment