Skip to content

Instantly share code, notes, and snippets.

@sourabhxyz
Last active October 3, 2021 13:07
Show Gist options
  • Save sourabhxyz/eb7d804afd802fd45762b84b32aa18f2 to your computer and use it in GitHub Desktop.
Save sourabhxyz/eb7d804afd802fd45762b84b32aa18f2 to your computer and use it in GitHub Desktop.
Given the target number (which I would suggest you to play with), this program simulates various situations to reach it.
#include <iostream>
#include <cmath>
using namespace std;
int main () {
double target = 92.51; // update this value to your marks to see possible situations.
for (int rm = 0; rm <= 100; rm++) { // number of questions removed can either be 0 or all
int availableQuestions = 100 - rm;
double perQuestionMark = ((double) 200)/(double (100 - rm));
for (int i = 0; i <= availableQuestions; i++) { // correct questions range from zero to available
int corr = i;
for (int j = 0; j <= availableQuestions - i; j++) { // incorrect questions range from zero to available
double candidateMarks = perQuestionMark * ((double) i) - (perQuestionMark / 3.0) * ((double) j);
if (abs(candidateMarks - target) < 0.05) {
cout << "Removed questions: " << rm << " & per question marks therefore: " << perQuestionMark << ". Correct questions: " << i << " & Incorrect questions: " << j << " & candidate marks: " << candidateMarks << "\n";
}
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment