Create anagrams exercise
This commit is contained in:
parent
e011e17e51
commit
01681dae61
39
anagrams.lua
Normal file
39
anagrams.lua
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
-- Solution --------------------------------------------------------------------
|
||||||
|
|
||||||
|
function is_anagram(str1, str2)
|
||||||
|
-- Your implementation here
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Tests -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
local luaunit = require("luaunit.luaunit")
|
||||||
|
|
||||||
|
function test_listen_is_anagram_of_silent()
|
||||||
|
luaunit.assertTrue(is_anagram("listen", "silent"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_astronomers_is_anagram_of_moon_starers()
|
||||||
|
luaunit.assertTrue(is_anagram("astronomers", "moon starers"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_dormitory_is_anagram_of_dirty_room()
|
||||||
|
luaunit.assertTrue(is_anagram("dormitory", "dirty room"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_foo_is_not_anagram_of_bar()
|
||||||
|
luaunit.assertFalse(is_anagram("foo", "bar"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_foo_is_not_anagram_of_of()
|
||||||
|
luaunit.assertFalse(is_anagram("foo", "of"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_bar_is_not_anagram_of_barn()
|
||||||
|
luaunit.assertFalse(is_anagram("bar", "barn"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_barn_is_not_anagram_of_bar()
|
||||||
|
luaunit.assertFalse(is_anagram("barn", "bar"))
|
||||||
|
end
|
||||||
|
|
||||||
|
os.exit(luaunit.LuaUnit.run())
|
Loading…
x
Reference in New Issue
Block a user