Elyse, magician-to-be, continues her training. She will be given several decks of cards that she needs to perform her tricks. To make things a bit easier, she only uses the cards 1 to 10. She only has one of each card, there are no duplicates in her decks of cards.
In this exercise, use methods from Julia's Base library to analyse the contents of an array.
Elyse wants to determine if a card is present in the deck -- in other words, if the deck contains a specific number.
julia> card = 3;
julia> has_card([2, 3, 4, 5], card)
trueElyse wants to know the position (index) of a card in the deck.
If the card is not in the deck, return nothing.
julia> card = 2;
julia> find_card([9, 7, 3, 2], card)
4Elyse wants to know if every card is even -- in other words, if each number in the deck is even.
julia> all_cards_even([2, 4, 6, 7])
falseElyse wants to know if there is an odd number in the deck.
julia> any_odd_cards([3, 2, 6, 4, 8])
trueElyse wants to know the position of the first card that is even.
If there are no even cards in the deck, return nothing.
julia> first_even_card_idx([5, 2, 3, 1])
2Elyse wants to know the value of the first card that is odd.
If there are no odd cards in the deck, return nothing.
julia> first_odd_card([4, 2, 8, 7, 9])
7Elyse, magician-to-be, continues her training. She will be given several decks of cards that she needs to perform her tricks. To make things a bit easier, she only uses the cards 1 to 10. She only has one of each card, there are no duplicates in her decks of cards.
In this exercise, use methods from Julia's Base library to analyse the contents of an array.
Elyse wants to determine if a card is present in the deck -- in other words, if the deck contains a specific number.
julia> card = 3;
julia> has_card([2, 3, 4, 5], card)
trueElyse wants to know the position (index) of a card in the deck.
If the card is not in the deck, return nothing.
julia> card = 2;
julia> find_card([9, 7, 3, 2], card)
4Elyse wants to know if every card is even -- in other words, if each number in the deck is even.
julia> all_cards_even([2, 4, 6, 7])
falseElyse wants to know if there is an odd number in the deck.
julia> any_odd_cards([3, 2, 6, 4, 8])
trueElyse wants to know the position of the first card that is even.
If there are no even cards in the deck, return nothing.
julia> first_even_card_idx([5, 2, 3, 1])
2Elyse wants to know the value of the first card that is odd.
If there are no odd cards in the deck, return nothing.
julia> first_odd_card([4, 2, 8, 7, 9])
7