Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Mirroring and Shifting #355

Open
littlehug opened this issue Aug 9, 2018 · 0 comments
Open

File Mirroring and Shifting #355

littlehug opened this issue Aug 9, 2018 · 0 comments

Comments

@littlehug
Copy link
Collaborator

Write a program to mirror and shift a binary file.

Task Description

Given the names of an input binary file of L bytes, the name for an output file and an integer N, mirror the file first, then shift the left N bytes and write the contents to the output binary file. For example, if a file consists of 00010011 01011100 00100110 11000101, after mirroring, it will be 10100011 01100100 00111010 11001000. Then we shift left 3 bytes, it will be 11001000 10100011 01100100 00111010.

Subtask

  • 10 points: The whole file can be read into memory and N is 0.
  • 20 points: The whole file can be read into memory and N is between 0 and L - 1.
  • 70 points: The file will be too large to read into memory.

Input Format

The input contains only one test case. There are two strings and one integer in the first line. The first string is the name of the input file and the second string is the name of the output file. The second line of the input is N. The name of the files have no more than 16 characters.

Output Format

Write a binary file with given output file name.

Sample Input 1

0-in.dat 0-out.dat 
0

Sample Input binary file 1

0-in.dat

00010011 01011100 00100110 11000101

Sample Output binary file 1

0-out.dat

10100011 01100100 00111010 11001000

Sample Input 2

1-in.dat 1-out.dat 
3

Sample Input binary file 2

1-in.dat

00010011 01011100 00100110 11000101

Sample Output binary file 2

1-out.dat

11001000 10100011 01100100 00111010

Sample Input 3

2-in.dat 2-out.dat 
27

Sample Output 3

2-out.dat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant