Games

# Computer, Games: Hacked app solutions Levels 1-3 (Copied)

Stage One:

input + 1;

Stage Two:

input> 0;

Stage Three:

if input < 0 {
return -input;
}
return input;

Stage Four:

abs(input);

Level two: High School Hack

Stage One:

while var_a < input {
var_b = var_b + input;
var_a++;
}
return var_b;

Stage Two:

pow(input, 2);

Stage Three:

foreach var_a in input {
var_b++;
}
return var_b;

Stage Four:

var_a = [];
while var_b < input {
var_a.push(var_b);
var_b++;
}
return var_a;

Hacked App – level three: Jailbreak

Stage One:

foreach var_a in input {
if var_a > var_b {
var_b = var_a;
}
}
return var_b;

OR

while var_a < input.length { if input[var_a] > var_b {
var_b = input[var_a];
}
var_a++;
}
return var_b;

Stage two:

foreach var_a in input {
var_b = max(var_b, var_a);
}
return var_b;

OR

while var_a < input.length {
var_b = max(var_b, input[var_a]);
var_a++;
}
return var_b;

Stage three:

while input > 1 {
input = input – 2;
}
return input;

OR

if input / 2 * 2 == input {
return 0;
}
return 1;

Stage four:

foreach var_a in input {
if var_a != input.pop {
return false;
}
}
return true;

OR

while var_a < input.length {
if input[var_a] != input[input.length – 1 – var_a] {
return false;
}
var_a++;
}
return true;

# Games, Mathematics:Probability Puzzles

Incremental Update

Probability puzzle is available on google app store:

it comprises of 3 levels of difficulty:

1. Easy Peasy:
1. Julius Ceasar tosses two fair coins, probability of two heads?
Hint: [h,h – h,t – t,t – t,h]
2. six individual socks, 2 red,2 blue, 2 purple.
probability of blindly picking a matching pair.
Hint: [you already picked one of six, the rest are 5, one of which is matching the one you have]
3. rolling a fair six-sided dice, probability of even number.
Hint: [1,2,3,4,5,6]
4. roll two fair independent six-sided dice, probability of getting 12 in total.
Hint: [1,1-1,2-1,3,………6,6]
5. boys’ birth probability 0.51, girls’ 0.49, the probability of getting 2 girls birth.
6. in a perfectly shuffled deck of 52 cards, with 4 aces, what is the probability of drawing 2 aces.
Hint: if you draw one card, the deck is less by one.
7. in 40 cards deck with 4 aces-yet not drawn- what is the probability of drawing only one ace in two draws.
Hint: first pick is ace, 4/40 and second pick is not an ace 36/39, remember these are 2 draws
8. a deck contains 4 suits, 13 cards each, the probability of drawing two cards of same suit.
Hint: first draw doesn’t count, in the second draw the deck is 51 cards this time and 12 cards of the required suit.
9. These weird monkey favors 3 types of berries, red, yellow, blue.
but not all monkeys created equally.
the probability of a monkey favoring red to blue and yellow
Hint: [RYB,RBY,BRY,BYR,YRB,YBR], this trick here is the monkey prefers red over blue, but you are not sure that she prefers yellow to red or blue.
10. you have stolen from the king, he is feeling generous, you are a smart guy, maximize you chance of survival in his game, 100 marbles, 50 white and 50 black marbles, put them in 2 jars.
Jars have 50-50 chance to b picked.
Hint:
Answer: (1/2)*(1)+(1/2)*(49/99) = (1/2)+(0.495)=0.747 (Good Luck)
11. Alice and Bob found unfair coin of 72% heads to 28% tails, they agreed to a game Alice will toss twice, if it comes up Heads then Tails, she wins; If came up Tails then Heads, Bob wins; if came up Heads or Tails it is a draw. What is Bob’s probability of winning?
Hint: Since the two consecutive coin tosses are independent, Pr[HT]=Pr[H]Pr[T], and Pr[TH]=Pr[T]Pr[H]. Does the winner depend on the bias Pr at all?(Note that the probability that someone wins in the first round does depend on the bias; but since the game is repeated until either HT or TH happens, it does not. For more, you may want to read about von Neumann’s trick; essentially, Alice and Bob have equal chances of winning, but the (expected) duration of the game will depend on the bias p=0.72))
Copied from http://math.stackexchange.com/questions/1622474/what-is-the-probability-of-bob-winning-the-game
12. boys’ birth probability 0.51, girls’ 0.49, researcher is interested to interview 50 families in which they are exactly 8 children.
what is the probability that at least in one family the children will all be of the same gender?
Hint:
13. Monty Hall game with 10 doors 9 goats and a car, if you switch what is your probability of winning the car?
Hint: at first you picked a door of 1/10 chance of winning, when the 8 doors were eliminated, the remaining one door (the one you didn’t pick) its chance didn’t change still at 1/10, but you odds have changed from 1/10 to 9/10.
14. you roll 2 six-sided fair dices, the probability that the sum of outcome is 7.
Hint: only 6 combination of dices can result of 7, the total outcomes are 36.
15. 0.05 of population are gays, 0.95 are straight, Susie can guess with 90% accuracy if one is gay or straight, what is the possibility that one is gay?
Hint:
16. the three dice puzzles,
Hint:
17. ancient Romans, [0,2], [2,10],[10,30],[30,70] and [70,90], what is the life expectancy of an ancient Roman, who was still alive at age of 30?
Hint:
18. a friend wants you to guess the amount of money he has, if yuo guess right the cash is yours, 50% chance he has 0$, 25% chance he has 1$,  24% chance he has 100$, 1% chance he has 1000$ what is the amount you should guess in order to maximize your experience?
Hint:
19. two departments A and B, A has a 50-50 men-women ratio,  B has 0.1 men and 0.2 women.
the overall acceptance in both departments are 0.3for men, and 0.25 for women.
2. Getting serious:
1. well, you are tossing a dice, How many tosses to get a number larger than 4.
Hint: [5,6]
2. what is the probability that some of the people shares their birthday.
3. Outrageous:

That is my progress so far.

# Business, Culture, Games: 4 Valuable business lessons I learned from Civilization Revolution

While on vacation at Outer Banks, I’ve been playing Civilization Revolution on my iPod touch and got an idea to create and article sharing the few lessons that I have learned from it. Continue reading