little joey wrote:Well, the problem statement states that both operands contain exactly one wildcard character but nothing is further said about it. This implies that all four forms (*, x*, *y and x*y) are possible in any combination. It is further explicitly stated (in the note) that we are not emulating the behaviour of MS-DOS, but letting the wildcard character match any number of printable characters (with the 14 character filename restriction). Constructions like "rename a*b b*a" and "rename * x*y" are perfectly legal according to the text.
So, no Dominik, I don't think these cases are tricky or incorrect.
Happy hunting!
-little joey
PS. It would be cruel to require knowledge of MS-DOS to solve a programming problem, especially because there are thirty-something versions and sub-versions of the thing, all with their own bugs/features. It is my strong conviction that people tend to live longer and happier without any knowledge of MS-DOS. I, alas, know too much about it...
Problem description wasn't clear for me. This problem looked hard until i got output above.
rename wildfrom wildto
from and to will both contain one wild-card character, `*'
I think possibilities of wildfrom and wildto should be explained a little more in problem description.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
I'm doing this problem in Python3 and get WA despite getting all test cases right which are posted in this forum and on udebug (and the ones I created myself). I think my test cases cover every possible combination, even things like "rename * *" and such. Not sure what else to check??
Also, we should assume a limit of 14 characters for filenames. Does that mean we ignore longer files? Or truncate them? For input? For output?
The AC solution in udebug handles longer filesnames????
Yes, you should assume a limit of 14 characters for filenames. It means that there won't be longer filenames. Therefore no need to truncate them. Limit of 14 characters is for input. My accepted solution treats filenames with maximal length of 14 characters. So judge's input is valid. By the way judge's input contains at most 10001 filenames at each dataset.
To get help you could describe your algorithm. I use following algorithm:
1. Find position of * and divide wildfrom (oldname) into two parts - before * and after *. Filename = A*B, where A is first part and B is second. Some of this parts can be empty.
2. Divide wildto into two parts - before * and after *. Filename = C*D, where C is first part and D is second. Some of this parts can be empty.
3. For each FILENAME in the list we check two things. If A is prefix of FILENAME and B is postfix of FILENAME. I.e. check if FILENAME = AmiddleB, where middle is middle part of FILENAME.
4. if checking is OK, replace A by C and replace B by D. I.e. answer is CmiddleD
Hope it helps.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman