Skip to content

Commit

Permalink
Simplify the example solution.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanplusplus authored Oct 10, 2024
1 parent 062f96d commit 930df61
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion exercises/practice/dominoes/.meta/example.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ local function without_domino(dominoes, target)
end

local function can_chain(dominoes)
if #dominoes == 0 then
return true
end

local function recur(left, dominoes, right)
if #dominoes == 0 then
return left == right
Expand All @@ -29,7 +33,7 @@ local function can_chain(dominoes)
return false
end

return recur((dominoes[1] or {})[1], without_domino(dominoes, 1), (dominoes[1] or {})[2])
return recur(dominoes[1][1], without_domino(dominoes, 1), dominoes[1][2])
end

return { can_chain = can_chain }

0 comments on commit 930df61

Please sign in to comment.