You're at the job interview when this guy walks in and asks you to find the longest sequence in the first one million digits of pi that repeats three or more times.
What do?
You're at the job interview when this guy walks in and asks you to find the longest sequence in the first one million...
Ask him how this is relevant in my position.
I only know pi to 15 decimal places. I don't get the job.
I tell him there's infinite sequences in pi so that's impossible
Okay boy, apperently you are to retarded to understand my question. You'll hear from us. Bye.
I turn to the board and write 9. Then call the interview an idiot for not specifying from decimal point.
load array of 1 million digits of pi
start at 1. digit
incrementally increase length of sequence and find next 2 evenly spaced matches until no evenly spaced matches or end of array
keep track of longest match
shift to next digit
naive but should work.
forgot to add: check whether the evenly spaced matches form a continuous sequence.
...
YOU'RE FIRED
suggest a better algorithm :^)
> load array of 1 million digits of pi
well I would start with
string pie = string(pi)
then [spoiler]dive out the window as the whiteboard spontaneously combusts
I don't know about other languages but in Java that's not even close to the max size of an array
how is that not a valid spoiler goddamnit
return("234567");
Sup Forums doesn't have spoilers. We don't deal in fiction
What would you spoil on Sup Forums? The ending to the Linux kernel?
Linux kernel is already spoiled
hello, newfriend
here in Sup Forums we don't have spoilers. That's for Sup Forums and /mlp/ and those other boards. Please leave. Please.
>first one million digits
>infinite
???
uh, yeah? you want to generate new sequences for every comparison of unknown length?
gets phone from pocket, google it in front of him
let N be the digits of pi, and let k be the length of the longest common sequence repeating at least three times.
>generate first million digits of pi in O(N) time
>create suffix array in O(N) time
>find longest sequence in O(k*N) time
now let's discuss my future salary.
>alright user, could you write down such procedure in pseudocode?
Demand a green board and chalk. When I get them I throw the chalk at him and get out.
Calculate pie.
ctrl+f ten times
Do I get the job?
ask the candidate why he is asking me questions
Easy. Next.
bc -l
Thats only 4Mo of RAM
Find the longest sequence in the first one million digits of pi
that repeats three or more times.
bc -l
You're hiring whiteboards?
I was implying that calculating those 1 million digits was part of the interview question.
You're at the job interview when this guy walks in. He asks you mub da mo bidda te dat tum muhfugen bix nood cof bin dub ho muhfugga
What do?
>waiting a decade for bc to finish
>tr -d '\n\'
you mean tr -d '\\\n'
>grep -Eo '(.)\1+'
you mean grep -Eo '(.*)\1\1' but I'm not sure if that was the problem
I remind him that I am giving the interview, and that he is the applicant. No, sir, you do not get the job. Next!
if day == day
import pifacts
cout
What's the point of calculating PI when it's a constant?
Beat him to death with a whiteboard eraser
what?
>He missed the Sup Forums filename joke
Oh I get it now. I'm too nerd for that kind of "humor".
That is almost certainly a good thing user
call the cops
>if day == day
Fucking kek this got me good
don't relax.
I implement a BBP algorithm in clojure, then I add a core.memoize wrapper to it with the least-used caching strategy with the amount of invocation equal to 5 in order to minimize the RAM consumption.
After this crap is done I just run:
(filter #(= (memo-bbp (dec %)) (memo-bbp %) (memo-bbp (inc %))) (range 1 1000000)
Boom bitch, less than 10 mins of work