daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function start() {
  2.     var secretPasscode = generateRandomPasscode();
  3.  
  4.     var i = 0;
  5.     while(true){
  6.         i++;
  7.  
  8.         var guess = "";
  9.  
  10.         for(var firstDigit = 0; firstDigit <= 9; firstDigit++){
  11.             guess += firstDigit;
  12.             for(var secondDigit = 0; secondDigit <= 9; secondDigit++){
  13.                 guess += secondDigit;
  14.                 for(var thirdDigit = 0; thirdDigit <= 9; thirdDigit++){
  15.                     guess += thirdDigit;
  16.                     for(var fourthDigit = 0; fourthDigit <= 9; fourthDigit++){
  17.                         guess += fourthDigit;
  18.                     }
  19.                 }
  20.             }
  21.         }
  22.         return guess;
  23.  
  24.         if(guess == secretPasscode){
  25.             break;
  26.         }
  27.         println("It took " + i + " guesses to get the correct");
  28.     }
  29.  
  30. }
  31.    
  32. function generateRandomPasscode() {
  33.     var randomPasscode = "";
  34.  
  35.     for(var i = 0; i < 4; i++) {
  36.         var randomDigit = Randomizer.nextInt(0, 9);
  37.         randomPasscode += randomDigit;
  38.     }
  39.  
  40.     return randomPasscode;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top