My Job Interview at Google
51–60 of 114 posts
Re: My Job Interview at Google
#52He seems pretty excited for not getting the job.
SREs are on call. That means they carry a pager/cell phone and must be accessible at all times. He should be happy he didn't get picked ;).
Nope, just when they're on call. I was snowboarding in Montana for a week last winter with my google SRE buddy, so I'm pretty sure about this :)
Re: My Job Interview at Google
#53Could anyone point me on how to solve this(either a solution or preferrably a pointer on how to get to it): "Q: Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7." First I thought it was simple but the I got stuck, maybe I'm just tired. No matter how I twsit and turn it I seem to get only an even distribution over 5 numbers.
I'll give you a hint, though - the solution is not elegant at all. Which is part of the point.
Re: My Job Interview at Google
#54Could anyone point me on how to solve this(either a solution or preferrably a pointer on how to get to it): "Q: Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7." First I thought it was simple but the I got stuck, maybe I'm just tired. No matter how I twsit and turn it I seem to get only an even distribution over 5 numbers.
Execute f 7 times, add all numbers, call that x. Then you do mod(x,7)+1, and you get a random number between 1 and 7. If the original function was unbiased, this one is going to be unbiased too.
Re: My Job Interview at Google
#55Earlier quoted context omitted.
It's actually * and &. ;-) Don't interview for positions in languages you've forgotten, then, or brush up and re-learn stuff before the interview. It's like riding a bike...it comes back to you. Not being able to remember pointer syntax is a serious problem if you're being hired to program in C. I can understand why they'd want to weed out anyone who can't get that, particularly given how many candidates they have.
lol, thanks. I could have said x[i] is the same as ^(x + i) and really thought that was the correct syntax. The problem is I have used enough languages and dialects that I really can't brush up on it all. I just say if it's been five years, let me break out my cheet sheet for that stuff. PS: Ok, if it was really just a C job of course I would focus on that. Edit: Dammit it is like riding a bike. I have been having C…
Re: My Job Interview at Google
#56Re: My Job Interview at Google
#57Earlier quoted context omitted.
Execute f 7 times, add all numbers, call that x. Then you do mod(x,7)+1, and you get a random number between 1 and 7. If the original function was unbiased, this one is going to be unbiased too.
This won't work. f gives 1 to 5. 7 * f gives 7 to 35. But 7 to 35 will not be evenly generated. Think about it: There are more ways to get a 20 than there are to get a 7 or a 35. Same thing with rolling 2 die.
I didn't want to go through all 5^7 possibilities for the 7-die case, but I figured it's likely enough that he's right that I'd keep my mouth shut.
Re: My Job Interview at Google
#58Earlier quoted context omitted.
Execute f 7 times, add all numbers, call that x. Then you do mod(x,7)+1, and you get a random number between 1 and 7. If the original function was unbiased, this one is going to be unbiased too.
This won't work. f gives 1 to 5. 7 * f gives 7 to 35. But 7 to 35 will not be evenly generated. Think about it: There are more ways to get a 20 than there are to get a 7 or a 35. Same thing with rolling 2 die.
Re: My Job Interview at Google
#59Could anyone point me on how to solve this(either a solution or preferrably a pointer on how to get to it): "Q: Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7." First I thought it was simple but the I got stuck, maybe I'm just tired. No matter how I twsit and turn it I seem to get only an even distribution over 5 numbers.
;; * SPOILER? *
(defun rand7 ()
(loop (let ((result (+ (1- (rand5))
(1- (rand5)))))
(if (
;; * SPOILER *edit: If it doesn't work I'd like to know why...
Re: My Job Interview at Google
#60Could anyone point me on how to solve this(either a solution or preferrably a pointer on how to get to it): "Q: Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7." First I thought it was simple but the I got stuck, maybe I'm just tired. No matter how I twsit and turn it I seem to get only an even distribution over 5 numbers.
http://ariya.blogspot.com/2007/11/random-number-15-to-17.htm...
He gives a few different ways to solve it, most with uniform distribution.