Back
Close

Laser and mirrors

Statement

 Goal

Take a board of R rows and C columns. Shoot a laser beam rightward from the top-left corner. It reflects off the mirrors / and \, and stops at the target #. Print the cells that the laser beam passed excluding the mirrors and the target.
Input
Line 1: Two space-separated integers R and C for the size of the board
Next R lines: The board's layout
Output
Line 1: The cells that the laser beam passed as one long string
Constraints
1 ≤ R,C ≤ 16
Example
Input
8 8
Hello, \
       w
       o
       r
       l
       d
       !
       #
Output
Hello, world!

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
8 8 Hello, \ w o r l d ! #
Output
Hello, world!

Validator 1 Validator
Input
6 6 One, \ t w o ! #
Output
One, two!

Test 2 Test
Input
1 6 Right#
Output
Right

Validator 2 Validator
Input
1 9 Straight#
Output
Straight

Test 3 Test
Input
6 1 \ D o w n #
Output
Down

Validator 3 Validator
Input
8 1 \ D o w n . . #
Output
Down..

Test 4 Test
Input
5 9 \ . \Twists \ / dna/ #\tu\ . \snr/ .
Output
Twists and turns

Validator 4 Validator
Input
5 9 \ . \eeeeeee\ /eeee/ #\ee\ . \eee/ .
Output
eeeeeeeeeeeeeeee

Test 5 Test
Input
3 11 Double\/r#. /edis-/\o\. \d mir/\r/.
Output
Double-sided mirror

Validator 5 Validator
Input
5 11 \/- sid\/\. d\el\/e/or. \oub//mi\\# ....d...rr. ....\/..\/.
Output
double- sided.mirror

Test 6 Test
Input
3 4 l\ . /op# \/ .
Output
loop

Validator 6 Validator
Input
3 5 mi\ . /ors# \r/ .
Output
mirrors

Test 7 Test
Input
7 7 Sh\ . /or t\ fo/eh/ t . \/m . /on!# \/ .
Output
Shoot for the moon!

Validator 7 Validator
Input
7 7 SH\ . /OR T\ FO/EH/ T . \/M . /ON!# \/ .
Output
SHOOT FOR THE MOON!

Test 8 Test
Input
8 14 If\**/e am\/s# ** */\b\/\o\\* / you \ htn*r* s*\o/mwle g//* \si\///l \/a** ***\//li\st\\* ****\i/\t/\\/* **************
Output
If you miss you will still be among the stars

Validator 8 Validator
Input
8 14 iF\**/E aM\/s# ** */\b\/\o\\* / you \ hTN*r* s*\O/MWLE g//* \Si\///l \/a** ***\//Li\sT\\* ****\i/\T/\\/* **************
Output
iF yOu MiSs you WiLl sTilL bE aMoNg ThE sTars

Test 9 Test
Input
10 8 111111\1 1/\/662\ 13551127 /3//33// #3341191 13341191 /99\55\\ 03281161 0\28226/ \1/\77/1
Output
111111223344556677889900122933566279916228239333353

Validator 9 Validator
Input
10 8 123456\1 1/\/234\ 19011185 /8//09// #7011161 16921171 /58\34\\ 34701158 4\32109/ \5/\87/1
Output
123456489012345978208534537890123456789012345678908

Test 10 Test
Input
10 13 Ready.\#\ . / ..//\\ . \Set.\!\\ . /..//\/\. \ GOoooO\ /oOoOo/ \ooOoo\ /oOoOo/ \OoooO\ \/\/\/
Output
Ready... Set... GOoooOoOoOoooOoooOoOoOoooOOoooOoOoOoooOoooOoOoOoooO!!

Validator 10 Validator
Input
10 13 Ready.\#\ . / ..//\\ . \Set.\!\\ . /..//\/\. \ WHEEEE\ /E e E/ \Ee eE\ /E e E/ \EEEEE\ \/\/\/
Output
Ready... Set... WHEEEEE e EEe eEE e EEEEEEEEEEEE e EEe eEE e EEEEEH!!

Solution language

Solution

Stub generator input