Home easyCTF 2015 Sort-of-Easy
Writeup
Cancel

Sort-of-Easy

Challenge
Use the programming interface to complete this task.

Input: A list of numbers, separated by commas. Ex: 3,28,9,17,5
Output: The list sorted from largest to smallest, separated by commas. Ex: 28,17,9,5,3

Read the input from a file called sorting-job.in that’s in the current working directory, and then write your output to a file called sorting-job.out.

Solution

1
2
3
4
5
6
nums= open("sorting-job.in","r").readline().rstrip().split(",")
nums= [int(n) for n in nums]
nums = sorted(nums)
nums = nums[::-1]

open("sorting-job.out","w").write( ','.join(str(n) for n in nums)+'\n' )

Flag

easyctf{sorting_is_as_easy_as_3_2_1!}