โ
Problem 6 Analysis (FIT1058 Assignment 1, Semester 1 2025)
๐ก What is the problem about?
Problem 6 asks you to write a one-line sed command that:
- Performs a local transposition of width 8 (
Tโ)
- Uses a specific permutation derived from your student ID, which is
35175192
Essentially, you need to:
- Construct a permutation from your student ID using a set of steps.
- Use that permutation to write a
sed command that reorders blocks of 8 letters accordingly.
๐ข Step-by-step Solution
๐งฎ Step 1: Generate Your Student Permutation
Student ID = 35175192
Remove 8 and 9
โ Result: 3517512
Keep only the first occurrence of each digit
โ Result: 3512 (second 5 and 1 are removed)
This is the "reduced student number": 3512
Append missing digits from 0 to 7 in decreasing order
Missing digits in 3512: 0, 4, 6, 7
In decreasing order: 7, 6, 4, 0
โ Final permutation = 3512 + 7640 = 35127640
Interpret as permutation
๐งช Step 2: Understand How sed Will Apply the Permutation
- You are doing a local transposition in blocks of 8 letters.
- That means youโll use regex with capture groups
\(...\) to grab 8 characters.
- Then reorder them using
\1 to \8 based on your permutation.
๐ง Your permutation (35127640) is:
0 1 2 3 4 5 6 7
โ โ โ โ โ โ โ โ
3 5 1 2 7 6 4 0 โ this maps index i in the original to index perm[i] in the output
This means:
- 1st output char = original char at position 4 (index 3)
- 2nd output char = original char at position 6 (index 5)
- 3rd output char = original char at position 2 (index 1)
- 4th output char = original char at position 3 (index 2)
- 5th output char = original char at position 8 (index 7)
- 6th output char = original char at position 7 (index 6)
- 7th output char = original char at position 5 (index 4)
- 8th output char = original char at position 1 (index 0)
๐งพ Step 3: Write the sed Command
sed 's/\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\4\6\2\3\8\7\5\1/g'
๐ Breakdown:
\(.\) โ captures one character, repeated 8 times
- Output:
\4 โ position 3 (index 0-based)
\6 โ position 5
\2 โ position 1
\3 โ position 2
\8 โ position 7
\7 โ position 6
\5 โ position 4
\1 โ position 0
Which corresponds exactly to permutation 35127640.
โ
Final Answer for Problem 6
Create a file named prob6.txt and put this one line inside:
sed 's/\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\4\6\2\3\8\7\5\1/g'
Would you like me to help generate the answer for Problem 7 as well based on this?