+ 5

[ASSIGNMENT] Gravitational Numbers (extended version)

PART 1: Let's pretend that numbers from 1 to 9 have mass and gravitate towards one another. The higher value attracts the smaller (the smaller value moves towards the higher). The following notation is introduced: (<<) = Mass to left is greater. (>>) = Mass to Right is greater. (><) = Mass is equal both sides. (0) is a Blackhole, so all surrounding mass gravitates towards it.

20th Apr 2018, 5:06 AM
Nevfy
4 Answers
+ 2
SOLUTIONS LIST: If you experience some difficulties solving this task, you can refer to this list of correct solutions: - my own solution (Python): https://code.sololearn.com/cDeSwkB15el2/?ref=app - LukArToDo (Java): https://code.sololearn.com/chD9bQ80g48z/?ref=app - ~ swim ~ (C++): https://code.sololearn.com/c9VCUjwA1HaG/?ref=app - ... free place for your solution if you will be able to find it ... Good luck! ;-)
20th Apr 2018, 1:49 PM
Nevfy
20th Apr 2018, 8:02 AM
LukArToDo
LukArToDo - avatar
+ 3
PART 2: Numbers with several digits move depending on the interaction between their corresponding digits. For example: 175 >> 391 because 1 >> 3 and 7 >> 9 and 5 << 1 12 >> 13 because 1 >< 1 and 2 >> 3 42 >< 13 because 4 << 1 and 2 >> 3 However, if number contains 0 it overrides the effect of any other interactions! If one of the number has more 0s than the other it has bigger mass. For example: 107 << 359 because it contains 0 despite of 1 >> 3 and 7 >> 9 102 >> 100 because 102 has one 0 whereas 100 has two 0 107 >< 250 because both have one 0 YOUR TASK: Using a random number generator build a matrix of given size with given numbers length and print it out together with gravity states. Example for the input 3,2,4 (matrix 3 by 2 with 4 digits numbers): 6185 >> 8306 << 2947 ^ ^ ^ v ^ ^ 2523 >< 9417 >> 1928 v v v v v v 3503 >> 4005 >< 1900 CREDENTIALS: This task is an extension of the other one, which operates only with one digit numbers. So if you didn't solve it before, you can find its full text here: https://www.sololearn.com/Discuss/1216717/?ref=app I thank @D_Stark for the great initial idea.
20th Apr 2018, 5:07 AM
Nevfy