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

23
03_hamming_distance.lua Normal file
View File

@@ -0,0 +1,23 @@
-- The hamming distance is the number of positions in which two
-- strings differ, and is used to measure how similar strings are.
-- Implement the hamming_distance() function below to calculate this;
-- you may assume that the strings are of equal length.
--
-- Solution --------------------------------------------------------------------
function hamming_distance(str1, str2)
-- Your implementation here
end
-- Tests -----------------------------------------------------------------------
local luaunit = require("luaunit.luauint")
function test_distance_between_foo_and_bar_is_3()
luaunit.assertEquals(hamming_distance("foo", "bar"), 3)
end
function test_distance_between_bar_and_baz_is_1()
luaunit.assertEquals(hamming_distance("bar", "baz"), 1)
end
os.exit(luaunit.LuaUnit.run())