Note that there are some explanatory texts on larger screens.

plurals
  1. POCode Golf: Lasers
    primarykey
    data
    text
    <h2>The challenge</h2> <p>The shortest code by character count to input a 2D representation of a board, and output 'true' or 'false' <em>according to the input</em>.</p> <p>The board is made out of 4 types of tiles:</p> <pre><code> # - A solid wall x - The target the laser has to hit / or \ - Mirrors pointing to a direction (depends on laser direction) v, ^, &gt; or &lt; - The laser pointing to a direction (down, up, right and left respectively) </code></pre> <p>There is only <strong>one laser</strong> and only <strong>one target</strong>. Walls must form a solid rectangle of any size, where the laser and target are placed inside. Walls inside the 'room' are possible.</p> <p>Laser ray shots and travels from its origin to the direction it's pointing. If a laser ray hits the wall, it stops. If a laser ray hits a mirror, it bounces 90 degrees to the direction the mirror points to. Mirrors are two sided, meaning both sides are 'reflective' and may bounce a ray in two ways. If a laser ray hits the laser (<code>^v&gt;&lt;</code>) itself, it is treated as a wall (laser beam destroys the beamer and so it'll never hit the target).</p> <h2>Test cases</h2> <pre> Input: ########## # / \ # # # # \ x# # > / # ########## Output: true Input: ########## # v x # # / # # /# # \ # ########## Output: false Input: ############# # # # # > # # # # # # # x # # # # ############# Output: false Input: ########## #/\/\/\ # #\\//\\\ # #//\/\/\\# #\/\/\/x^# ########## Output: true </pre> <p>Code count includes input/output (i.e full program).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload