题解 | #配置文件恢复#
配置文件恢复
https://www.nowcoder.com/practice/ca6ac6ef9538419abf6f883f7d6f6ee5
from enum import Flag
import sys
dic1 = {"reset": "reset what"}
dic2 = {
("reset", "board"): "board fault",
("board", "add"): "where to add",
("board", "delete"): "no board at all",
("reboot", "backplane"): "impossible",
("backplane", "abort"): "install first",
}
for line in sys.stdin:
op = line.split()
flag = False
if len(op) == 1:
if op[0][0] == "r" and op[0] in "reset":
print("reset what")
flag = True
elif len(op) == 2:
count = 0
out = 0
for key in dic2:
if op[0][0] == key[0][0] and op[0] in key[0]:
if op[1][0] == key[1][0] and op[1] in key[1]:
out = dic2[key]
count += 1
if count == 1:
print(out)
flag = True
if not flag:
print("unknown command")
