ZorakBane
Smash Journeyman
==============
Hypothesis
==============
Throw a hammer until you 9 once per life
==============
Results
==============
Throwing a hammer until you 9 is still 14.28% or a 1/7 chance.
==============
Data
==============
How many lives do you want to test?
4
How many times do you want to test?
65000
After 1820996 throws Average = 14.28%
Average throws perlife before a 9 is 7.00
How many lives do you want to test?
4
How many times do you want to test?
65000
After 1818474 throws Average = 14.30%
Average throws perlife before a 9 is 6.99
How many lives do you want to test?
5
How many times do you want to test?
65000
After 2279487 throws Average = 14.26%
Average throws perlife before a 9 is 7.01
How many lives do you want to test?
20
How many times do you want to test?
65000
After 9108878 throws Average = 14.27%
Average throws perlife before a 9 is 7.01
==============
Code
==============
#include <stdio.h>
#include <time.h>
int ham(int last1, int last2);
int main(void)
{
srand(time(0));
int i=0, j, jj, x=0, last1=2, last2=1, counter=0, throwsperlife=0, lives, times, average=0;
printf("How many lives do you want to test?\n");
scanf("%d", &lives);
printf("How many times do you want to test?\n");
scanf("%d", ×);
for(jj=0; jj<times;jj++)
{
for(j=1; j<=lives; j++)
{
do
{
x = ham(last1, last2);
throwsperlife++;
last1=last2;
last2=x;
}while(x!=9);
counter++;
printf("Died, reset throw probability\n\n");
last1=2;
last2=1;
}
}
printf("After %d throws Average = %.2f%%\n", throwsperlife, (float)((float)(counter*100)/(float)(throwsperlife)));
system("pause");
}
int ham(int last1, int last2)
{
int hammerval=0;
hammerval = 1 + rand()%9;
printf("Threw a %d\n", hammerval);
while( (hammerval==last1 || hammerval==last2) )
{
printf("Can't throw %d or %d, throwing again!\n", last1, last2);
hammerval = 1 + rand()%9;
printf("Threw a %d\n", hammerval);
}
return (int)hammerval;
}
==============
Sample Run
==============
How many lives do you want to test?
4
How many times do you want to test?
3
Threw a 5
Threw a 3
Threw a 4
Threw a 9
Died, reset throw probability
Threw a 8
Threw a 3
Threw a 8
Can't throw 8 or 3, throwing again!
Threw a 9
Died, reset throw probability
Threw a 1
Can't throw 2 or 1, throwing again!
Threw a 8
Threw a 1
Can't throw 1 or 8, throwing again!
Threw a 5
Threw a 4
Threw a 1
Threw a 8
Threw a 1
Can't throw 1 or 8, throwing again!
Threw a 2
Threw a 8
Can't throw 8 or 2, throwing again!
Threw a 4
Threw a 8
Threw a 1
Threw a 3
Threw a 2
Threw a 9
Died, reset throw probability
Threw a 9
Died, reset throw probability
Threw a 8
Threw a 9
Died, reset throw probability
Threw a 7
Threw a 6
Threw a 3
Threw a 9
Died, reset throw probability
Threw a 9
Died, reset throw probability
Threw a 5
Threw a 8
Threw a 7
Threw a 6
Threw a 5
Threw a 3
Threw a 8
Threw a 9
Died, reset throw probability
Threw a 7
Threw a 8
Threw a 8
Can't throw 7 or 8, throwing again!
Threw a 5
Threw a 3
Threw a 9
Died, reset throw probability
Threw a 5
Threw a 7
Threw a 6
Threw a 9
Died, reset throw probability
Threw a 4
Threw a 5
Threw a 7
Threw a 9
Died, reset throw probability
Threw a 1
Can't throw 2 or 1, throwing again!
Threw a 6
Threw a 8
Threw a 4
Threw a 6
Threw a 9
Died, reset throw probability
After 53 throws Average = 22.64%
Press any key to continue . . .
Hypothesis
==============
Throw a hammer until you 9 once per life
==============
Results
==============
Throwing a hammer until you 9 is still 14.28% or a 1/7 chance.
==============
Data
==============
How many lives do you want to test?
4
How many times do you want to test?
65000
After 1820996 throws Average = 14.28%
Average throws perlife before a 9 is 7.00
How many lives do you want to test?
4
How many times do you want to test?
65000
After 1818474 throws Average = 14.30%
Average throws perlife before a 9 is 6.99
How many lives do you want to test?
5
How many times do you want to test?
65000
After 2279487 throws Average = 14.26%
Average throws perlife before a 9 is 7.01
How many lives do you want to test?
20
How many times do you want to test?
65000
After 9108878 throws Average = 14.27%
Average throws perlife before a 9 is 7.01
==============
Code
==============
#include <stdio.h>
#include <time.h>
int ham(int last1, int last2);
int main(void)
{
srand(time(0));
int i=0, j, jj, x=0, last1=2, last2=1, counter=0, throwsperlife=0, lives, times, average=0;
printf("How many lives do you want to test?\n");
scanf("%d", &lives);
printf("How many times do you want to test?\n");
scanf("%d", ×);
for(jj=0; jj<times;jj++)
{
for(j=1; j<=lives; j++)
{
do
{
x = ham(last1, last2);
throwsperlife++;
last1=last2;
last2=x;
}while(x!=9);
counter++;
printf("Died, reset throw probability\n\n");
last1=2;
last2=1;
}
}
printf("After %d throws Average = %.2f%%\n", throwsperlife, (float)((float)(counter*100)/(float)(throwsperlife)));
system("pause");
}
int ham(int last1, int last2)
{
int hammerval=0;
hammerval = 1 + rand()%9;
printf("Threw a %d\n", hammerval);
while( (hammerval==last1 || hammerval==last2) )
{
printf("Can't throw %d or %d, throwing again!\n", last1, last2);
hammerval = 1 + rand()%9;
printf("Threw a %d\n", hammerval);
}
return (int)hammerval;
}
==============
Sample Run
==============
How many lives do you want to test?
4
How many times do you want to test?
3
Threw a 5
Threw a 3
Threw a 4
Threw a 9
Died, reset throw probability
Threw a 8
Threw a 3
Threw a 8
Can't throw 8 or 3, throwing again!
Threw a 9
Died, reset throw probability
Threw a 1
Can't throw 2 or 1, throwing again!
Threw a 8
Threw a 1
Can't throw 1 or 8, throwing again!
Threw a 5
Threw a 4
Threw a 1
Threw a 8
Threw a 1
Can't throw 1 or 8, throwing again!
Threw a 2
Threw a 8
Can't throw 8 or 2, throwing again!
Threw a 4
Threw a 8
Threw a 1
Threw a 3
Threw a 2
Threw a 9
Died, reset throw probability
Threw a 9
Died, reset throw probability
Threw a 8
Threw a 9
Died, reset throw probability
Threw a 7
Threw a 6
Threw a 3
Threw a 9
Died, reset throw probability
Threw a 9
Died, reset throw probability
Threw a 5
Threw a 8
Threw a 7
Threw a 6
Threw a 5
Threw a 3
Threw a 8
Threw a 9
Died, reset throw probability
Threw a 7
Threw a 8
Threw a 8
Can't throw 7 or 8, throwing again!
Threw a 5
Threw a 3
Threw a 9
Died, reset throw probability
Threw a 5
Threw a 7
Threw a 6
Threw a 9
Died, reset throw probability
Threw a 4
Threw a 5
Threw a 7
Threw a 9
Died, reset throw probability
Threw a 1
Can't throw 2 or 1, throwing again!
Threw a 6
Threw a 8
Threw a 4
Threw a 6
Threw a 9
Died, reset throw probability
After 53 throws Average = 22.64%
Press any key to continue . . .