Jump to content
• Advertisement

# Unity Need cram help for job application testing please !!!!

This topic is 5186 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Hello I am so excited, i just got short listed for a job interview so they must have liked at least something about my game demo that the GameDev.net community helped me so much with. ;p The position is for a Junior Programmer and I have to do a '3 hour software test' as part of the next stage. They gave me no clue other that that.... So I have about 40hrs - 2 sleeps to prepare and I am not sure how I should spend my time. I'm thinking I will be digging out my c++ books and just brushing up on that. Possibly also looking a little at the DirectX API which I am kind of familiar with. Is anyone here in a position to be able to offer me some advice on this??

#### Share this post

##### Share on other sites
Advertisement
Hey,

Nothing that is obvious aside from:

Get enough sleep.

[and other general study stuff] - Also depending on how competent they are, you should possibly be prepared for silly questions about doing multiplication using only shifting and addition and that sort of stuff.

Hope it helps.

CJM

#### Share this post

##### Share on other sites
Check out the tests at the bottom of this site

http://www.codesampler.com/miscsrc.htm

Good Luck

#### Share this post

##### Share on other sites
Hey thanks a lot guys !

Those tests look like just the sort of thing i need to look into ;p

"multiplication using only shifting and addition"......can anyone explain how to do this ?

#### Share this post

##### Share on other sites
Quote:
 Original post by bobbinusHey thanks a lot guys !Those tests look like just the sort of thing i need to look into ;p"multiplication using only shifting and addition"......can anyone explain how to do this ?

If you know long multiplication (which I would assume you do) then "multiplication using only shifting and addition" is basically just that in binary.

We all know that multiplying by 10 in decimal just involves shifting all the figures to the left then putting a zero at the end. It's similar in binary when multiplying by %10 (2 in decimal), i.e. shift left then put a zero at the end.

e.g.

%1101 * %0110=

(%00001101 * %0[bit 0])+
(%00011010 * %1[bit 1])+
(%00110100 * %1[bit 2])+
(%01101000 * %0[bit 3]) =

(%00011010 * %1)+
(%00110100 * %1) =
%1001110

In code, you would shift the multiplier to the right each time and if a 1 came out add the multiplicand to the result. Then shift the multiplicand left. Do this in a loop for all bits in the multiplier.

As to your original question, there's many different formats your test could take, from writing a function to do a particular job to a few smaller tests such as IQ tests, questions on c++, debug a small function etc. I don't think there's anything you can really prepare for.

In fact, they probably don't want you to prepare which is why they won't tell you what form the test will be. They will probably want to see how youthink about problems and how you go about solving them.

Good luck anyway.

#### Share this post

##### Share on other sites
Quote:
 Original post by bobbinusHey thanks a lot guys !Those tests look like just the sort of thing i need to look into ;p"multiplication using only shifting and addition"......can anyone explain how to do this ?

Left-Shifting doubles the value of a number, so multiplication by a power of 2 can be easily achieved.

Multiplying by a number close to a power of 2 can be achieved by combining left-shifting with addition/subtraction:

a = (a << 3)-a;//multiply a by 8 then subtract a, giving a final value of a*7.

I've also been asked how to count the number of set-bits in an integer in O(n) where n is the number of set bits (Rare asked me this)

That can be done like this:
unsigned int bitCount(unsigned int data){    unsigned int count=0;    while(data)    {        data &= data-1;        ++count;    }    return count;}

They key to understanding this is that subtracting 1 from a number unsets the least significant set bit and sets all less significant bits:

e.g. 10001000 - 1 == 10000111;

so x &= x-1; simply unsets the least significant set bit.

#### Share this post

##### Share on other sites
Quote:
 Original post by bobbinus"multiplication using only shifting and addition"......can anyone explain how to do this ?

Like so:

result = 640 * y //starting example equasion which we wish to evaluate using only addition & shifting
result = (512 + 128) * y //step 1: distribute the constant into a sum of powers of two.
result = (512 * y) + (128 * y) //step 2: distribute the other operand
result = (2^9 * y) + (2^7 * y) //step 3: convert into power-of-two representation (equasion uses ^ as in power (e.g. BASIC ^) not binary xor (e.g. C++ ^))
result = (y << 9) + (y << 7); //step 4: convert each power-of-two representation into shifts, ala this equivilancy: (2^n * y) == (y << n)

This is an ancient "optimization" back from the days of C compilers without optimizers. Any recent compiler should in fact automatically do this conversion for you as needed, meaning the difference is only cosmetic.

#### Share this post

##### Share on other sites
Hehe. I like this question (from the Codemasters test, linked above):
Quote:
 What does mysteryFunction3D() compute?struct vector_3d_typ {// a 3-D vector along with normalization factorfloat x,y,z,w; } vector_3d,*vector_3d_ptr;float mysteryFunction3D_1(vector_3d_ptr u,vector_3d_ptr v){return( (u->x * v->x) + (u->y * v->y) + (u->z * v->z));}

Since it's under the "3D" section of the test I assume they're looking for an answer of "the (unnormalized) dot product", but in actual fact the answer is "nothing"!. They forgot to typedef their struct, so vector_3d_ptr is a global variable of type vector_3d_typ *, not a type and subsequently mysteryFunction3D_1 fails to compile. [lol]

Enigma

#### Share this post

##### Share on other sites
Go learn the format of the floating point- how many bits are used for the mantissa and the exponent. People love asking about that.

Actually, make sure you know the typical sizes of all the data types.

The floodfill algorithm is popular, I've had to write that one like 3 times. Hint: Don't use recursion. Depending on how big the area is to be floodfilled, either keep a big queue for "next cells to look at", or have a flag for every pixel/cell that means "checked".

In fact, I remember one question that just asked "what is a better way to solve this problem, iteration or recursion?" The answer is almost always iteration.

Also, the quicksort algorithm seems to show up a lot. Luckily I don't think anyone has asked me to write quicksort from memory, which is good because it's a damn confusing algorithm. More likely, they'll show you a broken version of quicksort and ask you to fix it.

And these days, everybody seems to throw in a question about 3d math. Here's an example of one that I got: "Given a triangle defined by points A,B,C (<Ax,Ay,Az>, <Bx,By,Bz>,<Cx,Cy,Cz>) using clockwise winding, determine whether point P (<Px,Py,Pz>) is in front of the triangle, behind it, or coplanar."

#### Share this post

##### Share on other sites
A test I was asked to complete had these sort of questions:

1. Some round about word problem that required binary partitioning. [a range of numbers, and you could tell if the answer was 'above' or 'below' a given guess, so you divide the range in two, successively until you find the solution]

2. Write a pathfinding function for a basic map type.

3. Add two abritrarily long strings, and return the result as a string.

4. Define an object class which has to do such-and-such things. [how to design for collision detection elegantly]

and one other I don't remember.

#### Share this post

##### Share on other sites

• Advertisement
• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• Advertisement

• ### Popular Now

• 12
• 30
• 9
• 16
• 12
• Advertisement
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!