# Random Interview Questions

interview questions shared by candidates

## Random Interview Questions

You are given a predefined function which generates random number from 1 to 5. You need to use this function and create another function which will generate random number from 1 to 7. Now most important thing is to remember that new random function should be even (i.e. the number generated should be unpredictable, and evenly spaced out). Represent 7 in binary (111). For each place, set either 0 or 1 depending on your random number generator -- roll between 1-5, reroll if you get 5, otherwise set the bit to 0 if the roll is 1 or 2, and 1 if the roll is 3 or 4. Full function: int random7() { for (int i=0; i < 3; i++) { int answer = 0; int roll = 5; while (roll == 5) { roll = drand48()*5+1; } if (roll < 3) answer |= 1 << i; } return roll; } If the function returns float or double: - Simply multiply the answer by 7/5. If the function returns integers: - Call the rand5 function 7 times, sum the results, calculate mod7 of the sum and finally add 1. Let f() be the random function that returns a number between (1,5). Let g() = f() -1; then g is a function that returns a number between (0,4). Let h() = g()/4; then h is a function that returns a number between (0,1). Let i() = h()*6; then i is a function that returns a number between (0,6) Let j() = i() + 1; then j is a function that returns a number between (1,7). important to note that simply multiplying by 7/5 is NOT correct. If you do that you can never get 1 out of your random number . the numbers you will obtain in that case will be uniformly distributed between (7/5 and 7) not between (1,7) Show More Responses |

How do I know that you wouldn't accept a position from a totally different company if you were called upon by a recruiter, and offered $10k or $20k more per year? |

How would you go about counting the blades of grass on a football field? |

"Team Edward or Team Jacob?" |

What skills do you have that may not be on your resume? |

Define chaos. |

What do you want to be when you grow up? |

You don't make eye contact very much, do you have problems with your father? |

Sell me something? |

Describe to me what the position is that you're applying for. |

**1**–

**10**of

**20**Interview Questions