title: Calculating the area of irregular room
body: <p>There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that and the mistakes result in losses. So, he comes to you, and asks you to make a small intelligent car, which could run along the room’s walls and calculate their length. </p>
  
  <p>The car has to come back from where it’s started. This means the starting point is the same as the ending one. When the car gives the length of the room’s walls, you could calculate the surface area of the floor.</p>
  
  <p><strong><em>Knowing the surface area</em></strong>, you could calculate the price for covering the whole floor with pebbles.  3 kilograms of pebbles are needed for covering an area of 1 square meter. The rate of the pebbles is $5 per kilogram. </p>
  
  <p>For example  The car’s measurements are illustrated, using two arrays. </p>
  
  <p><code>Array 1 = {L, R, L, R, R, L, R, R, L, R, R, L, R, L, L, R, Z}</code> </p>
  
  <p>Where  <code>L</code> denotes, that the car turned Left. <code>R</code> denotes, that the car turned Right. Z denotes, that the finishing point is after the last turn.  The following picture will clear any misunderstandings (on this example <code>Array 1 = {L, R, R, R, Z}</code>).</p>
  
  <p><code>Array 2 = {3, 4, 2, 3, 2, 4, 5, 4, 2, 3, 2, 1, 2, 2, 2, 1, 2}</code></p>
  
  <p>An element of <code>Array2</code> denotes the length (in meters), covered by the car, after taking the corresponding turn.</p>
  
  <p><code>{3L, 4R, 2L, 3R, 2R, 4L, 5R, 4R, 2L, 3R, 2R, 1L, 2R, 2L, 2L, 1R, 2Z}</code></p>
  
  <p>In this representation it is clearly visible that the direction from entry turning point is measured, along with the distance to the next turning point.  The last element <code>Z</code> in <code>Array1</code> represents that the corresponding length in the <code>Array2</code> is the final distance and the car will be at finishing point after covering this length.   </p>
  
  <p>The area of the given picture is 63 square meters and the cost for covering it is $945.!</p>