Enumerate the exercises

This commit is contained in:
2023-12-11 16:13:48 +00:00
parent 3558a24b47
commit 3052288380
13 changed files with 4 additions and 2 deletions

43
09_queen_threats.lua Normal file
View File

@@ -0,0 +1,43 @@
-- Implement the function is_queen_threat() below. It should return
-- true if the queen is threatening the pawn and false otherwise. The
-- coordinates are as given as file (A-H), rank (1-8) pairs such as B3
-- and D7.
--
-- Solution --------------------------------------------------------------------
function is_queen_threat(queen_position, pawn_position)
-- Your implementation here
end
-- Tests -----------------------------------------------------------------------
local luaunit = require("luaunit.luaunit")
function test_B4_theatens_G4()
luaunit.assertTrue(is_queen_threat("B4", "G4"))
end
function test_D7_theatens_D1()
luaunit.assertTrue(is_queen_threat("D7", "D1"))
end
function test_C5_theatens_F8()
luaunit.assertTrue(is_queen_threat("C5", "F8"))
end
function test_B3_theatens_D1()
luaunit.assertTrue(is_queen_threat("B3", "D1"))
end
function test_B4_does_not_threaten_F3()
luaunit.assertFalse(is_queen_threat("B4", "F3"))
end
function test_E2_does_not_threaten_G1()
luaunit.assertFalse(is_queen_threat("E2", "G1"))
end
function test_A8_does_not_threaten_G3()
luaunit.assertFalse(is_queen_threat("A8", "G3"))
end
os.exit(luaunit.LuaUnit.run())