Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sys import argv
- import numpy as GABO
- import itertools
- gabelas_sheipi = (-1, 1)
- gabelas_failebi = open(argv[1], 'r'), open(argv[2], 'rb'), open(argv[3], 'wb')
- gabelas_n, gabelas_k = map(int, gabelas_failebi[0].readline().split(' '))
- gabelas_matrica = []
- for gabelas_indeqsi in range(gabelas_k):
- gabelas_masivi = []
- gabelas_xazi = gabelas_failebi[0].readline().rstrip('\n')
- for gabelas_kodi in gabelas_xazi:
- gabelas_masivi.append(int(gabelas_kodi))
- gabelas_masivi = GABO.array(gabelas_masivi)
- gabelas_matrica.append(gabelas_masivi)
- gabelas_matrica = GABO.array(gabelas_matrica)
- gabelas_leqsikoni = {}
- while True:
- gabelas_xazi = gabelas_failebi[0].readline().rstrip('\n')
- if not gabelas_xazi:
- break
- gabelas_dasplituli = gabelas_xazi.split('!')
- gabelas_sgabelas_indeqsiromi, gabelas_kodi = gabelas_dasplituli[0], gabelas_dasplituli[1]
- gabelas_leqsikoni[gabelas_sgabelas_indeqsiromi] = gabelas_kodi
- # File to string
- gabelas_failis_info = ''
- gabelas_bufferi = gabelas_failebi[1].read()
- for gabelas_byte in gabelas_bufferi:
- gabelas_byte_str = "{0:b}".format(gabelas_byte)
- gabelas_failis_info += '0'*(8-len(gabelas_byte_str))+gabelas_byte_str
- gabelas_chasaweri_teqsti = ''
- gabelas_failis_infos_zoma = len(gabelas_failis_info)
- for gabelas_indeqsi in range(0, gabelas_failis_infos_zoma//gabelas_n, 1):
- gabelas_axlandeli_chunki = gabelas_failis_info[gabelas_indeqsi *
- gabelas_n:(gabelas_indeqsi + 1)*gabelas_n]
- gabelas_vectori = list(map(int, gabelas_axlandeli_chunki))
- gabelas_vectori = GABO.array(gabelas_vectori).reshape(gabelas_sheipi)
- gabelas_kodi = ''
- gabelas_namravli = gabelas_matrica.dot(gabelas_vectori) % 2
- for gabelas_c in gabelas_namravli:
- gabelas_kodi += str(gabelas_c[0])
- if gabelas_kodi not in gabelas_leqsikoni:
- continue
- gabelas_masivi = []
- for gabelas_kodi in gabelas_leqsikoni[gabelas_kodi]:
- gabelas_masivi.append(int(gabelas_kodi))
- gabelas_masivi = GABO.array(gabelas_masivi).reshape(gabelas_sheipi)
- gabelas_vectori = (gabelas_vectori - gabelas_masivi) % 2
- for gabelas_veqtoris_elementi in gabelas_vectori:
- gabelas_chasaweri_teqsti += str(gabelas_veqtoris_elementi[0])
- # Write
- gabelas_indeqsi = 0
- GABEEEEL = b''
- while True:
- gabelas_byte = 0
- for gabelas_i in range(7, -1, -1):
- if gabelas_indeqsi < len(gabelas_chasaweri_teqsti):
- gabelas_indeqsi += 1
- gabelas_axlandeli_biti = gabelas_chasaweri_teqsti[gabelas_indeqsi-1]
- if gabelas_axlandeli_biti == '1':
- gabelas_byte |= pow(2, gabelas_i)
- else:
- gabelas_failebi[2].write(
- GABEEEEL + bytes([gabelas_byte | pow(2, gabelas_i)]))
- exit()
- GABEEEEL += bytes([gabelas_byte])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement