+ 7

# [ASSIGNMENT] Magnetic numbers (extended version)

PART 1: Let's pretend that numbers from 0 to 9 are the poles of a magnet. - if the number is even its a positive pole (+) - if the number is odd its a negitive pole (-) Two numbers can either attract ( >< ) or repel ( <> ). For example: 6 <> 2 or 3 >< 4 Numbers with several digits can attract ( >< ), repel ( <> ) or be balanced ( ~~ ) depending on attraction or repeling of their corresponding digits. For example: 105 <> 397 because 1 <> 3 and 0 >< 9 and 5 <> 7 12 ~~ 13 because 1 <> 1 and 2 >< 3

11th Apr 2018, 1:32 AM
Nevfy
+ 6
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/c4Zqk4AGXfId/?ref=app - John Wells (kt): https://code.sololearn.com/cWL5yR79fK7D/?ref=app - Oma Falk (Python): https://code.sololearn.com/caO5WPb48Xsn/?ref=app - Lucas Pardo (Python): https://code.sololearn.com/cYLXlbztmEuz/?ref=app - LukArToDo (Java): https://code.sololearn.com/csBwc6yWjn4y/?ref=app - ~ swim ~ (C++): https://code.sololearn.com/crbKi7Lzpw7V/?ref=app - ... free place for your solution if you will be able to find it ... Good luck! ;-)
11th Apr 2018, 5:50 PM
Nevfy
12th Apr 2018, 5:07 PM
LukArToDo
+ 8
https://code.sololearn.com/caO5WPb48Xsn/?ref=app
11th Apr 2018, 2:56 PM
Oma Falk
11th Apr 2018, 10:38 AM
John Wells
+ 3
PART 2: Your task is: Using a random number generator build a matrix of given size with given numbers length and print it out together with numbers magnetic states. Good luck! Example of the output for the input 3,2,4 (matrix 3 by 2 with 4 digits numbers): 6185 <> 8306 ^ v v ^ 2523 >< 9417 ~ ^ ~ v 3533 ~~ 4695 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/1207800/?ref=app I thank @D_Stark for the initial idea of the task and @John Wells for the idea of its extension.
11th Apr 2018, 1:33 AM
Nevfy
+ 3
Here is my try, I think it works quite nice, It was a challenge to learn how to make the vertical signs and align then in the middle of any two numbers. Really good challenge! https://code.sololearn.com/cYLXlbztmEuz/?ref=app
12th Apr 2018, 3:57 PM
Lucas Pardo
+ 2
@Oma Falk Not only both but all numbers must have the same numbers of digits, which is defined by third number in the input. See my example in PART 2.
11th Apr 2018, 1:26 PM
Nevfy