Gravitational Numbers (Assignment) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 12

Gravitational Numbers (Assignment)

Gravitational Numbers. Numbers have mass and gravitate towards one another. Choosing 2 random numbers in the range of (0-9) compare them side by side above and below as follows. (<<) = Mass to left is greater. (>>) = Mass to Right is greater. (><) = Mass is equal both sides. (0) = Blackhole all surrounding mass gravitates towards this. Please see example. Input 3x3. Output: 5 >> 6 >> 0 v v v v v ^ 7 >> 9 >> 0 ^ ^ ^ ^ ^ ^ 1 >< 1 >> 8 Thanks

15th Apr 2018, 7:31 AM
D_Stark
D_Stark - avatar
7 Answers
19th Apr 2018, 12:07 PM
LukArToDo
LukArToDo - avatar
15th Apr 2018, 2:07 PM
Louis
Louis - avatar
+ 7
@Coming In Second haha i nearly believed you, i thought that was written with python at first 😂
15th Apr 2018, 3:31 PM
D_Stark
D_Stark - avatar
+ 3
Thanks for the interesting challenge. I really like the idea to have 0 as a "breaker" of usual comparison rule, however I implemented a trick to still keep them simple. Here is my solution: https://code.sololearn.com/cWGD0VkqgD8c/?ref=app By the way, do you plan to publish an extended version with numbers of several digits length? :-)
19th Apr 2018, 4:08 PM
Nevfy
+ 1
On-liner, class challenge{ public static void main(String[ ] args){ System.out.print("5>>6>>0\nv v v\nv v ^\n7>>9>>0\n^ ^ ^\n^ ^ ^\n1><1>>8");} } Haha
15th Apr 2018, 2:48 PM
Evan Martine
+ 1
D_Stark XD sorry I know there is no room for puns, but it technically is just a onliner of your example haha
16th Apr 2018, 3:10 PM
Evan Martine
+ 1
Well, here it is - the extended version of the challenge that operates with numbers of any length: https://www.sololearn.com/Discuss/1226683/?ref=app Have fun!
20th Apr 2018, 6:00 AM
Nevfy