Решение на Шахматни фенове от Кирил Кирилов

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

Към профила на Кирил Кирилов

Резултати

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

Код

class ChessException(Exception):
def __init__(message):
super().__init__(message)
#rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR
class ChessPostion:
def __init__(self, fen):
self.fen = fen
self.board = {}
rows = fen.split('/')
row = 'A'
column = '3'
figure = 'r'
for i in range(8):
row += '1'
for j in range(8):
column += '1'
self.board[f"{row}{column}"] = figure
print(self.board)
def get_white_score():
pass
def get_black_score():
pass
def white_is_winning():
pass
def black_is_winning():
pass
def is_equal():
pass
def __len__():
pass
def __getitem__():
pass
def __str__():
pass
class ChessScore:
def __init__(self, l):
pass
def __int__():
pass
def __lt__(self, other):
pass
def __gt__(self, other):
pass
def __ne__(self, other):
pass
def __eq__(self, other):
pass
def __le__(self, other):
pass
def __add__(self, other):
pass
def __sub__(self, other):
pass
chess = ChessPostion("rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR")

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

{'A131': 'r', 'A1311': 'r', 'A13111': 'r', 'A131111': 'r', 'A1311111': 'r', 'A13111111': 'r', 'A131111111': 'r', 'A1311111111': 'r', 'A113111111111': 'r', 'A1131111111111': 'r', 'A11311111111111': 'r', 'A113111111111111': 'r', 'A1131111111111111': 'r', 'A11311111111111111': 'r', 'A113111111111111111': 'r', 'A1131111111111111111': 'r', 'A111311111111111111111': 'r', 'A1113111111111111111111': 'r', 'A11131111111111111111111': 'r', 'A111311111111111111111111': 'r', 'A1113111111111111111111111': 'r', 'A11131111111111111111111111': 'r', 'A111311111111111111111111111': 'r', 'A1113111111111111111111111111': 'r', 'A111131111111111111111111111111': 'r', 'A1111311111111111111111111111111': 'r', 'A11113111111111111111111111111111': 'r', 'A111131111111111111111111111111111': 'r', 'A1111311111111111111111111111111111': 'r', 'A11113111111111111111111111111111111': 'r', 'A111131111111111111111111111111111111': 'r', 'A1111311111111111111111111111111111111': 'r', 'A111113111111111111111111111111111111111': 'r', 'A1111131111111111111111111111111111111111': 'r', 'A11111311111111111111111111111111111111111': 'r', 'A111113111111111111111111111111111111111111': 'r', 'A1111131111111111111111111111111111111111111': 'r', 'A11111311111111111111111111111111111111111111': 'r', 'A111113111111111111111111111111111111111111111': 'r', 'A1111131111111111111111111111111111111111111111': 'r', 'A111111311111111111111111111111111111111111111111': 'r', 'A1111113111111111111111111111111111111111111111111': 'r', 'A11111131111111111111111111111111111111111111111111': 'r', 'A111111311111111111111111111111111111111111111111111': 'r', 'A1111113111111111111111111111111111111111111111111111': 'r', 'A11111131111111111111111111111111111111111111111111111': 'r', 'A111111311111111111111111111111111111111111111111111111': 'r', 'A1111113111111111111111111111111111111111111111111111111': 'r', 'A111111131111111111111111111111111111111111111111111111111': 'r', 'A1111111311111111111111111111111111111111111111111111111111': 'r', 'A11111113111111111111111111111111111111111111111111111111111': 'r', 'A111111131111111111111111111111111111111111111111111111111111': 'r', 'A1111111311111111111111111111111111111111111111111111111111111': 'r', 'A11111113111111111111111111111111111111111111111111111111111111': 'r', 'A111111131111111111111111111111111111111111111111111111111111111': 'r', 'A1111111311111111111111111111111111111111111111111111111111111111': 'r', 'A111111113111111111111111111111111111111111111111111111111111111111': 'r', 'A1111111131111111111111111111111111111111111111111111111111111111111': 'r', 'A11111111311111111111111111111111111111111111111111111111111111111111': 'r', 'A111111113111111111111111111111111111111111111111111111111111111111111': 'r', 'A1111111131111111111111111111111111111111111111111111111111111111111111': 'r', 'A11111111311111111111111111111111111111111111111111111111111111111111111': 'r', 'A111111113111111111111111111111111111111111111111111111111111111111111111': 'r', 'A1111111131111111111111111111111111111111111111111111111111111111111111111': 'r'}
EEEEEEEEEEEEEFFEE
======================================================================
ERROR: test_correct_parent (test.TestChessException)
Ensure ChessException is a child of Exception.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: ChessException.__init__() takes 1 positional argument but 2 were given

======================================================================
ERROR: test_against_touching_kings (test.TestChessPosition)
Test for kings next to each other.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'ChessPosition' is not defined

======================================================================
ERROR: test_black_is_winning (test.TestChessPosition)
Test black_is_winning.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'ChessPosition' is not defined

======================================================================
ERROR: test_get_black_score (test.TestChessPosition)
Test get_black_score.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'ChessPosition' is not defined

======================================================================
ERROR: test_get_white_score (test.TestChessPosition)
Test get_white_score.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'ChessPosition' is not defined

======================================================================
ERROR: test_getitem (test.TestChessPosition)
Test getitem functionality.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'ChessPosition' is not defined

======================================================================
ERROR: test_is_equal (test.TestChessPosition)
Test is_equal.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'ChessPosition' is not defined

======================================================================
ERROR: test_king_count (test.TestChessPosition)
Test for missing or multiple kings.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'ChessPosition' is not defined

======================================================================
ERROR: test_len (test.TestChessPosition)
Test number of pieces for a position.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'ChessPosition' is not defined

======================================================================
ERROR: test_pawns_position (test.TestChessPosition)
Test for incorrect pawns.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'ChessPosition' is not defined

======================================================================
ERROR: test_str (test.TestChessPosition)
Test string representation of the instance.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'ChessPosition' is not defined

======================================================================
ERROR: test_validation_conflict (test.TestChessPosition)
Test for correct Exception on multiple validation fails.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'ChessPosition' is not defined

======================================================================
ERROR: test_white_is_winning (test.TestChessPosition)
Test white_is_winning.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
NameError: name 'ChessPosition' is not defined

======================================================================
ERROR: test_correct_mapping_of_pieces (test.TestChessScore)
Test correct mapping for each piece.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: ChessScore.__int__() takes 0 positional arguments but 1 was given

======================================================================
ERROR: test_correct_sum_of_pieces (test.TestChessScore)
Test correct sum for random pieces.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
TypeError: ChessScore.__int__() takes 0 positional arguments but 1 was given

======================================================================
FAIL: test_basic_arithmetic (test.TestChessScore)
Test additiona and subtraction of ChessScores.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: None != 7

======================================================================
FAIL: test_comparison (test.TestChessScore)
Test correct comparison on a pair of scores.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage/deedee/data/rails/pyfmi-2022/releases/20221115154139/lib/language/python/runner.py", line 67, in thread
    raise result
AssertionError: <solution.ChessScore object at 0xffffb3246380> not less than <solution.ChessScore object at 0xffffb32ce320>

----------------------------------------------------------------------
Ran 17 tests in 0.214s

FAILED (failures=2, errors=15)

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

Кирил обнови решението на 29.11.2022 17:58 (преди почти 2 години)

+class ChessException(Exception):
+ def __init__(message):
+ super().__init__(message)
+
+#rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR
+
+class ChessPostion:
+ def __init__(self, fen):
+ self.fen = fen
+ self.board = {}
+ rows = fen.split('/')
+ row = 'A'
+ column = '3'
+ figure = 'r'
+ for i in range(8):
+ row += '1'
+ for j in range(8):
+ column += '1'
+ self.board[f"{row}{column}"] = figure
+ print(self.board)
+
+
+ def get_white_score():
+ pass
+
+ def get_black_score():
+ pass
+
+ def white_is_winning():
+ pass
+
+ def black_is_winning():
+ pass
+
+ def is_equal():
+ pass
+
+ def __len__():
+ pass
+
+ def __getitem__():
+ pass
+
+ def __str__():
+ pass
+
+class ChessScore:
+ def __init__(self, l):
+ pass
+
+ def __int__():
+ pass
+
+ def __lt__(self, other):
+ pass
+
+ def __gt__(self, other):
+ pass
+
+ def __ne__(self, other):
+ pass
+
+ def __eq__(self, other):
+ pass
+
+ def __le__(self, other):
+ pass
+
+ def __add__(self, other):
+ pass
+
+ def __sub__(self, other):
+ pass
+
+
+chess = ChessPostion("rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR")