Я изучаю Python и пытаюсь пройти курс «Введение в компьютерную науку» (CS101) из Udacity. (https://www.udacity.com/course/intro-to-computer-science--cs101) Одно из упражнений - 10 строк Abacus. Я написал мое решение, и это работает очень хорошо в моем Python IDLE, но оценщик did't принимает мой код, возвращается сообщение об ошибке:Ошибка при попытке оценить мое решение упражнений от Intro до компьютерных наук (курс Python Udacity)
"Incorrect. Your submission did not return the correct result for the input 12345678. The expected output was:
'|00000***** |\n|00000***** |\n|00000**** *|\n|00000*** **|\n|00000** ***|\n|00000* ****|\n|00000 *****|\n|0000 0*****|\n|000 00*****|\n|00 000*****|'
Your submission passed 1 out of 3 test cases"
Я не могу понять, где проблема Если кто-то может скажите мне, где моя ошибка, я буду признателен!
Описание упражнения:
10-row School abacus
by
Michael H
Description partially extracted from from wikipedia
Around the world, abaci have been used in pre-schools and elementary
In Western countries, a bead frame similar to the Russian abacus but
with straight wires and a vertical frame has been common (see image).
Helps schools as an aid in teaching the numeral system and arithmetic
|00000***** | row factor 1000000000
|00000***** | row factor 100000000
|00000***** | row factor 10000000
|00000***** | row factor 1000000
|00000***** | row factor 100000
|00000***** | row factor 10000
|00000***** | row factor 1000
|00000**** *| row factor 100 * 1
|00000*** **| row factor 10 * 2
|00000** ***| row factor 1 * 3
-----------
Sum 123
Each row represents a different row factor, starting with x1 at the
bottom, ascending up to x1000000000 at the top row.
TASK:
Define a procedure print_abacus(integer) that takes a positive integer
and prints a visual representation (image) of an abacus setup for a
given positive integer value.
Ranking
1 STAR: solved the problem!
2 STARS: 6 < lines <= 9
3 STARS: 3 < lines <= 6
4 STARS: 0 < lines <= 3
Мой код:
Защиту print_abacus (значение):
abacuses = {
"0" : "|00000***** |",
"1" : "|00000**** *|",
"2" : "|00000*** **|",
"3" : "|00000** ***|",
"4" : "|00000* ****|",
"5" : "|00000 *****|",
"6" : "|0000 0*****|",
"7" : "|000 00*****|",
"8" : "|00 000*****|",
"9" : "|0 0000*****|"}
lst = []
s = str(value)
for i in s:
for key in abacuses:
if i == key:
lst.append(abacuses[key])
while len(lst) <= 10:
lst.insert(0, abacuses["0"])
for abacus in lst:
print abacus
P.S. Извините за мой английский
Какой результат для 12345678 при запуске вручную? – Kendas