`
famoushz
  • 浏览: 2950902 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

面试题~~

阅读更多

一家公司 给我出的面试题。。呵呵,蛮简单的。。就是好久没写了。。昨天完成了。有兴趣可以做做。。温故以前知识。

Write a program that can compute the number of unique, valid phone numbers with the following constraints:

a)       A valid phone number is seven digits in length

b)       A valid phone number cannot begin with a zero or a one

c)       A valid phone number can contain only digits

d)       A valid phone number must consist of a sequence of digits that can be traced by the movements of a chess piece on a normal telephone keypad

 

1

2

3

4

5

6

7

8

9

*

0

#

e)       The program should be written so that it could work with any chess piece, but for the purposes of this test you only need to implement support for the knight, which has the following valid move pattern for a piece starting at the center dot:

 

 

X

 

X

 

X

 

 

 

X

 

 

 

 

X

 

 

 

X

 

X

 

X

 

 

For example, a knight starting on the number 8 could move to 1 or 3. From 1 it could move to 6 or 8, etc.

You can use any language of your pick to complete this exercise.

 

Additional Instructions:

When you are finished, you will be asked to review the test with us.  Our evaluation criterion includes both your approach to the solution as well as your answer to the problem.  You do not need to spend time documenting your code; you can discuss the code as you review it with us.

 

You should be able to finish the test within 4 hours.  Nevertheless, we are giving 24 hours to response.  You do not get extra credit for finishing quickly, nor are you penalized for taking the full 24 hours.  We would much rather see a well-designed, efficient solution than a quick answer to the problem. 

 

Deliverables:

 

  1. All source code
  2. Configuration files (if any)
  3. Compilation instruction (if required)
  4. Result of the question (i.e. number possible phone numbers)
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics