Okey im boring a bit so, yes, fight agains my self from the pass. Me at this moment remember about math ahahaahha
def knight_move3d(position=(0, 0, 0)) -> bool: if position == (0, 0, 0): return True _sum: int = 0 mul: int = 1 for i in position: if i > 2 or -2 > i: return False _sum += abs(i) mul = mul * i return _sum == 3 and mul == 0
- def knight_move3d(position=(0, 0, 0)) -> bool:
- if position == (0, 0, 0):
- return True
res: list = [False, False, False]- _sum: int = 0
- mul: int = 1
- for i in position:
- if i > 2 or -2 > i:
- return False
res[abs(i)] = Truereturn all(res)- _sum += abs(i)
- mul = mul * i
- return _sum == 3 and mul == 0
def knight_move3d(position=(0, 0, 0)) -> bool: if position == (0, 0, 0): return True res: list = [False, False, False] for i in position: if i > 2 or -2 > i: return False res[abs(i)] = True return all(res)
def knight_move3d(coordinates) -> bool:return sorted(map(abs,coordinates))==[0,1,2] or coordinates==(0,0,0)- def knight_move3d(position=(0, 0, 0)) -> bool:
- if position == (0, 0, 0):
- return True
- res: list = [False, False, False]
- for i in position:
- if i > 2 or -2 > i:
- return False
- res[abs(i)] = True
- return all(res)
import codewars_test as test from solution import knight_move3d import random @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(knight_move3d((0,0,0)),True) test.assert_equals(knight_move3d((0,-2,1)),True) test.assert_equals(knight_move3d((0,-2,-1)),True) test.assert_equals(knight_move3d((0,2,1)),True) test.assert_equals(knight_move3d((0,1,2)),True) test.assert_equals(knight_move3d((1,2,0)),True) test.assert_equals(knight_move3d((-1,2,0)),True) test.assert_equals(knight_move3d((1,-2,0)),True) test.assert_equals(knight_move3d((-1,-2,0)),True) test.assert_equals(knight_move3d((1,0,2)),True) test.assert_equals(knight_move3d((1,0,-2)),True) test.assert_equals(knight_move3d((-1,0,-2)),True) test.assert_equals(knight_move3d((-1,-2,0)),True) test.assert_equals(knight_move3d((2,0,1)),True) test.assert_equals(knight_move3d((2,0,-1)),True) test.assert_equals(knight_move3d((-2,1,0)),True) test.assert_equals(knight_move3d((-2,0,-1)),True) test.assert_equals(knight_move3d((-2,0,1)),True) @test.it("test case") def test_case(): test.assert_equals(knight_move3d((1,1,1)),False) test.assert_equals(knight_move3d((-1,1,2)),False) test.assert_equals(knight_move3d((7,7,6)),False) test.assert_equals(knight_move3d((0,0,1)),False)
- import codewars_test as test
- from solution import knight_move3d
- import random
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- test.assert_equals(knight_move3d((0,0,0)),True)
- test.assert_equals(knight_move3d((0,-2,1)),True)
- test.assert_equals(knight_move3d((0,-2,-1)),True)
- test.assert_equals(knight_move3d((0,2,1)),True)
- test.assert_equals(knight_move3d((0,1,2)),True)
- test.assert_equals(knight_move3d((1,2,0)),True)
- test.assert_equals(knight_move3d((-1,2,0)),True)
- test.assert_equals(knight_move3d((1,-2,0)),True)
- test.assert_equals(knight_move3d((-1,-2,0)),True)
- test.assert_equals(knight_move3d((1,0,2)),True)
- test.assert_equals(knight_move3d((1,0,-2)),True)
- test.assert_equals(knight_move3d((-1,0,-2)),True)
- test.assert_equals(knight_move3d((-1,-2,0)),True)
- test.assert_equals(knight_move3d((2,0,1)),True)
- test.assert_equals(knight_move3d((2,0,-1)),True)
- test.assert_equals(knight_move3d((-2,1,0)),True)
- test.assert_equals(knight_move3d((-2,0,-1)),True)
- test.assert_equals(knight_move3d((-2,0,1)),True)
#test.assert_equals(knight_move3d((2,2,1)),True)#test.assert_equals(knight_move3d((2,-2,1)),True)- @test.it("test case")
- def test_case():
- test.assert_equals(knight_move3d((1,1,1)),False)
- test.assert_equals(knight_move3d((-1,1,2)),False)
- test.assert_equals(knight_move3d((7,7,6)),False)
- test.assert_equals(knight_move3d((0,0,1)),False)