I am attempting to take a binary file and duplicate the contents in order:
Say the file contains 101010101010101. I want to duplicate each bit by x (say 3 for this example) and make a copy of the file so that the copied file with the duplicates will read as 111000111000111000111000111000111000111000111.
I then want to be able to reverse this as well.
The issue I am having is how to read each element, and then write that element x times in a new file. I am able to copy the file, however unsure how to read each element and then duplicate it
I don't know if you already tried something or if you are having any trouble with your solution.
But suppose you already read the file you need and already assigned the value from the file to a variable, you could do:
You can also change this to a function and read each file calling the function.
If you
print(new_bit):If you check if the
new_bitis different than the example you shared byprint('111000111000111000111000111000111000111000111' != new_bit):If you
print(reverse_new_bit):