Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- def is_soluble (digits) :
- print(digits)
- inv = 0
- for i in range(16):
- if (digits[i] != 0):
- for j in range(i):
- if (digits[j] > digits[i]):
- inv += 1
- for i in range(16):
- if (digits[i] == 0):
- inv += 1 + i/4
- if (int(inv) & 1):
- return '1'
- else :
- return '0'
- file = open('Downloads/puzzles.txt')
- lines = file.readlines()
- flag = ''
- abcd = 0
- digits = []
- num = ''
- for i in range(len(lines)):
- if (abcd == 4):
- flag += is_soluble(digits)
- digits = []
- abcd = 0
- if ('bit' in lines[i] or '-' in lines[i] or '-' in lines[i] or lines[i].replace(' ','') == '\n'):
- continue
- lines[i] = lines[i].replace(' ','0')
- for sym in lines[i]:
- try :
- int(sym)
- except :
- if (num != ''):
- digits.append(int(num))
- num = ''
- else :
- num += sym
- abcd += 1
- print(flag)
- flag = int(flag, 2)
- print('SharifCTF{%s}' % hex(flag).replace('0x',''))
Advertisement
Add Comment
Please, Sign In to add comment