You are viewing a single comment's thread. Return to all comments →
Anyone a fan of one-liners? Here's my uglified code (my solution breaks it up into more optimized parts.
weights = set(chain.from_iterable(imap(lambda (x, y): x * y, enumerate(g, 1)) for _, g in groupby(imap(lambda c: ord(c) - 96, raw_input())))) for X in (input() for _ in xrange(input())): print ["No", "Yes"][X in weights]
Basically it does the following:
Seems like cookies are disabled on this browser, please enable them to open this website
Weighted Uniform Strings
You are viewing a single comment's thread. Return to all comments →
Anyone a fan of one-liners? Here's my uglified code (my solution breaks it up into more optimized parts.
Basically it does the following: