Java Script Laser 3D

This is one of the more challenging of tasks I’ve solved in my preparation of the JS Exam:

Laser
Condition:

Given a cuboid made from cubes with. It’s width, height and depth are known. From a given startpoint a laser is shot in one of 26 directions. Direction is a 3D vector (i.e. (1,-1,1) will move to the right,down (up in my draw), deeper(right-er) in every turn). The laser burns cubes that it passes through  and stops when a burned cube has been reached. The red,green and blue cubes in the picture are burned on the start so they will never be the answer.

Demo

In the console part I print out a cuboid current state. On the left is the close wall and on the right the back wall . Every move of the ‘laser‘ is represented by a 5 for better view. Every draw is a new move.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s