pjcook / jl-coding-challenge-017 Goto Github PK
View Code? Open in Web Editor NEWIn this challenge you need to create a function that determines whether a player or the dealer has won at the card game known in the UK as Pontoon. The function will receive one array containing all the cards for a player and another array containing all the cards for the dealer. It will return the winner (ie. “The player” or “The dealer”) and a description of the winning hand. Each card will be represented by two characters, the first character representing “rank” and the second character representing “suit”. Rank can be any of 2,3,4,5,6,7,8,9,T,J,Q,K,A (T=Ten, J=Jack, Q=Queen, K=King, A=Ace). Suit can be any of C,D,H,S (Clubs, Diamonds, Hearts, Spades). So TH will be 10 of Hearts. Winning hands (ordered by highest scoring) are: Pontoon - one card has a rank of ace and the other card is a picture card, i.e. has rank of J, Q or K. Five card Trick - there are five cards with a total value of 21 or less. Ace has value of one and picture cards have value of 10. The total value of the cards doesn’t matter as long as it is 21 or less. Highest total of 21 or less. Ace can have a value of one or eleven. e.g. two kings and an ace would have a value of 21 but an ace and a 3 would have a value of 14. Hands totalling more than 21 are “bust” and worth nothing The player must have a higher scoring hand than the dealer to win, otherwise the dealer wins. Sample data for a Pontoon: ["QH","AC"] Sample data for a five card trick: ["3D","2C","4H","AD","5C"] Sample data for total of 17: ["7C","AD","9H"] Sample data for total of 21: ["AD","8S","2H"] Sample data for total of 13: ["AD","AH","AS"]
License: MIT License