Skip to content

Instantly share code, notes, and snippets.

@Spaceghost
Created March 23, 2012 17:08
Show Gist options
  • Save Spaceghost/2172834 to your computer and use it in GitHub Desktop.
Save Spaceghost/2172834 to your computer and use it in GitHub Desktop.
Recruiters...
Good Morning Johnneylee,
You have been selected for a phone interview. Prior to the interview, the hiring manager would like you to complete the following puzzle. Please complete and return to me.
=========== BEGIN PUZZLE TEST =============
Z1. "Queue-Tip"
Imagine a queue that looks like the following: ABCDEFGH
A is in slot 0 of the queue, and H is in slot 7. The alphabet gods have now
told you to defy the order of this queue on-demand. Your task is to write a
program that accepts pairs of values, one being a slot number, and the other
being a letter. The program should be able to accept any even combination of
unique slot numbers and letters, which pairs in the order of letters and
numbers received, and should throw an error if an odd number of arguments are
passed or if a slot number and letter are used more than once in the argument
list. Based on the input, the queue will change, and you will output the new
queue. Any letters that are not defined in the arguments passed should move
into the open slots in alphabetical order (much like a queue, ironically). If
no arguments are passed, the original queue should output. It is also safe to
throw an error if a letter that doesn’t exist in the queue is passed, and also
if a slot number is passed that is larger than the size of the queue.
Example input: Myprog 3 A B 5
Expected output: CDEAFBGH
Example input: Myprog A H 1 6 7 E
Expected output: BACDFGHE
Bad inputs: Myprog A 1 A 2 Myprog A 1 B 3 C
Z2. "Sort-sort-sort-it-out"
You're receiving a delimited text file, and it's very large (greater than 1GB).
Some fields contain alpha numeric characters, and fields may be duplicated. You
should process the file and output strings that occur multiple times in the
same field and the number of occurrences. You should also sort as you go,
meaning that the most frequently occurring words are at the top. Consider the
following concerns:
Simple, elegant code. Memory efficiency. Computational run time.
EXAMPLE: 1,2,3,4,5
foo,bar,foodbar,foobar,faboor
fSU_)d89fs-,sjdoknfpoi,doof,foobar,oiufs
&^T(^#(*&$,1233880,FOODBARz,%%YES%%,NV
apoif,bar,pf9,FOOBAR,null
The output would be
bar - column 2 - occurrences: 2
foobar - column 4 - occurrences: 2
foo - column 1 - occurrences: 1
fSU_)d89fs- - column 1 - occurrences: 1
etc...
Z3. "Tran-slay-tor"
You need to write a program that follows a simple interface. This interface has
one method/function/routine that accepts a single argument of a filepath and
returns a filepath to a new file it has written out. The method should be
called translate. It must be able to read an arbitrary set of chained
instructions and perform the translation described on the file. In cases of
ambiguity, simply document your decisions.
Entities your program should understand CHARACTER CONSONANT VOWEL NUMBER WORD LINE
Operators: +-/*><=
Actions you should support: REPLACE WITH REVERSE var PREPEND APPEND
Modifiers: CONSECUTIVE UNIQUE
So a given instruction set might look like:
consecutive vowels replace with 'x' consecutive consonants append 'bar' numbers > 10 reverse line
And they would respective produce outputs:
My name is foobar => My name is fxbar
I am happy to buy all 5 => I am happbary to buy all 5
There are 100s of foos! => !sxf fo s001 era erehT
============ END PUZZLE TEST ==============
Thank you,
- Niraj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment