Решение на Телефонна любов от Пламена Кръстева

Обратно към всички решения

Към профила на Пламена Кръстева

Резултати

  • 0 точки от тестове
  • 0 бонус точки
  • 0 точки общо
  • 0 успешни тест(а)
  • 37 неуспешни тест(а)

Код

def nums_to_text(numbers):
text = []
index = 0
for number in numbers:
index = index+1
if number == 1 or number == -1:
continue
times = 1
while number == numbers[index-1+times]:
times = times + 1
index = index+1
for _ in range(times):
numbers.next()
if number == 2:
times = times % 3
if times == 1:
text.append("A")
elif times == 2:
text.append("B")
elif times == 0:
text.append("C")
if number == 3:
times = times % 3
if times == 1:
text.append("D")
elif times == 2:
text.append("E")
elif times == 0:
text.append("F")
if number == 4:
times = times % 3
if times == 1:
text.append("G")
elif times == 2:
text.append("H")
elif times == 0:
text.append("I")
if number == 5:
times = times % 3
if times == 1:
text.append("J")
elif times == 2:
text.append("K")
elif times == 0:
text.append("L")
if number == 6:
times = times % 3
if times == 1:
text.append("M")
elif times == 2:
text.append("N")
elif times == 0:
text.append("O")
if number == 7:
times = times % 4
if times == 1:
text.append("P")
elif times == 2:
text.append("Q")
elif times == 3:
text.append("R")
elif times == 0:
text.append("S")
if number == 8:
if times == 1:
text.append("T")
elif times == 2:
text.append("U")
elif times == 0:
text.append("V")
if number == 9:
times = times % 4
if times == 1:
text.append("W")
elif times == 2:
text.append("X")
elif times == 3:
text.append("Y")
elif times == 0:
text.append("Z")
if number == 0:
text.append(" ")
return text

Лог от изпълнението

EEEEEEEEEEEEEEEEEEEEEEFEEEEEEEEEEEEEE
======================================================================
ERROR: test_empty_input (test.TestAnglesToNums)
Test with empty input.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'angles_to_nums' is not defined

======================================================================
ERROR: test_exact_angle (test.TestAnglesToNums)
Test with an exact angle.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'angles_to_nums' is not defined

======================================================================
ERROR: test_ignoring_over_330 (test.TestAnglesToNums)
Test that angles rounded over 330 are ignored.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'angles_to_nums' is not defined

======================================================================
ERROR: test_ignoring_under_30 (test.TestAnglesToNums)
Test that angles rounded under 30 are ignored.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'angles_to_nums' is not defined

======================================================================
ERROR: test_multiple_angles (test.TestAnglesToNums)
Test with a couple of angles as input.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'angles_to_nums' is not defined

======================================================================
ERROR: test_negative_angles (test.TestAnglesToNums)
Test with a negative input.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'angles_to_nums' is not defined

======================================================================
ERROR: test_overflowing_angles (test.TestAnglesToNums)
Test with an overflowed input.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'angles_to_nums' is not defined

======================================================================
ERROR: test_random_mixed_case (test.TestAnglesToNums)
Test with a random mixed input.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'angles_to_nums' is not defined

======================================================================
ERROR: test_round_angle_direction (test.TestAnglesToNums)
Test with an angle requiring explicit rounding to floor.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'angles_to_nums' is not defined

======================================================================
ERROR: test_round_angle_easy_case (test.TestAnglesToNums)
Test with an angle requiring rounding - easy case.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'angles_to_nums' is not defined

======================================================================
ERROR: test_empty_input (test.TestIsPhonetastic)
Test with empty input.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'is_phone_tastic' is not defined

======================================================================
ERROR: test_random_falses (test.TestIsPhonetastic)
Test with a random input resulting in False.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'is_phone_tastic' is not defined

======================================================================
ERROR: test_random_trues (test.TestIsPhonetastic)
Test with a random input resulting in True.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'is_phone_tastic' is not defined

======================================================================
ERROR: test_correct_mapping (test.TestNumsToAngles)
Test correct mapping for all numbers.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'nums_to_angle' is not defined

======================================================================
ERROR: test_empty_input (test.TestNumsToAngles)
Test with empty input.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'nums_to_angle' is not defined

======================================================================
ERROR: test_for_overflowing_numbers (test.TestNumsToAngles)
Test normalizing when sum overflows.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'nums_to_angle' is not defined

======================================================================
ERROR: test_for_sum (test.TestNumsToAngles)
Test with multiple numbers that should result in a sum.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'nums_to_angle' is not defined

======================================================================
ERROR: test_normalizing_for_top_boundary (test.TestNumsToAngles)
Test normalizing when the sum is full circle.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'nums_to_angle' is not defined

======================================================================
ERROR: test_random_mixed_case (test.TestNumsToAngles)
Test with a random mixed input.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'nums_to_angle' is not defined

======================================================================
ERROR: test_single_number (test.TestNumsToAngles)
Test with single number.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'nums_to_angle' is not defined

======================================================================
ERROR: test_all_chars (test.TestNumsToText)
Test for correct mapping of all chars.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: 'list' object has no attribute 'next'

======================================================================
ERROR: test_complex_word (test.TestNumsToText)
Test with a complex word that requires -1.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
IndexError: list index out of range

======================================================================
ERROR: test_ending_with_timeout (test.TestNumsToText)
Test with a sequence ending with a -1.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: 'list' object has no attribute 'next'

======================================================================
ERROR: test_multiple_timeouts (test.TestNumsToText)
Test with multiple '-1's next to each other.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: 'list' object has no attribute 'next'

======================================================================
ERROR: test_overflow_input (test.TestNumsToText)
Test with oveflowing number of presses.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
IndexError: list index out of range

======================================================================
ERROR: test_random_mixed_case (test.TestNumsToText)
Test for a random mixed case.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: 'list' object has no attribute 'next'

======================================================================
ERROR: test_simple_word (test.TestNumsToText)
Test with a simple word that doesn't require -1.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
AttributeError: 'list' object has no attribute 'next'

======================================================================
ERROR: test_spaces_only (test.TestNumsToText)
Test for input of only whitespaces with or without -1.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
IndexError: list index out of range

======================================================================
ERROR: test_starting_with_timeout (test.TestNumsToText)
Test with a sequence starting with a -1.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
IndexError: list index out of range

======================================================================
ERROR: test_all_chars (test.TestTextToNums)
Test for correct mapping of all chars.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'text_to_nums' is not defined

======================================================================
ERROR: test_complex_word (test.TestTextToNums)
Test with a complex word that requires -1.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'text_to_nums' is not defined

======================================================================
ERROR: test_empty_input (test.TestTextToNums)
Test with empty input.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'text_to_nums' is not defined

======================================================================
ERROR: test_mixed_casing (test.TestTextToNums)
Test for both lower and capital case.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'text_to_nums' is not defined

======================================================================
ERROR: test_random_mixed_case (test.TestTextToNums)
Test for a random mixed case.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'text_to_nums' is not defined

======================================================================
ERROR: test_simple_word (test.TestTextToNums)
Test with a simple word that doesn't require -1.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'text_to_nums' is not defined

======================================================================
ERROR: test_spaces_only (test.TestTextToNums)
Test for input of only whitespaces.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'text_to_nums' is not defined

======================================================================
FAIL: test_empty_input (test.TestNumsToText)
Test with empty input.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221020151654/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: [] != ''

----------------------------------------------------------------------
Ran 37 tests in 0.352s

FAILED (failures=1, errors=36)

История (1 версия и 2 коментара)

Пламена обнови решението на 03.11.2022 17:57 (преди над 1 година)

+def nums_to_text(numbers):
+ text = []
+ index = 0
+ for number in numbers:
+ index = index+1
+ if number == 1 or number == -1:
+ continue
+ times = 1
+ while number == numbers[index-1+times]:
+ times = times + 1
+ index = index+1
+ for _ in range(times):
+ numbers.next()
+
+ if number == 2:
+ times = times % 3
+ if times == 1:
+ text.append("A")
+ elif times == 2:
+ text.append("B")
+ elif times == 0:
+ text.append("C")
+ if number == 3:
+ times = times % 3
+ if times == 1:
+ text.append("D")
+ elif times == 2:
+ text.append("E")
+ elif times == 0:
+ text.append("F")
+ if number == 4:
+ times = times % 3
+ if times == 1:
+ text.append("G")
+ elif times == 2:
+ text.append("H")
+ elif times == 0:
+ text.append("I")
+ if number == 5:
+ times = times % 3
+ if times == 1:
+ text.append("J")
+ elif times == 2:
+ text.append("K")
+ elif times == 0:
+ text.append("L")
+ if number == 6:
+ times = times % 3
+ if times == 1:
+ text.append("M")
+ elif times == 2:
+ text.append("N")
+ elif times == 0:
+ text.append("O")
+ if number == 7:
+ times = times % 4
+ if times == 1:
+ text.append("P")
+ elif times == 2:
+ text.append("Q")
+ elif times == 3:
+ text.append("R")
+ elif times == 0:
+ text.append("S")
+ if number == 8:
+ if times == 1:
+ text.append("T")
+ elif times == 2:
+ text.append("U")
+ elif times == 0:
+ text.append("V")
+ if number == 9:
+ times = times % 4
+ if times == 1:
+ text.append("W")
+ elif times == 2:
+ text.append("X")
+ elif times == 3:
+ text.append("Y")
+ elif times == 0:
+ text.append("Z")
+ if number == 0:
+ text.append(" ")
+ return text