Curie's Waterfall X16329


Statement
 

pdf   zip

html

Input Two integers representing the number of rows and columns of the waterfall wall, followed by a series of waterfall elements, which ends with an "end" string. Each element is represented by a different character, followed by the position of the element, represented by a row and a column. Each of the elements is defined as follows: - Font: the character ’O’. - Rock: the character ’R’. - Wormhole: the character ’W’ (followed by 2 connected positions). - Black hole: the character ’B’. - Magnet: the character ’M’ followed by its position, the type of magnet (- for repulsion and + for attraction), the radius of the magnetic field, and its power (both integer). All the given numbers are integers.

Output A two-dimensional diagram of the waterfall, representing the path (or paths) the radioactive fluid will follow, according to the input configuration of Curie’s Waterfall. Each cell is represented by a character, with an empty space represented by a dot (’.’), and the rest of the characters as outlined in the instructions. The path of the fluid should be represented by the character ’O’.

Public test cases
  • Input

    20
    60
    O 2 7
    R 4 7
    M 5 7 - 4 1
    R 13 5
    R 13 7
    R 13 9
    O 4 18
    R 15 17
    R 16 17
    R 16 18
    R 16 19
    R 16 20
    R 16 21
    R 16 22
    R 16 23
    R 16 24
    W 16 25 4 32
    R 5 32
    R 10 31
    M 4 38 + 7 1
    B 9 38
    M 10 38 + 7 1
    B 15 38
    M 19 29 - 5 1
    O 4 44 
    O 4 56
    M 10 50 + 15 1
    M 11 50 + 15 1
    R 12 50
    M 18 50 - 8 3
    end
    

    Output

    ............................................................
    ............................................................
    .......O....................................................
    ......OOO...................................................
    .....O.R.O........O............OWO....M.....O...........O...
    ....O..M..O.......O............OR.O.........O...........O...
    ...O.......O......O............O...O.........O.........O....
    ...O.......O......O............O....O.........O.......O.....
    ...O.......O......O............O.....O.........O.....O......
    ...O.......O......O...........OOO.....B.........O...O.......
    ...O.......O......O...........OR.O....M..........OMO........
    ...O.......O......O...........O...O..............OMO........
    ...O.......O......O...........O....O............O.R.O.......
    ...O.R.R.R.O......O...........O.....O..........O.....O......
    ...O.......O......O...........O......O........O.......O.....
    ...O.......O.....ROOOOOOOO....O.......B......O.........O....
    ...O.......O.....RRRRRRRRW.....O............O...........O...
    ...O.......O....................O..........O.............O..
    ...O.......O.....................O........O.......M.......O.
    ...O.......O.................M....O........O.............O..
    
  • Information
    Author
    HP CodeWars
    Language
    English
    Official solutions
    C++
    User solutions
    C++ Python