Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A teacher want to share details of students to school's management. All the data can be accessed using roll number, name and secret code. The

A teacher want to share details of students to school's management. All the data can be accessed using roll number, name and secret code. The teacher shares this information using go channels. But before writing to channel the teacher modifies secret code according to following rules- 1- You divide the SecretCode in equal size chunks 2- Re-arrange the chunks in reverse order 3- If length is such that it cannot be divided in equal size chunks then you pad the secret code using '0'. Eg: secret code length is 8 and chunk size is 5 so you add "00" in secret code which makes the length 10 and get each chunk of size 5

Write a program in which a go routine 'teacher' takes three SecretStudent objects. Modifies the secret code according to the rules. Convert the object to byte array(using json encoding) and write the byte array to A channel

Another go routine 'management' reads from the channel. Decode the byte array and display the recieved SecretStudent. After that fix the SecretCode and display it.By using GO LANG

Here are 2 examples for secretCode modification

Examples1 =========== Input: SecretCode: abcdefghijkl ChunkSize: 4 Length: 12

Output: ijklefghabcd

Examples2 =========== Input: SecretCode: abcdefghijkl ChunkSize: 5 Length: 12

Output: kl000fghijabcde

NOTE:-

optimise the code and please give me solution as per mentioned requirements.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago

Question

What resources will these tactics require?

Answered: 1 week ago

Question

What level of impact will this tactic make on the key public?

Answered: 1 week ago

Question

Have you used powerful language in your message?

Answered: 1 week ago