0

I need someone to help me with an algorithm , please!

7th Feb 2021, 6:51 PM
chaimaa elmaachi
chaimaa elmaachi - avatar
7 Answers
+ 1
And please specify the language too
7th Feb 2021, 8:19 PM
Atul [Inactive]
+ 1
I am favorable to python, so i will be using it with that. I recommend having a loop with a photon’s coordinates (integers) along with its dx and dy values (can only be +-1 or zero each), and incrementing its position by its velocity before checking if its current position is a mirror and adjusting the velocity appropriately. Assuming the “table” is a multi-line ascii string, i will work on code.
9th Feb 2021, 6:40 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
+ 1
This code will take the laser starting point (a tuple), a starting velocity (a capitalized one-character string of one of the compass points N, S, E, W), and a table (a multi-line string with 0s 1s and 2s with the specified meanings), and return a boolean. The coordinates start at the top left of the table, which is 0, 0. False will be returned if the laser goes back over the point where it started from heading in the same direction it started with, thus going around in circles. I have not fully tested this code yet… https://code.sololearn.com/cR6uLn5PVce0/?ref=app
9th Feb 2021, 7:30 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
+ 1
Thank you so much Wilbur Jaywright
9th Feb 2021, 11:19 PM
chaimaa elmaachi
chaimaa elmaachi - avatar
0
♤♢☞ 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 ☜♢♤ A laser cross a rectangular grid (table) that contains many mirrors. The objectif of the algorithm is to define if the laser will exit from the grid or not . The table contain 'L' lines and 'C' columns, each one of the cases of the table will get one of these values : 0, 1 or 2 0 : blank case 1 : mirror oriented \ 2 : mirror oriented / The mirror has an reflection of 45 degrees Please I need to define these cases , can you help me ?!
7th Feb 2021, 8:18 PM
chaimaa elmaachi
chaimaa elmaachi - avatar
0
Atul it's just algorithm , there is no specific language
7th Feb 2021, 8:31 PM
chaimaa elmaachi
chaimaa elmaachi - avatar