An Encryption Question. Made me lost 100000 brain cells :D

**Voters**

SixBeeps (2289)

You could probably do this without a 2D array. Do you need to use one?

NgMarco (0)

@SixBeeps

No sir, the tutor said we can do whatever we can to solve this question.

Can I ask what method I can use instead?

is N always 10?

@mwilki7 no sir, it depends on the number of digit of the KEY input by the user. As an example, 1234567890 is the KEY input by user, the number n equal to 10.

@NgMarco

will there ever be a digit larger than the length of the whole number?

for instance: "1239" length 4, but there is a 9

@mwilki7

(This reply is false. Sorry for causing misunderstanding.🤦😂)

Yes, every single digit of the KEY can be larger than the length of the whole number.😁

For example, length of "19" is 2, but largest digit in the number is 9.

@NgMarco

for example:

Starting encryption with "19"

[zero-th digit] 1 - would move Column 0 to 1

[first digit] 9 - would move Column 1 to

`9 <- this would cause a seg fault`

this only has 2 columns, but the 2nd digit wants to move a column 9 or am I misunderstanding something

@mwilki7 Sorry I made a mistake in the last reply. The key wont be number 19.

@NgMarco ok i understand better now

are you able to use strings instead of char arrays?

for example:

@mwilki7 yes we can use any methods :D

BTW

I made another mistake :(that the leading digit of the key can start with 0. Therefore in the last picture, there should be 3 options of key which are {01,10,11}@NgMarco

a 2D array would be the easiest way to do this problem

is there a specific part of this program you don't know how to do?

@mwilki7

i wonder how to change the columns for the encryption. :)

can i invite you to another repl to ask you about the encryption step involving the 2d arrays

@NgMarco

sure