Skip to content

Instantly share code, notes, and snippets.

Created August 14, 2017 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/358f1fff12e5f0a95789d373c9288a76 to your computer and use it in GitHub Desktop.
Save anonymous/358f1fff12e5f0a95789d373c9288a76 to your computer and use it in GitHub Desktop.
//*******************************************************************
// Dear CompileJava users,
//
// CompileJava has been operating since 2013 completely free. If you
// find this site useful, or would otherwise like to contribute, then
// please consider a donation (link in 'More Info' tab) to support
// development of the new CompileJava website (stay tuned!).
//
// Most sincerely, Z.
//*******************************************************************
import java.util.Random;
public class MainClass {
public static void main(String[] args)
{
int expCount = 10000000;
int successCount = 0;
Random random = new Random();
for(int i=0; i<expCount; i++)
{
int selection = random.nextInt(3);
int realValue = random.nextInt(3);
if(selection==realValue) //player's chosen the right card and doesn't give a fuck
successCount++;
}
double percentage = ((double)successCount/(double)expCount)*100;
System.out.println(percentage + "%");
successCount = 0;
for(int i=0; i<expCount; i++)
{
int selection = random.nextInt(3);
int realValue = random.nextInt(3);
if(selection==realValue) {} //player's chosen the right card but now changes it and fails
else successCount++; //player's chosen the WRONG card but now changes it for the right one
}
percentage = ((double)successCount/(double)expCount)*100;
System.out.println(percentage + "%");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment