Generation

generate functionFri, 26 May 2023

The Robots have found an encrypted message. We cannot decrypt it at the moment, but we can take the first steps towards doing so. You have a set of "words", all in lower case, and each word contains symbols in "alphabetical order". (it's not your typical alphabetical order, but a new and different order.) We need to determine the order of the symbols from each "word" and create a single "word" with all of these symbols, placing them in the new alphabetical order. In some cases, if we cannot determine the order for several symbols, you should use the traditional latin alphabetical order. For example: Given words "acb", "bd", "zwa". As we can see "z" and "w" must be before "a" and "d" after "b". So the result is "zwacbd". Input: Words as a list of strings. Output: The order as a string.

def checkio(words): w = words.split(',') print (w) for i in w: if len(i) > 1: if ord(i[0]) < ord(i[1]): print (i[0]) return "a,c,b" checkio("acb,bd,zwa")

Questions about programming?Chat with your personal AI assistant