面试题~~

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

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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值