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

37
10_hexadecimal.lua Normal file
View File

@@ -0,0 +1,37 @@
-- Write a function to return the hexadecimal representation (in a
-- string) of a number. Use lowercase a to f.
--
-- Solution --------------------------------------------------------------------
function hexadecimal(x)
-- Your implementation here
end
-- Tests -----------------------------------------------------------------------
local luaunit = require("luaunit.luaunit")
function test_hexadecimal_of_8_is_8()
luaunit.assertEquals(hexadecimal(8), "8")
end
function test_hexadecimal_of_14_is_e()
luaunit.assertEquals(hexadecimal(14), "e")
end
function test_hexadecimal_of_42_is_2a()
luaunit.assertEquals(hexadecimal(42), "2a")
end
function test_hexadecimal_of_3735928559_is_deadbeef()
luaunit.assertEquals(hexadecimal(3735928559), "deadbeef")
end
function test_hexadecimal_of_12648430_is_c0ffee()
luaunit.assertEquals(hexadecimal(12648430), "c0ffee")
end
function test_hexadecimal_of_49374_is_c0de()
luaunit.assertEquals(hexadecimal(49374), "c0de")
end
os.exit(luaunit.LuaUnit.run())