Advertisement
peltorator

In-Code Stress

Apr 20th, 2021 (edited)
1,184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. mt19937 rnd(123);
  6.  
  7. int gen() {
  8.     return rnd() % 100;
  9. }
  10.  
  11. int smart(int n) {
  12.     if (n % 12 == 0) {
  13.         return 3; // uhh... stupid mistake!
  14.     }
  15.     return n * n;
  16. }
  17.  
  18. int stupid(int n) {
  19.     return n * n;
  20. }
  21.  
  22. int check(int n, int smartans, int stupidans) {
  23.     return smartans == stupidans;
  24. }
  25.  
  26. int main() {
  27.     for (int test = 0;; test++) {
  28.         if (test % 1000000 == 0) {
  29.             cout << "Running test # " << test << endl;
  30.         }
  31.         int n = gen();
  32.         int smartans = smart(n);
  33.         int stupidans = stupid(n);
  34.         if (!check(n, smartans, stupidans)) { // here we may not use any checker
  35.             cout << "Test found!" << endl << "n = " << n << ", smartans = " << smartans << ", stupidans = " << stupidans << endl;
  36.             break;
  37.         }
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement