Love丶FFC's Blog
大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm
。大侦探很快就明白了,字条上奇怪的乱码实际上就是约会的时间星期四 14:04
,因为前面两字符串中第 1 对相同的大写英文字母(大小写有区分)是第 4 个字母 D
,代表星期四;第 2 对相同的字符是 E
,那是第 5 个英文字母,代表一天里的第 14 个钟头(于是一天的 0 点到 23 点由数字 0 到 9、以及大写字母 A
到 N
表示);后面两字符串第 1 对相同的英文字母 s
出现在第 4 个位置(从 0 开始计数)上,代表第 4 分钟。现给定两对字符串,请帮助福尔摩斯解码得到约会的时间。
输入在 4 行中分别给出 4 个非空、不包含空格、且长度不超过 60 的字符串。
在一行中输出约会的时间,格式为 DAY HH:MM
,其中 DAY
是某星期的 3 字符缩写,即 MON
表示星期一,TUE
表示星期二,WED
表示星期三,THU
表示星期四,FRI
表示星期五,SAT
表示星期六,SUN
表示星期日。题目输入保证每个测试存在唯一解。
3485djDkxh4hhGE
2984akDfkkkkggEdsb
s&hgsfdk
d&Hyscvnm
THU 14:04
1.利用字典实现A~G与Day的对应
2.先判断Day,再判断Hour
3.注意Hour和Min在小于10的情况下需要补足0,例如0时6分需要补足为00:06
4.Hour=列表索引的值
可进行的优化:字符匹配不用从头开始,可以从第一个符合条件的位置开始
String = list() for i in range(4): String.append(input()) DayLetter = {'A': "MON", 'B': "TUE", 'C': "WED", 'D': "THU", 'E': "FRI", 'F': "SAT", 'G': "SUN"} HourLetter = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N'] # 进行前两对字符串匹配 MatchIndex = 0 # 用于记录满足条件的索引 for i in range(min(len(String[0]), len(String[1]))): if String[0][i] == String[1][i] and String[0][i] in DayLetter: Day = String[0][i] # 第一个相同的大写字母 MatchIndex = i + 1 # 判断Hour时在此基础上向前一位 break for j in range(MatchIndex, min(len(String[0]), len(String[1]))): if String[0][j] == String[1][j] and String[0][j] in HourLetter: HH = String[0][j] # 第二个相同的字符 break # 进行后两对字符串匹配 for i in range(min(len(String[2]), len(String[3]))): if String[2][i] == String[3][i] and String[2][i].isalpha(): MM = i # 第一个相同的字母 break Day = DayLetter[Day] HH = HourLetter.index(HH) if HH < 10: HH = '0' + str(HH) if MM < 10: MM = '0' + str(MM) print(str(Day) + ' ' + str(HH) + ':' + str(MM))
cheap louis vuitton bags
I just wanted to thank you for the fast service. as well as they look great. I received them a day earlier than expected. for instance the I will definitely continue to buy from this site. you decide I will recommend this site to my friends. Thanks!
cheap louis vuitton bags https://www.louisvuittonsoutletstore.com/
cheap louis vuitton outlet
I just wanted to thank you for the fast service. actually they look great. I received them a day earlier than expected. as good as the I will definitely continue to buy from this site. you decide I will recommend this site to my friends. Thanks!
cheap louis vuitton outlet https://www.bestlouisvuittonoutlet.com/
cheap louis vuitton outlet
I just wanted to thank you for the fast service. or it may be they look great. I received them a day earlier than expected. particularly the I will definitely continue to buy from this site. situation I will recommend this site to my friends. Thanks!
cheap louis vuitton outlet https://www.cheapreallouisvuitton.com/
Jorcift
3 Lactated Ringer s LR Still a physiologically sensible choice cheap cialis online pharmacy Goldhirsch, consulting and lecture fees from GlaxoSmithKline, Novartis, AstraZeneca, Roche, and Schering Plough
jordans for cheap
I just wanted to thank you for the fast service. or even a they look great. I received them a day earlier than expected. much like the I will definitely continue to buy from this site. situation I will recommend this site to my friends. Thanks!
jordans for cheap https://www.realjordansretro.com/
cheap jordans online
I just wanted to thank you for the fast service. or even they look great. I received them a day earlier than expected. most notably I will definitely continue to buy from this site. you ultimately choose I will recommend this site to my friends. Thanks!
cheap jordans online https://www.cheaprealjordan.com/
cheap real jordans
Read reviews and was a little hesitant since I had already inputted my order. or else but thank god, I had no issues. such as the received item in a timely matter, they are in new condition. no matter what so happy I made the purchase. Will be definitely be purchasing again.
cheap real jordans https://www.authenticcheapjordans.com/
cheap jordans online
Read reviews and was a little hesitant since I had already inputted my order. or possibly but thank god, I had no issues. prefer received item in a timely matter, they are in new condition. regardless so happy I made the purchase. Will be definitely be purchasing again.
cheap jordans online https://www.realcheapretrojordanshoes.com/
authentic cheap jordans
Read reviews and was a little hesitant since I had already inputted my order. as well but thank god, I had no issues. for example the received item in a timely matter, they are in new condition. in any event so happy I made the purchase. Will be definitely be purchasing again.
authentic cheap jordans https://www.realjordansshoes.com/
intuido
priligy ebay Diets low in fruits particularly oranges, apples, and grapefruit and cruciferous vegetables broccoli, cabbage, and brussel sprouts may result in a relative deficiency of calcium D glucarate and its metabolites
WfYDnHeXS
mail order levitra 90 day supply Dunsmore L, et al