s******c 发帖数: 99 | 1 在本地的考试中心预约的上机考试。考试有三个部分,1.数学题,2.给出一种新的编程
语言的语法,回答相应问题,3. Programming Test 要求速度和准确性both important
Programming test 答得不好,肯定不行了,把面试题发上来让大家做做。做了3个半小
时,快累死了。
数学题基本上就是脑筋急转弯,举几个例子
1. You have three kinds of magazines, all but two are Times, all but two are
Science, all but two are Nature. How many magazines in total do you have?
2. Only one of the answers is true
A. All of the below are true
B. All answers are true
C. One of the above is true
D. All of the above are true
E. None of the above are true
F. None of the above are true
3. You have two coins which sum up to 15 cents. One of them is not a dime.
What are the two coins (multiple choice)
A. Penny
B. Nickel
C. Dime
D. Quarter
E. Not possible
第二部分,是介绍一种高级语言,有点像lisp,没什么特别的,就按照它介绍的语法规
则来答
第三部分,编程题,一共四道题,实在没想到有这么多,鼓励自己坚持到最后,写完了
3道。没写上的那个题是最经典的电话按键排列组合题的变种,面之前没看,这个悔呀
1. You are given a telephone keyboard
0-0
1-1
2-ABC2
3-DEF3
4-GHI4
5-JKL5
6-MNO6
7-PQRS7
8-TUV8
9-WXYZ9
0-0
*-space
#-char separater
if you type "2", you will get 'A', that is
"2"-'A'
"22"-'B'
"222"-'C'
"2222"-'D'
However, the digits can repeated many times
"22222"-you get 'A' again
You can use "#" to separate characters, for example
"2#22", you get "AB"
However, you may also have consecutive different digits without separator: "
23"-'AD'
If you type "*", it means space.
You a given a sequence of digits, translate it into a text message
2. Basket ball hit rates
The hit rate of the basketball game is given by the number of hits divided
by the number of chances. For example, you have 73 chances but hit 15 times,
then your hit rate is 15/73=0.205 (keep the last 3 digits). On average, you
have 4.5 chances in each basketball game. Assume the total number of games
is 162. Write a function for a basketball player. He will input the number
of hits he has made, the number of chances he had, and the number of
remaining games. The function should return the number of future hits, so
that he can refresh his hit rate to 0.45
3. A Typist problem. 电话按键题的变种!一个打字员,10个手指,分别负责不同的
按键,
0-null
1-gftrvb
2-edc
3-wsx
4-qaz
5-null
6-yuhjnm
7-ik
8-ol
9-p
给你 9801,输出所有可能组合
pog
pof
pot
por
pov
pob
plg
plf
...
悔啊悔啊,面之前打算看电话按键题的,没看,没想到真考了……
4. String transpose
Transpose a string means re-sequencing a string
If you transpose string1 to string2, you can only swap the adjacent two
characters each time, until you get your target string.
For example, you want to transpose GUW to WUG, the steps are
GUW
GWU
WGU
WUG
Print all steps in string transpose
先把题放着看看,一会儿我再说我的答案 | b*****c 发帖数: 1103 | 2 easy job, but no luck, sad | v***n 发帖数: 5085 | | p*i 发帖数: 411 | 4 我周一考……看来这个难度不大
【在 v***n 的大作中提到】 : 楼主记忆力真好。。。这都能记得下来
| h********f 发帖数: 73 | | z****u 发帖数: 104 | 6 我只能预约到早晨8点的考试!考试中心最近也要20mile.
你们的考试都是几点开始的? | s******c 发帖数: 99 | 7 我也是8点考
【在 z****u 的大作中提到】 : 我只能预约到早晨8点的考试!考试中心最近也要20mile. : 你们的考试都是几点开始的?
| s******c 发帖数: 99 | 8 还是要好好准备一下的,每道题都要考虑细节。
递归那部分一定要好好看,一定是会考的,把输入电话按键给出字母排列那道题背下来。
还有就是字符串和数组的操作。
另外这个考试很看重时间,所以一定要尽快做完。
【在 p*i 的大作中提到】 : 我周一考……看来这个难度不大
| b***e 发帖数: 383 | | p*i 发帖数: 411 | 10 看到你说要背题,
no offense,我就不打击你了。
Good luck!
来。
【在 s******c 的大作中提到】 : 还是要好好准备一下的,每道题都要考虑细节。 : 递归那部分一定要好好看,一定是会考的,把输入电话按键给出字母排列那道题背下来。 : 还有就是字符串和数组的操作。 : 另外这个考试很看重时间,所以一定要尽快做完。
| | | p*i 发帖数: 411 | 11 10点,on campus
【在 z****u 的大作中提到】 : 我只能预约到早晨8点的考试!考试中心最近也要20mile. : 你们的考试都是几点开始的?
| h********w 发帖数: 221 | 12 1. 6 magazines
2. E
3. BC
4. 电话按键,如2222, mode(4) , 0 is 2, 1 is A, 2 is B, 3 is C and so and,
Public phoneKey(String str){
String keystring="";
for(int i=0; i
{
int count=0;
int key =0;
if(str.charAt(i) =='2'){
for(int j=0; str[j]!=2; j++)
{
++count;
}
key=count%4;
switch(key)
case 0:
key= 2; break;
case 1:
key = a; break;
.....
keystring+=key;
.....
}
累了,休息一下,
BTW, EPIC tnnd,2面都不给我,HR问了一堆HR的垃圾问题
......
}
return keystring;
} | s******c 发帖数: 99 | 13 第一题不对,一共就3本
编程第一题,你可以用来存储对应关系,如2->"ABC2",这样能更
简洁一些
【在 h********w 的大作中提到】 : 1. 6 magazines : 2. E : 3. BC : 4. 电话按键,如2222, mode(4) , 0 is 2, 1 is A, 2 is B, 3 is C and so and, : Public phoneKey(String str){ : String keystring=""; : for(int i=0; i: { : : int count=0;
| n*s 发帖数: 752 | 14 4. telephone keyboard problem
import sys
map = {'0':'0','1':'1','2':'abc2','3':'def3','4':'ghi4','5':'jkl5','6':'mno6
','7':'pqrs7','8':'tuv8','9':'wxyz9','*':' ','#':'#'}
def translate():
print 'Please input from telephone keyboard:'
input = sys.stdin.readline().strip()
output = []
count = -1
prev = input[0]
for x in input:
if not (x in map.keys()):
return 'invalid input!'
if x == prev: # repeated input
if x == '*' or x == '0' or x == '1':
output.append(map[x])
else:
count += 1
else: # new input
if prev != '#':
size = len(map[prev])
output.append(map[prev][count %size])
count = 0
prev = x
# the very last char
if x != '#':
size = len(map[x])
output.append(map[x][count %size])
return ''.join(output)
if __name__ == '__main__':
print translate() | s******c 发帖数: 99 | 15 没事,确实答得不好,刚开始准备。
递归的问题我掌握得不好。有什么建议吗?
【在 p*i 的大作中提到】 : 看到你说要背题, : no offense,我就不打击你了。 : Good luck! : : 来。
| h********w 发帖数: 221 | 16 喔,sorry, all but是除了..以外的意思,
【在 s******c 的大作中提到】 : 第一题不对,一共就3本 : 编程第一题,你可以用来存储对应关系,如2->"ABC2",这样能更 : 简洁一些
| n*s 发帖数: 752 | 17 4. string transpose
import sys
def transpose(input,i):
mystr = list(input)
mystr[i],mystr[i+1] = mystr[i+1],mystr[i]
return ''.join(mystr)
def str_transpose():
print 'input two strings, separated by blank:'
a, b = sys.stdin.readline().split()
size = len(a)
if size != len(b) or sorted(a) != sorted(b):
return 'no way!'
next = [b]
parent = {b:None}
idx = size -1
notFound = True
while notFound:
newstr = []
for x in next:
for i in xrange(idx):
tmp = transpose(x,i)
if not (tmp in parent.keys()):
parent[tmp] = x
newstr.append(tmp)
if tmp == a:
notFound = False
break
next = newstr
output = [a,'\n']
while parent[tmp] != None:
tmp = parent[tmp]
output += tmp
output += '\n'
return ''.join(output)
if __name__ == '__main__':
print str_transpose()
important
are
【在 s******c 的大作中提到】 : 在本地的考试中心预约的上机考试。考试有三个部分,1.数学题,2.给出一种新的编程 : 语言的语法,回答相应问题,3. Programming Test 要求速度和准确性both important : Programming test 答得不好,肯定不行了,把面试题发上来让大家做做。做了3个半小 : 时,快累死了。 : 数学题基本上就是脑筋急转弯,举几个例子 : 1. You have three kinds of magazines, all but two are Times, all but two are : Science, all but two are Nature. How many magazines in total do you have? : 2. Only one of the answers is true : A. All of the below are true : B. All answers are true
| b***e 发帖数: 383 | 18 第二题有点不懂。
player总共有 4.5*162 = 729 次chance.
要使得 hit rate = 0.45, 那么总共的hit数是 729* 0.45 = 328.05.
如果知道目前的hit数,,那么后面的比赛只需要再有 328.05 - hits 就可以了。
那么输入 the number of chances he had, and the number of
remaining games 就没有任何的意义。
或者我们不知道player有多少次chance, 那么,而我们知道the number of (hits) he
has made, the number of (chances) he had, and the number of remaining
(games
).
如果这样,是不是解出这样的方程就可以了?
(hits + X) /(chances + games * 4.5) = 0.45 | s******c 发帖数: 99 | 19 4.5次chance是个平均值,是帮你预测未来的情况的,以前的情况已经发生了,就不能
用4.5*162了。
后面那个公式是对的
he
【在 b***e 的大作中提到】 : 第二题有点不懂。 : player总共有 4.5*162 = 729 次chance. : 要使得 hit rate = 0.45, 那么总共的hit数是 729* 0.45 = 328.05. : 如果知道目前的hit数,,那么后面的比赛只需要再有 328.05 - hits 就可以了。 : 那么输入 the number of chances he had, and the number of : remaining games 就没有任何的意义。 : 或者我们不知道player有多少次chance, 那么,而我们知道the number of (hits) he : has made, the number of (chances) he had, and the number of remaining : (games : ).
| b***e 发帖数: 383 | 20
多谢回复。
【在 s******c 的大作中提到】 : 4.5次chance是个平均值,是帮你预测未来的情况的,以前的情况已经发生了,就不能 : 用4.5*162了。 : 后面那个公式是对的 : : he
| | | s******c 发帖数: 99 | 21 在本地的考试中心预约的上机考试。考试有三个部分,1.数学题,2.给出一种新的编程
语言的语法,回答相应问题,3. Programming Test 要求速度和准确性both important
Programming test 答得不好,肯定不行了,把面试题发上来让大家做做。做了3个半小
时,快累死了。
数学题基本上就是脑筋急转弯,举几个例子
1. You have three kinds of magazines, all but two are Times, all but two are
Science, all but two are Nature. How many magazines in total do you have?
2. Only one of the answers is true
A. All of the below are true
B. All answers are true
C. One of the above is true
D. All of the above are true
E. None of the above are true
F. None of the above are true
3. You have two coins which sum up to 15 cents. One of them is not a dime.
What are the two coins (multiple choice)
A. Penny
B. Nickel
C. Dime
D. Quarter
E. Not possible
第二部分,是介绍一种高级语言,有点像lisp,没什么特别的,就按照它介绍的语法规
则来答
第三部分,编程题,一共四道题,实在没想到有这么多,鼓励自己坚持到最后,写完了
3道。没写上的那个题是最经典的电话按键排列组合题的变种,面之前没看,这个悔呀
1. You are given a telephone keyboard
0-0
1-1
2-ABC2
3-DEF3
4-GHI4
5-JKL5
6-MNO6
7-PQRS7
8-TUV8
9-WXYZ9
0-0
*-space
#-char separater
if you type "2", you will get 'A', that is
"2"-'A'
"22"-'B'
"222"-'C'
"2222"-'D'
However, the digits can repeated many times
"22222"-you get 'A' again
You can use "#" to separate characters, for example
"2#22", you get "AB"
However, you may also have consecutive different digits without separator: "
23"-'AD'
If you type "*", it means space.
You a given a sequence of digits, translate it into a text message
2. Basket ball hit rates
The hit rate of the basketball game is given by the number of hits divided
by the number of chances. For example, you have 73 chances but hit 15 times,
then your hit rate is 15/73=0.205 (keep the last 3 digits). On average, you
have 4.5 chances in each basketball game. Assume the total number of games
is 162. Write a function for a basketball player. He will input the number
of hits he has made, the number of chances he had, and the number of
remaining games. The function should return the number of future hits, so
that he can refresh his hit rate to 0.45
3. A Typist problem. 电话按键题的变种!一个打字员,10个手指,分别负责不同的
按键,
0-null
1-gftrvb
2-edc
3-wsx
4-qaz
5-null
6-yuhjnm
7-ik
8-ol
9-p
给你 9801,输出所有可能组合
pog
pof
pot
por
pov
pob
plg
plf
...
悔啊悔啊,面之前打算看电话按键题的,没看,没想到真考了……
4. String transpose
Transpose a string means re-sequencing a string
If you transpose string1 to string2, you can only swap the adjacent two
characters each time, until you get your target string.
For example, you want to transpose GUW to WUG, the steps are
GUW
GWU
WGU
WUG
Print all steps in string transpose
先把题放着看看,一会儿我再说我的答案 | b*****c 发帖数: 1103 | 22 easy job, but no luck, sad | v***n 发帖数: 5085 | | h********f 发帖数: 73 | | s******c 发帖数: 99 | 25 我也是8点考
【在 z****u 的大作中提到】 : 我只能预约到早晨8点的考试!考试中心最近也要20mile. : 你们的考试都是几点开始的?
| s******c 发帖数: 99 | 26 还是要好好准备一下的,每道题都要考虑细节。
递归那部分一定要好好看,一定是会考的,把输入电话按键给出字母排列那道题背下来。
还有就是字符串和数组的操作。
另外这个考试很看重时间,所以一定要尽快做完。
【在 p*i 的大作中提到】 : 我周一考……看来这个难度不大
| b***e 发帖数: 383 | | h********w 发帖数: 221 | 28 1. 6 magazines
2. E
3. BC
4. 电话按键,如2222, mode(4) , 0 is 2, 1 is A, 2 is B, 3 is C and so and,
Public phoneKey(String str){
String keystring="";
for(int i=0; i
{
int count=0;
int key =0;
if(str.charAt(i) =='2'){
for(int j=0; str[j]!=2; j++)
{
++count;
}
key=count%4;
switch(key)
case 0:
key= 2; break;
case 1:
key = a; break;
.....
keystring+=key;
.....
}
累了,休息一下,
BTW, EPIC tnnd,2面都不给我,HR问了一堆HR的垃圾问题
......
}
return keystring;
} | s******c 发帖数: 99 | 29 第一题不对,一共就3本
编程第一题,你可以用来存储对应关系,如2->"ABC2",这样能更
简洁一些
【在 h********w 的大作中提到】 : 1. 6 magazines : 2. E : 3. BC : 4. 电话按键,如2222, mode(4) , 0 is 2, 1 is A, 2 is B, 3 is C and so and, : Public phoneKey(String str){ : String keystring=""; : for(int i=0; i: { : : int count=0;
| n*s 发帖数: 752 | 30 4. telephone keyboard problem
import sys
map = {'0':'0','1':'1','2':'abc2','3':'def3','4':'ghi4','5':'jkl5','6':'mno6
','7':'pqrs7','8':'tuv8','9':'wxyz9','*':' ','#':'#'}
def translate():
print 'Please input from telephone keyboard:'
input = sys.stdin.readline().strip()
output = []
count = -1
prev = input[0]
for x in input:
if not (x in map.keys()):
return 'invalid input!'
if x == prev: # repeated input
if x == '*' or x == '0' or x == '1':
output.append(map[x])
else:
count += 1
else: # new input
if prev != '#':
size = len(map[prev])
output.append(map[prev][count %size])
count = 0
prev = x
# the very last char
if x != '#':
size = len(map[x])
output.append(map[x][count %size])
return ''.join(output)
if __name__ == '__main__':
print translate() | | | s******c 发帖数: 99 | 31 没事,确实答得不好,刚开始准备。
递归的问题我掌握得不好。有什么建议吗?
【在 p*i 的大作中提到】 : 看到你说要背题, : no offense,我就不打击你了。 : Good luck! : : 来。
| h********w 发帖数: 221 | 32 喔,sorry, all but是除了..以外的意思,
【在 s******c 的大作中提到】 : 第一题不对,一共就3本 : 编程第一题,你可以用来存储对应关系,如2->"ABC2",这样能更 : 简洁一些
| n*s 发帖数: 752 | 33 4. string transpose
import sys
def transpose(input,i):
mystr = list(input)
mystr[i],mystr[i+1] = mystr[i+1],mystr[i]
return ''.join(mystr)
def str_transpose():
print 'input two strings, separated by blank:'
a, b = sys.stdin.readline().split()
size = len(a)
if size != len(b) or sorted(a) != sorted(b):
return 'no way!'
next = [b]
parent = {b:None}
idx = size -1
notFound = True
while notFound:
newstr = []
for x in next:
for i in xrange(idx):
tmp = transpose(x,i)
if not (tmp in parent.keys()):
parent[tmp] = x
newstr.append(tmp)
if tmp == a:
notFound = False
break
next = newstr
output = [a,'\n']
while parent[tmp] != None:
tmp = parent[tmp]
output += tmp
output += '\n'
return ''.join(output)
if __name__ == '__main__':
print str_transpose()
important
are
【在 s******c 的大作中提到】 : 在本地的考试中心预约的上机考试。考试有三个部分,1.数学题,2.给出一种新的编程 : 语言的语法,回答相应问题,3. Programming Test 要求速度和准确性both important : Programming test 答得不好,肯定不行了,把面试题发上来让大家做做。做了3个半小 : 时,快累死了。 : 数学题基本上就是脑筋急转弯,举几个例子 : 1. You have three kinds of magazines, all but two are Times, all but two are : Science, all but two are Nature. How many magazines in total do you have? : 2. Only one of the answers is true : A. All of the below are true : B. All answers are true
| b***e 发帖数: 383 | 34 第二题有点不懂。
player总共有 4.5*162 = 729 次chance.
要使得 hit rate = 0.45, 那么总共的hit数是 729* 0.45 = 328.05.
如果知道目前的hit数,,那么后面的比赛只需要再有 328.05 - hits 就可以了。
那么输入 the number of chances he had, and the number of
remaining games 就没有任何的意义。
或者我们不知道player有多少次chance, 那么,而我们知道the number of (hits) he
has made, the number of (chances) he had, and the number of remaining
(games
).
如果这样,是不是解出这样的方程就可以了?
(hits + X) /(chances + games * 4.5) = 0.45 | s******c 发帖数: 99 | 35 4.5次chance是个平均值,是帮你预测未来的情况的,以前的情况已经发生了,就不能
用4.5*162了。
后面那个公式是对的
he
【在 b***e 的大作中提到】 : 第二题有点不懂。 : player总共有 4.5*162 = 729 次chance. : 要使得 hit rate = 0.45, 那么总共的hit数是 729* 0.45 = 328.05. : 如果知道目前的hit数,,那么后面的比赛只需要再有 328.05 - hits 就可以了。 : 那么输入 the number of chances he had, and the number of : remaining games 就没有任何的意义。 : 或者我们不知道player有多少次chance, 那么,而我们知道the number of (hits) he : has made, the number of (chances) he had, and the number of remaining : (games : ).
| b***e 发帖数: 383 | 36
多谢回复。
【在 s******c 的大作中提到】 : 4.5次chance是个平均值,是帮你预测未来的情况的,以前的情况已经发生了,就不能 : 用4.5*162了。 : 后面那个公式是对的 : : he
| D****3 发帖数: 611 | 37
important
are
nice post.
答案呢
【在 s******c 的大作中提到】 : 在本地的考试中心预约的上机考试。考试有三个部分,1.数学题,2.给出一种新的编程 : 语言的语法,回答相应问题,3. Programming Test 要求速度和准确性both important : Programming test 答得不好,肯定不行了,把面试题发上来让大家做做。做了3个半小 : 时,快累死了。 : 数学题基本上就是脑筋急转弯,举几个例子 : 1. You have three kinds of magazines, all but two are Times, all but two are : Science, all but two are Nature. How many magazines in total do you have? : 2. Only one of the answers is true : A. All of the below are true : B. All answers are true
| e********r 发帖数: 2352 | 38 在本地的考试中心预约的上机考试。考试有三个部分,1.数学题,2.给出一种新的编程
语言的语法,回答相应问题,3. Programming Test 要求速度和准确性both important
Programming test 答得不好,肯定不行了,把面试题发上来让大家做做。做了3个半小
时,快累死了。
数学题基本上就是脑筋急转弯,举几个例子
1. You have three kinds of magazines, all but two are Times, all but two are
Science, all but two are Nature. How many magazines in total do you have?
3 books
2. Only one of the answers is true
A. All of the below are true
B. All answers are true
C. One of the above is true
D. All of the above are true
E. None of the above are true
F. None of the above are true
E
3. You have two coins which sum up to 15 cents. One of them is not a dime.
What are the two coins (multiple choice)
A. Penny
B. Nickel
C. Dime
D. Quarter
E. Not possible
B C
第二部分,是介绍一种高级语言,有点像lisp,没什么特别的,就按照它介绍的语法规
则来答
第三部分,编程题,一共四道题,实在没想到有这么多,鼓励自己坚持到最后,写完了
3道。没写上的那个题是最经典的电话按键排列组合题的变种,面之前没看,这个悔呀
1. You are given a telephone keyboard
0-0
1-1
2-ABC2
3-DEF3
4-GHI4
5-JKL5
6-MNO6
7-PQRS7
8-TUV8
9-WXYZ9
0-0
*-space
#-char separater
if you type "2", you will get 'A', that is
"2"-'A'
"22"-'B'
"222"-'C'
"2222"-'D'
However, the digits can repeated many times
"22222"-you get 'A' again
You can use "#" to separate characters, for example
"2#22", you get "AB"
However, you may also have consecutive different digits without separator: "
23"-'AD'
If you type "*", it means space.
You a given a sequence of digits, translate it into a text message
/*
* =========================================================================
============
1. You are given a telephone keyboard
0-0
1-1
2-ABC2
3-DEF3
4-GHI4
5-JKL5
6-MNO6
7-PQRS7
8-TUV8
9-WXYZ9
0-0
*-space
#-char separater
if you type "2", you will get 'A', that is
"2"-'A'
"22"-'B'
"222"-'C'
"2222"-'D'
However, the digits can repeated many times
"22222"-you get 'A' again
You can use "#" to separate characters, for example
"2#22", you get "AB"
However, you may also have consecutive different digits without separator: "
23"-'AD'
If you type "*", it means space.
You a given a sequence of digits, translate it into a text message
* =========================================================================
============
*/
#include
#include
#include | e********r 发帖数: 2352 | 39 明天机考,刚翻出各位老大帖的之前的题,练一下手.
important
are
【在 e********r 的大作中提到】 : 在本地的考试中心预约的上机考试。考试有三个部分,1.数学题,2.给出一种新的编程 : 语言的语法,回答相应问题,3. Programming Test 要求速度和准确性both important : Programming test 答得不好,肯定不行了,把面试题发上来让大家做做。做了3个半小 : 时,快累死了。 : 数学题基本上就是脑筋急转弯,举几个例子 : 1. You have three kinds of magazines, all but two are Times, all but two are : Science, all but two are Nature. How many magazines in total do you have? : 3 books : 2. Only one of the answers is true : A. All of the below are true
|
|