#!/usr/bin/env python # coding=utf-8 def word2num(string_c): arr = [] while len(string_c) != 0: if 'Z' in string_c: arr.append(0) string_c.remove('Z') string_c.remove('E') string_c.remove('R') string_c.remove('O') elif 'X' in string_c: arr.append(6) string_c.remove('X') string_c.remove('S') string_c.remove('I') elif 'G' in string_c: arr.append(8) string_c.remove('G') string_c.remove('E') string_c.remove('I') string_c.remove('H') string_c.remove('T') elif 'S' in string_c : arr.append(7) string_c.remove('S') string_c.remove('E') string_c.remove('E') string_c.remove('V') string_c.remove('N') elif 'V' in string_c : arr.append(5) string_c.remove('V') string_c.remove('F') string_c.remove('I') string_c.remove('E') elif 'F' in string_c : arr.append(4) string_c.remove('F') string_c.remove('O') string_c.remove('U') string_c.remove('R') elif 'R' in string_c : arr.append(3) string_c.remove('R') string_c.remove('E') string_c.remove('E') string_c.remove('T') string_c.remove('H') elif 'T' in string_c : arr.append(2) string_c.remove('T') string_c.remove('W') string_c.remove('O') elif 'O' in string_c : arr.append(1) string_c.remove('O') string_c.remove('E') string_c.remove('N') else: arr.append(9) string_c.remove('N') string_c.remove('I') string_c.remove('E') string_c.remove('N') return arr def num2true(arr): numTrue = [] for item in arr: if item == 9: numTrue.append(1) elif item == 8: numTrue.append(0) else: numTrue.append(10 + item - 8) return numTrue def num2print_min(arr): arr.sort() arr = [str(i) for i in arr] return ''.join(arr) try: while 1: n = int(input()) for i in range(n): line = input().strip() strings = line.split() string_c = list(strings[0]) nums = word2num(string_c) truenums = num2true(nums) res = num2print_min(truenums) print(res) except: pass
点赞 评论

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务