id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

lotteryTicketCheckerWithRepeats


The method lotteryTicketCheckerWithRepeats() takes an integer arraylist for the winning numbers and another integer arraylist for your numbers. It returns a score that is determined using the following rules:
+ 3 points given for every exact number match in the exact right spot.
+ 1 point given for every number matched in the wrong spot. NOTE: In this example there's a chance the numbers can be repeated. For example [1, 1, 1, 1, 1], [1, 2, 3, 4, 5] should only return 3 because as soon as there's an exact match, it shouldn't also count for another match.


lotteryTicketCheckerWithRepeats([1, 2, 3, 4, 5], [1, 3, 2, 4, 5]) → 11
lotteryTicketCheckerWithRepeats([1, 2, 3, 5, 4], [9, 2, 3, 4, 5]) → 8
lotteryTicketCheckerWithRepeats([1, 1, 1, 1, 1], [1, 2, 3, 4, 5]) → 3

...Save, Compile, Run (ctrl-enter)

public int lotteryTicketCheckerWithRepeats(ArrayList<Integer> winner, ArrayList<Integer> ticket){ }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 300 Post-solution available

Copyright Nick Parlante 2017 - privacy