+ 1
Reading letters from a 2d array
I have been trying to solve a problem I was given by a friend for the last week and nothing came to me. Here is the problem: Given a bidimensional array filled with 1 and 0, output the text encoded inside the array. For example, if we have the following array: 1 0 1 0 1 1 1 1 1 1 1 0 1 0 0 0 1 0 1 0 1 1 1 1 0 0 0 0 0 0 0 0 the output should be "HC".
7 Answers
+ 1
First time I make something like this, took me about half an hour but glad it worked :)
Just change the array I've made to the array you want and enjoy!
https://code.sololearn.com/Wy8YULSy7WfQ/?ref=app
0
Sorry to disappoint you but your code doesn't do what I asked. Your code just converts each line of the array from base 2 to base 10 and then outputs the related character. I want to read the letters written in the array.
In my example, 1s form an H and a C so the outputs is HC
0
In this case you'll need to put the H code and C code in two different subarrays. Can you show me other examples of expected outputs for the code you want?
0
01111100010001
00010000010001
00010000011111
Output: TU
But not only 2 letters, as many letters as you want
0
This doesn't seem right man. These are 3 subarrays, each one represents a character.
01111100010001 = |
00010000010001 = D
00010000011111 = A
I don't see how 3 subarrays are expected to output two characters like that.
0
No. If look closely you'll see that there is a T formed in the let left half and an U in the right halh
0
Dammit xD
Haha now I get it. I'll give it a shot today, will let you know if I come up with something.