Решение на Четири функции от Фатих Хюсеинов

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

Към профила на Фатих Хюсеинов

Резултати

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

Код

def groupby(func, *args):
dictionary = {}
for i in args:
dictionary.setdefault(func(i),[]).append(i)
return dictionary

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

EEEEEEEEEEEEEEEEEEEE
======================================================================
ERROR: test_cache_cache_is_not_global (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 129, in test_cache_cache_is_not_global
    cached_double1 = solution.cache(double, 3)
AttributeError: 'module' object has no attribute 'cache'

======================================================================
ERROR: test_cache_call_is_cached (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 116, in test_cache_call_is_cached
    cached_double = solution.cache(double, 10)
AttributeError: 'module' object has no attribute 'cache'

======================================================================
ERROR: test_cache_function_with_vargs (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 159, in test_cache_function_with_vargs
    cached_sum = solution.cache(sum_varargs, 10)
AttributeError: 'module' object has no attribute 'cache'

======================================================================
ERROR: test_cache_no_cache (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 103, in test_cache_no_cache
    cached_double = solution.cache(double, 0)
AttributeError: 'module' object has no attribute 'cache'

======================================================================
ERROR: test_cache_size_is_respected (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 143, in test_cache_size_is_respected
    cached_double = solution.cache(double, 2)
AttributeError: 'module' object has no attribute 'cache'

======================================================================
ERROR: test_groupby_empty (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 9, in test_groupby_empty
    actual = solution.groupby(lambda x: x, [])
  File "/tmp/d20130408-29081-1nx36v7/solution.py", line 4, in groupby
    dictionary.setdefault(func(i),[]).append(i)
TypeError: unhashable type: 'list'

======================================================================
ERROR: test_groupby_no_repetitions (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 14, in test_groupby_no_repetitions
    actual = solution.groupby(lambda x: x, [1, 2, 3, 5,'se7en'], )
  File "/tmp/d20130408-29081-1nx36v7/solution.py", line 4, in groupby
    dictionary.setdefault(func(i),[]).append(i)
TypeError: unhashable type: 'list'

======================================================================
ERROR: test_groupby_nonequalty (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 28, in test_groupby_nonequalty
    actual = solution.groupby(lambda x: 'odd' if x%2 else 'even', [1, 2, 3, 4])
  File "/tmp/d20130408-29081-1nx36v7/solution.py", line 4, in groupby
    dictionary.setdefault(func(i),[]).append(i)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 28, in <lambda>
    actual = solution.groupby(lambda x: 'odd' if x%2 else 'even', [1, 2, 3, 4])
TypeError: unsupported operand type(s) for %: 'list' and 'int'

======================================================================
ERROR: test_groupby_simple_types (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 19, in test_groupby_simple_types
    actual = solution.groupby(lambda x: 'odd' if x%2 else 'even', [1, 2, 3, 5, 8, 9, 10, 12])
  File "/tmp/d20130408-29081-1nx36v7/solution.py", line 4, in groupby
    dictionary.setdefault(func(i),[]).append(i)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 19, in <lambda>
    actual = solution.groupby(lambda x: 'odd' if x%2 else 'even', [1, 2, 3, 5, 8, 9, 10, 12])
TypeError: unsupported operand type(s) for %: 'list' and 'int'

======================================================================
ERROR: test_groupby_with_generator (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 24, in test_groupby_with_generator
    actual = solution.groupby(lambda x: 'big' if x > 30 else 'small', range(0, 50, 5))
  File "/tmp/d20130408-29081-1nx36v7/solution.py", line 4, in groupby
    dictionary.setdefault(func(i),[]).append(i)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 24, in <lambda>
    actual = solution.groupby(lambda x: 'big' if x > 30 else 'small', range(0, 50, 5))
TypeError: unorderable types: range() > int()

======================================================================
ERROR: test_iterate_ordered_calls (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 37, in test_iterate_ordered_calls
    powers_of_two = solution.iterate(lambda x: x*2)
AttributeError: 'module' object has no attribute 'iterate'

======================================================================
ERROR: test_iterate_out_of_order_calls (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 48, in test_iterate_out_of_order_calls
    powers_of_two = solution.iterate(lambda x: x*2)
AttributeError: 'module' object has no attribute 'iterate'

======================================================================
ERROR: test_iterate_out_of_order_calls_again (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 48, in test_iterate_out_of_order_calls
    powers_of_two = solution.iterate(lambda x: x*2)
AttributeError: 'module' object has no attribute 'iterate'

======================================================================
ERROR: test_iterate_out_of_order_calls_yet_again (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 48, in test_iterate_out_of_order_calls
    powers_of_two = solution.iterate(lambda x: x*2)
AttributeError: 'module' object has no attribute 'iterate'

======================================================================
ERROR: test_iterate_start_with_identity_function (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 32, in test_iterate_start_with_identity_function
    bracketisers = solution.iterate(lambda x: '(' + x + ')') # there's no such word, really
AttributeError: 'module' object has no attribute 'iterate'

======================================================================
ERROR: test_zip_with_empty (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 66, in test_zip_with_empty
    actual = solution.zip_with(lambda x: x)
AttributeError: 'module' object has no attribute 'zip_with'

======================================================================
ERROR: test_zip_with_infinite_sequence (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 81, in test_zip_with_infinite_sequence
    actual = solution.zip_with(lambda x, y, z: x + y + z, first_names, spaces, last_names)
AttributeError: 'module' object has no attribute 'zip_with'

======================================================================
ERROR: test_zip_with_nonequalty (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 92, in test_zip_with_nonequalty
    actual = solution.zip_with(int.__add__, numbers1, numbers2)
AttributeError: 'module' object has no attribute 'zip_with'

======================================================================
ERROR: test_zip_with_one_shorter_seqence (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 73, in test_zip_with_one_shorter_seqence
    actual = solution.zip_with(str.__add__, first_names, last_names)
AttributeError: 'module' object has no attribute 'zip_with'

======================================================================
ERROR: test_zip_with_vargs_function (test.SecondHomeworkTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib/language/python/runner.py", line 60, in thread
    raise it.exc_info[1]
  File "lib/language/python/runner.py", line 48, in run
    self.result = func(*args, **kwargs)
  File "/tmp/d20130408-29081-1nx36v7/test.py", line 86, in test_zip_with_vargs_function
    actual = solution.zip_with(lambda *x: sum(x), [1], [2], [3], [5], [8])
AttributeError: 'module' object has no attribute 'zip_with'

----------------------------------------------------------------------
Ran 20 tests in 0.014s

FAILED (errors=20)

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