PAT B 1076 Wifi password

The code was released, we learn together, help each other
Topic:
Here is circulating on Weibo photo: "Dear students, given that we sometimes need to use wifi, afraid to delay the pro learning, now wifi password is set to answer the following math problem:. a-1; B- 2; C-3; D-4; ask someone to answer their own, a change every two days - thank you !! "
- in order to promote student teachers learning also fight ...... this question requires you to write a program to answer a series of topics translated into wifi password is given in accordance with the correspondence between the papers. Here simply assume that each multiple-choice questions have four options and only one correct answer.
Here Insert Picture Description
Input formats :
given input of the first line of a positive integer N (≤ 100), followed by N lines, each in accordance with the number - gives four options for a question answer format, T is the correct option, F indicates an error options. Separated by spaces option.

Output formats :
Output wifi passwords in a row.

Sample input:

8
A-T B-F C-F D-F
C-T B-F A-F D-F
A-F D-F C-F B-T
B-T A-F C-F D-F
B-F D-T A-F C-F
A-T C-F B-F D-F
D-T B-F C-F A-F
C-T A-F B-F D-F

Sample output:

13224143

Code below (Python):

import re
pat = '(.?)-T'
right_list = []
map_dict = {'A': '1', 'B': '2', 'C': '3', 'D': '4'}
for i in range(int(input())):
    options = input()
    right_list.append(re.findall(pat, options)[0])
for j in right_list:
    print(map_dict[j], end='')
Published 65 original articles · won praise 25 · views 1031

Guess you like

Origin blog.csdn.net/chongchujianghu3/article/details/104987138