A solution to solve the encryption
An English text needs to be encrypted using the following encryption scheme. First, the spaces are removed from the text. Let be the length of this text. Then, characters are written into a grid, whose rows and columns have the following constraints:
For example, the sentence
s = if man was meant to stay on the ground god would have given us roots, after removing spaces is 54 characters long. SQRT(54) is between 7 and 8, so it is written in the form of a grid with 7 rows and 8 columns.
ifmanwas
meanttos
tayonthe
groundgo
dwouldha
vegivenu
sroots
the output is
imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau
-
1 <= s <= 81
-
s is comprised only of characters in the range ascii[a-z].
This requires me to place the sentence in the R x C matrix by row, but print out by column. Using math, we can know that it just needs to print out the letters by skipping R letters.
The full solution script is provided here
haveaniceday
hae and via ecy
L = 12, SQRT(12) is between 3 and 4. Rewritten with 3 rows and 4 columns:
have
anic
eday
feedthedog
fto ehg ee dd
L = 10, SQRT(10) is between 3 and 4. Rewritten with 3 rows and 4 columns:
feed
thed
og
chillout
clu hlt io
Explanation 3
L = 8, SQRT(8) is between 2 and 3. Rewritten with 3 columns and 3 rows (2*3 = 6 < 8 so we have to use 3x3)
chi
llo
ut
""
""
Explanation 4
Empty String
aaaaaabbbbbbccccccddddddeeeeee
abcde abcde abcde abcde abcde abcde
Explanation 5
L = 30, SQRT(30) is between 5 and 6. Rewritten with 5 columns and 6 rows
abcde
abcde
abcde
abcde
abcde
abcde
aaaaaabbbbbbccccccddddddeeeee
abcde abcde abcde abcde abcde abcd
Explanation 6
L = 29, SQRT(29) is between 5 and 6. Rewritten with 5 columns and 6 rows
abcde
abcde
abcde
abcde
abcde
abcd
aaaaaabbbbbbccccccddddddeeeeee
abcde abcde abcde abcde abcde abcdef
Explanation 7
L = 31, SQRT(30) is between 5 and 6. Rewritten with 6 columns and 6 rows
abcdef
abcde
abcde
abcde
abcde
abcde