[Solved] Why the output in this Ruby challenge is 124? 🤔 | SoloLearn: Learn to code for FREE!


[Solved] Why the output in this Ruby challenge is 124? 🤔

Just from yesterday I started learning Ruby. Haven't done tutorial even half a way. Played this challenge, but did not understood why correct answer is 124 here. Need explanation. Please, help me! https://www.sololearn.com/post/626500/?ref=app

9/30/2020 1:33:31 AM


9 Answers

New Answer


The code works with the rows of the array (or sub arrays). It convers every element of the sub-array to string and output element with max length from this row. So for the first sub array max len is 1 character, for the second one is 2 characters, and for the third one - 4) First map with x - takes sub-arrays x.map - taks elements y from sub-array x y.to_s.size - rerurn length of the element y that was converted to the string, and we output the max len of the element from every sub-array.


Thank you Vladimir ! I did not understood x.map & y.to_s.size while answering the question. Now, it make sense about the length of sub-arrays.


length of the elements of the sub-arrays ) map is like foreach ... the first map takes every sub-array and do second map on every element of the sub-array


Ah, my bad 😅 it's length of the elements of the sub-array 👍


sorry for my bad explanation 😂


No worries Vladimir 😄👍


In html, When i use / for ending code it displays the same results as without / why?plz answer me also


Because you should do test and understand basics first ok first only I also traded challenge but afterwards I understand