Skip to content

Instantly share code, notes, and snippets.

@faizan1947
Created August 19, 2022 07:14
Show Gist options
  • Save faizan1947/91a1def3982e0ce4d13c1990adafc6eb to your computer and use it in GitHub Desktop.
Save faizan1947/91a1def3982e0ce4d13c1990adafc6eb to your computer and use it in GitHub Desktop.
for loop challenge
List<int> winningNumbers = [12, 6, 34, 22, 41, 9];
void main() {
List<int> ticket1 = [45, 2, 9, 18, 12, 33];
List<int> ticket2 = [41, 17, 26, 32, 7, 35];
checkNumbers(ticket2);
}
void checkNumbers(List<int> myNumbers) {
int matches=0;
for(int myNum in myNumbers){
for(int winningNum in winningNumbers){
if(winningNum==myNum){
matches++;
}
}
}
print('you have $matches matches');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment