using Test function countCards(cards) counter = zeros(Int64, 10, 1) for card in cards counter[card + 1] += 1 end return counter end function numberToCards(number, base = 10) counter = zeros(Int64, 10, 1) digits = Base.digits(number, base = base) for digit in digits counter[digit + 1] += 1 end return counter end function compareCards(received, necessary) for i in 1:10 if received[i] < necessary[i] return false end end return true end function checkWill(cards) received = countCards(cards) necessary = numberToCards(6174) return compareCards(received, necessary) end function checkTaki(cards) received = countCards(cards) necessary = numberToCards(6174) + numberToCards(7711) return compareCards(received, necessary) end function checkJackson(x, cards) received = countCards(cards) necessary = numberToCards(6174) + numberToCards(7711) + numberToCards(x) return compareCards(received, necessary) end function checkWillBase(b, cards) received = countCards(cards) necessary = numberToCards(6174, b) return compareCards(received, necessary) end # Seção de testes function extra_test() @testset "Extra Tests" begin @test !checkWill([0, 1]) @test !checkWill([0, 2, 3, 5, 8, 9]) @test checkWill([1, 4, 6 ,7]) @test checkWill([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) @test !checkTaki([1, 4, 6, 7]) @test !checkTaki([1, 1, 7, 7]) @test !checkTaki([1, 1, 4, 6, 7, 7]) @test checkTaki([6, 1, 7, 4, 7, 7, 1, 1]) @test !checkJackson(10, [0, 1]) @test !checkJackson(42, [1, 4, 6, 7, 1, 1, 7, 7]) @test !checkJackson(12345, [1, 2, 3, 4, 5, 6, 1, 7, 7]) @test checkJackson(1234, [6, 1, 7, 4, 1, 1, 7, 7, 1, 2, 3, 4]) @test checkJackson(0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 7, 7]) @test checkJackson(777, [7, 7, 6, 1, 7, 4, 1, 1, 7, 7, 1, 2, 3, 4, 7]) @test !checkWillBase(3, [6, 1, 7, 4]) @test !checkWillBase(4, [6, 1, 7, 4]) @test !checkWillBase(8, [6, 1, 7, 4]) @test checkWillBase(7, [3, 2, 4, 8, 8, 8, 0, 0, 0, 1]) @test checkWillBase(9, [1, 8, 4, 5, 2, 9, 3, 0]) @test checkWillBase(10, [6, 1, 7, 4]) end end