[Week 2] Sample Game Programming Interview Question

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 23631 Views - Last Post: 14 April 2011 - 06:26 AM

#1 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1009
  • View blog
  • Posts: 4,197
  • Joined: 14-February 08

[Week 2] Sample Game Programming Interview Question

Post icon  Posted 11 February 2011 - 09:39 AM

*
POPULAR

After some feedback from the previous question I thought it might be interesting to split this post into two questions. One is more technical to broaden or test your knowledge and the other is a more general interview question.

The second question is just something that might possibly pop up in an interview and you don't need to post the answer here. If you have tips for answering the question then post them.

So post your answer to question one in spoiler tags and have a good think about question two :)

Question 1 : Technical Question

Using bitwise (or bit shift) operators, can you optimise the following examples?

1. int a = b * 4; 
2. int a = b * 72;
3. int a = (b + c) / 2;
4. int a = (b * 3) / 8;
5. int a = (b % 8) * 4;


Question 2 : General Interview Question

What's the best game of all time and why?

I look forward to seeing your answers :)

This post has been edited by stayscrisp: 11 February 2011 - 02:27 PM


Is This A Good Question/Topic? 7
  • +

Replies To: [Week 2] Sample Game Programming Interview Question

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: [Week 2] Sample Game Programming Interview Question

Posted 11 February 2011 - 11:09 AM

For question 1 do you mean 'bit shift'? :)
Was This Post Helpful? 0
  • +
  • -

#3 xTorvos  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 61
  • View blog
  • Posts: 271
  • Joined: 23-October 09

Re: [Week 2] Sample Game Programming Interview Question

Posted 11 February 2011 - 11:38 AM

1. I suck with bit twiddling and I may even be doing this completely wrong, but I'll post one anyway.

Spoiler


Criticism and a better answer is appreciated. :)

2. Pacman. It's not my favorite game (that's Legend of Zelda: Ocarina of Time), but I think it's the best game of all time because it has enchanted the hearts of millions. You would be hard-pressed to find a person in the United States that has never heard of, seen, or played a game of Pacman.

This post has been edited by xTorvos: 11 February 2011 - 11:41 AM

Was This Post Helpful? 0
  • +
  • -

#4 Fib  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 161
  • View blog
  • Posts: 554
  • Joined: 12-March 09

Re: [Week 2] Sample Game Programming Interview Question

Posted 11 February 2011 - 12:20 PM

I'm definitely a noob at this, but i'm going to try anyway.

Spoiler


How much would this speed up your code? Would anyone notice a difference in the speed if all operations were done bitwise? Also, would one be expected to learn this in school? I'm a junior in a computer science program and I have never learned this before.

Let me know if I did it correct, if not then let me know what I did wrong please.

I think my favorite game of all time is The Legend Of Zelda: A Link to the Past. Just wanted to throw that in there :)

This post has been edited by Fib: 11 February 2011 - 12:30 PM

Was This Post Helpful? 0
  • +
  • -

#5 ghillieLEAD  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 208
  • Joined: 08-March 10

Re: [Week 2] Sample Game Programming Interview Question

Posted 11 February 2011 - 12:30 PM

Can't see what other people have done on my phone, the show spoiler button doesn't seem to work on the iPhone. I hope I'm not just adding the same stuff other people have done. Some of these I'm not sure if they're even much faster. I gave it a shot at least.

Spoiler

Was This Post Helpful? 0
  • +
  • -

#6 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1009
  • View blog
  • Posts: 4,197
  • Joined: 14-February 08

Re: [Week 2] Sample Game Programming Interview Question

Posted 11 February 2011 - 12:30 PM

View PostButchDean, on 11 February 2011 - 06:09 PM, said:

For question 1 do you mean 'bit shift'? :)

I would think that bit shift could be encompassed into bitwise. I know that they aren't due to the fact that bit shift does not operate on pairs of bits, but hey!
Was This Post Helpful? 0
  • +
  • -

#7 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: [Week 2] Sample Game Programming Interview Question

Posted 11 February 2011 - 12:38 PM

View Poststayscrisp, on 11 February 2011 - 07:30 PM, said:

View PostButchDean, on 11 February 2011 - 06:09 PM, said:

For question 1 do you mean 'bit shift'? :)

I would think that bit shift could be encompassed into bitwise. I know that they aren't due to the fact that bit shift does not operate on pairs of bits, but hey!

It's just a bit more specific. :)
Was This Post Helpful? 0
  • +
  • -

#8 ghillieLEAD  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 208
  • Joined: 08-March 10

Re: [Week 2] Sample Game Programming Interview Question

Posted 11 February 2011 - 12:45 PM

View PostButchDean, on 11 February 2011 - 12:38 PM, said:

View Poststayscrisp, on 11 February 2011 - 07:30 PM, said:

View PostButchDean, on 11 February 2011 - 06:09 PM, said:

For question 1 do you mean 'bit shift'? :)

I would think that bit shift could be encompassed into bitwise. I know that they aren't due to the fact that bit shift does not operate on pairs of bits, but hey!

It's just a bit more specific. :)


I used an AND in one of mine.
Was This Post Helpful? 0
  • +
  • -

#9 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: [Week 2] Sample Game Programming Interview Question

Posted 11 February 2011 - 12:48 PM

One of your answers I'm liking guys... the rest I'm not. ;)
Was This Post Helpful? 0
  • +
  • -

#10 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1009
  • View blog
  • Posts: 4,197
  • Joined: 14-February 08

Re: [Week 2] Sample Game Programming Interview Question

Posted 11 February 2011 - 12:55 PM

The first person to spot a pretty small optimisation in number 4 gets a prize :)
Was This Post Helpful? 0
  • +
  • -

#11 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1009
  • View blog
  • Posts: 4,197
  • Joined: 14-February 08

Re: [Week 2] Sample Game Programming Interview Question

Posted 12 February 2011 - 02:13 AM

Some tips

Spoiler

Was This Post Helpful? 1
  • +
  • -

#12 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1009
  • View blog
  • Posts: 4,197
  • Joined: 14-February 08

Re: [Week 2] Sample Game Programming Interview Question

Posted 12 February 2011 - 11:19 AM

ghillieLEAD's answers are looking almost spot on :)

This post has been edited by stayscrisp: 13 February 2011 - 09:01 AM

Was This Post Helpful? 0
  • +
  • -

#13 Filox  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 24-June 10

Re: [Week 2] Sample Game Programming Interview Question

Posted 12 February 2011 - 12:54 PM

I don't know if its the best optimization but here its my solution:

Spoiler

This post has been edited by Filox: 12 February 2011 - 12:54 PM

Was This Post Helpful? 0
  • +
  • -

#14 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 795
  • View blog
  • Posts: 1,681
  • Joined: 30-January 09

Re: [Week 2] Sample Game Programming Interview Question

Posted 13 February 2011 - 08:49 AM

Hmm, I've never done bitshift operations, but I have a fair amount of maths behind me, so I'll have a go:

Spoiler


As for the best game of all time (assuming you're talking about electronic games) I'd say Dwarf Fortress would have to be up there. The interface may be clunky, the graphics just ASCII, and the learning curve steep, but the gameplay factors are absolutely astonishing. The diversity and complexity of the game are pretty much unrivalled by any other game ever made, and the possibilities in it are endless (it's an open-ended game). Not to mention the amount of cross-disciplinary tertiary level knowledge the developer has put into it, such as Geology, Meteorology, History, and Sociology.

This post has been edited by e_i_pi: 13 February 2011 - 09:08 AM

Was This Post Helpful? 0
  • +
  • -

#15 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1009
  • View blog
  • Posts: 4,197
  • Joined: 14-February 08

Re: [Week 2] Sample Game Programming Interview Question

Posted 13 February 2011 - 09:11 AM

I'm surprised no-one has done this yet

Spoiler

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2