Challenge description:
Your task is to make a palindrome string by rearranging and concatenating given words.
Input Format: N <Word_1> <Word_2> ... <Word_N> Answer Format: Rearranged words separated by space. Each words contain only lower case alphabet characters. Example Input: 3 ab cba c Example Answer: ab c cba You have to connect to ppc1.chal.ctf.westerns.tokyo:31111(TCP) to answer the problem. $ nc ppc1.chal.ctf.westerns.tokyo 31111
|
This challenge was pretty simple. I used the given “example.py” and added the following function to it:
def makepal(l): for b in itertools.permutations(l, len(l)): str1 = ''.join(b) if str(str1) == str(str1)[::-1]: print b return b
Then I called it using the original script structure:
answer = makepal(words)
And the server returned the flag:
TWCTF{Hiyokko_Tsuppari}
The full script can be found here.