0
QUESTION: In football, teams fight over field space and score points in two different ways: through the touchdown, which can be worth 6 or 7 points and through the goal kick, which is worth 3 points. When a team enters the opponent’s touchdown area, it immediately scores 6 points and is entitled to a goal kick worth 1 extra point. Finally, the scoreboards of the games are assembled by the possibility of making 3, 6 or 7 points, which means that some scoreboards are impossible to happen as do 5, 13 or 22 points. Your task will be to have a collection of scoreboards from a team (array) and identify whether or not the scoreboards are achievable.
Ex: 17 invalid score, 10 valid score
The conditions that I achieved were several, but because it is a challenge I believe that the code does not get big, so I did not put all:
declared an array with scores. The program only needs to tell if they are valid scores or not.
int placarNY[10] = {17, 26, 22, 10, 21, 18, 15, 24, 35, 19};
for(int i = 0; i < 10; i++){
if((placarNY[i]%3 == 0) ||(placarNY[i]%7 == 0)||(placarNY[i]%10 == 0)){
cout << placarNY[i] << " <- placar valido !" << endl;
}else{
cout << placarNY[i] << " <- placar invalido !" << endl;
}
}
The logic of this challenge is to check if they exist
A
,B
andC
integers such thatA*3 + B*6 + C*7 = P
, beingP
the score you want to know if it is valid or not– Jefferson Quesado