# Link elements from list to make more lists from certain lenght [closed]

How can I go from this list [36, 73, 84, 0, 73, 83, 0, 69, 69, 78, 0, 84, 69, 75, 83, 84, 31] to this [0000003673, 8400738300, 6969780084, 6975838431]. Is there also a way to make the elements the exact amount of numbers that I want. thanks in advance

• if you can explain how these new list is related from the original one, that will help, For example what is why is the first number 0000003673, what is the mapping? And why is the second one 8400738300? i,e. what are the rules used? Dec 8, 2021 at 9:51
• Thanks for your reaction. We must do something with RSA code. We must split the first list that are actually letters into the second list. The 0 in 0000003673 are no letters but must stand there because the element must be 10 long and the 0 in 8400738300 is 1 zero from the first list and is a space from our original text we had to code. Dec 8, 2021 at 9:58
• I have downvoted because the question let think that you have never used Mathematica in your life. If you don't find this convincing, take the following 2nd argument : some proof of a minimal effort is mandatory. Dec 8, 2021 at 11:22
• I was going to comment that it isn't even clear if this is a Mathematica question. If yes, please show an example input and the expected output in Mathematica format. Edit the tags and keep only those that are relevant. Do not use tags to communicate information—they are only for categorization. All relevant information should be included in the body of the post. Dec 8, 2021 at 11:28

lst = {36, 73, 84, 0, 73, 83, 0, 69, 69, 78, 0, 84, 69, 75, 83, 84, 31};

m = 5;

il = Max @ IntegerLength @ lst;

Map[StringJoin] @
IntegerString[#, 10, il] & @
Partition[lst, m, m, {- Mod[Length @ lst, m, 1], 1}, 0]

 {"0000003673", "8400738300", "6969780084", "6975838431"}


Steps:

Partition[lst, m, m, {-Mod[Length@lst, m], 1}, 0]

{{0, 0, 0, 36, 73}, {84, 0, 73, 83, 0},
{69, 69, 78, 0, 84}, {69, 75,  83, 84, 31}}

IntegerString[%, 10, il]

{{"00", "00", "00", "36", "73"}, {"84", "00", "73", "83", "00"},
{"69", "69", "78", "00", "84"}, {"69", "75", "83", "84", "31"}}

Map[StringJoin] @ %

{"0000003673", "8400738300", "6969780084", "6975838431"}

• Thank you so much for your help kglr. You realy made my day. Dec 8, 2021 at 10:06

Is there also a way to make the elements the exact amount of numbers that I want

Right now, you are partitioning in sets of five starting from the right. Let that number be k.

k = 5; (* "exact amount of numbers" *)
alist = {36, 73, 84, 0, 73, 83, 0, 69, 69, 78, 0, 84, 69, 75, 83, 84,
31}


{0, 0, 0, 36, 73, 84, 0, 73, 83, 0, 69, 69, 78, 0, 84, 69, 75, 83, \
84, 31}

clist = Partition[blist, UpTo[k]]

{{0, 0, 0, 36, 73}, {84, 0, 73, 83, 0}, {69, 69, 78, 0, 84}, {69, 75,
83, 84, 31}}

dlist = FromDigits[#, 100] & /@ clist

{3673, 8400738300, 6969780084, 6975838431}


These are numbers, but you want padded strings:

StringPadLeft[#, 2 k, "0"] &@(ToString /@ dlist)


{"0000003673", "8400738300", "6969780084", "6975838431"}

Running this with k=6 yields.

{"003673840073", "830069697800", "846975838431"}

a = {36, 73, 84, 0, 73, 83, 0, 69, 69, 78, 0, 84, 69, 75, 83, 84, 31};

StringJoin /@ Reverse[Reverse /@
Partition[Reverse[a], 5, 5, {1, 1}, 0] /. a_Integer :> ToString[a] /. "0" -> "00"]

lst = {36, 73, 84, 0, 73, 83, 0, 69, 69, 78, 0, 84, 69, 75, 83, 84, 31};

m = 5;

il = Max @ IntegerLength @ lst;

StringPartition[#, il m] & @
StringPadLeft[#, il m Ceiling[Length @ lst / m], "0"] & @
StringJoin @
IntegerString[lst, 10, il]

 {"0000003673", "8400738300", "6969780084", "6975838431"}