Game programming test(Interview test)

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, this is my solution to the TISC question:
STO A,1 -- Write register a to mem 1
SUB A,0 -- Set register a to ('a-$0)
SUB A,1 -- Set register a to ('a-$0)-$1=='a-$0-'a==$0
STO A,1 -- Write register a (which is now $0) to mem 1

Note that 'a in the comments is the inital value of register a, it's not the updated value. So this should work as expected, with only one register and 4 instructions.
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Well, my roommate solution was only one register too, but I don,t see a case where yours doesn't work. Nice. I didn't touch the problem at all for that matter, just sent my roommate answer to Halifax for confirmation, that's all.

I can see something like that in a test. And while that solution, if no problem arise IS better, if the question asked for the solution in 7 steps (which is unclear in Halifax post), I know some places that would actually see it as only a partial answer because it does not meet the criteria. Giving both answer might give bonus points on the other hand. No matter, I'm interested to know if Hybrid's answer can be wrong in some context. I don't think so, but I'd like to know :P
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

I had such tests when I was qualifying to some unit in the army (haven't joined yet) and they said that you must not pass X lines with your answer though the answer can be X or less lines and passing the X-th line just make you loose some points but doesn't cancel your answer completely.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Haha, you can also repeat the last line until 7 statements are done :wink:
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Indeed. I did a smarty pant answer like that once in an interview and the interviewer was half-laughing for the next 5 minutes ^^
I received an offer that time ;)
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

hybrid wrote:Ok, this is my solution to the TISC question:
STO A,1 -- Write register a to mem 1
SUB A,0 -- Set register a to ('a-$0)
SUB A,1 -- Set register a to ('a-$0)-$1=='a-$0-'a==$0
STO A,1 -- Write register a (which is now $0) to mem 1

Note that 'a in the comments is the inital value of register a, it's not the updated value. So this should work as expected, with only one register and 4 instructions.
If my test case serves me correct, that doesn't work. The value swapped to $1 is negative $0:

Code: Select all

$0 - 24
$1 - 31
A - 12
B - 15

STO A,1 ($1 = 12)
SUB A,0 (A - $0 = 12 - 24 = -12)
SUB A,1 (A - $1 = -12 - 12 = -24)
STO A,1 ($1 = -24)

$1 = -24
Remember that the value of A, B, $0, and $1 are all random when the system starts up.
TheQuestion = 2B || !2B
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hmm, you're right. I also wrote that in my comment :oops:
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

If only TISC had a NEG <register> command. :lol: Then it would be the best processor out there.
TheQuestion = 2B || !2B
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

ROFL!! At first I read it as NGE.. :lol:
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
Post Reply