Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck that list members are in groups of 4, in a row
    primarykey
    data
    text
    <p>I have a list of objects that have coordinates. The object is something like this:</p> <pre><code>private class Seats { public string Code { get; set; } public long PosX { get; set; } public long PosY { get; set; } } </code></pre> <p>For all Seats inside the list, I need to know that they are in group of 4, in a horizontal row. For example, the list below is fine:</p> <pre><code>List&lt;Seats&gt; good = new List&lt;Seats&gt; { new Seats {Code = "A1", PosX = 0, PosY = 0}, new Seats {Code = "A2", PosX = 1, PosY = 0}, new Seats {Code = "A3", PosX = 2, PosY = 0}, new Seats {Code = "A4", PosX = 3, PosY = 0} }; </code></pre> <p>The list below is also OK (two rows):</p> <pre><code>List&lt;Seats&gt; good = new List&lt;Seats&gt; { new Seats {Code = "A1", PosX = 0, PosY = 0}, new Seats {Code = "A2", PosX = 1, PosY = 0}, new Seats {Code = "A3", PosX = 2, PosY = 0}, new Seats {Code = "A4", PosX = 3, PosY = 0}, new Seats {Code = "B1", PosX = 0, PosY = 1}, new Seats {Code = "B2", PosX = 1, PosY = 1}, new Seats {Code = "B3", PosX = 2, PosY = 1}, new Seats {Code = "B4", PosX = 3, PosY = 1} }; </code></pre> <p>The list below is also OK (same row, two groups, gap at (4,0)):</p> <pre><code>List&lt;Seats&gt; good = new List&lt;Seats&gt; { new Seats {Code = "A1", PosX = 0, PosY = 0}, new Seats {Code = "A2", PosX = 1, PosY = 0}, new Seats {Code = "A3", PosX = 2, PosY = 0}, new Seats {Code = "A4", PosX = 3, PosY = 0}, new Seats {Code = "A6", PosX = 5, PosY = 0}, new Seats {Code = "A7", PosX = 6, PosY = 0}, new Seats {Code = "A8", PosX = 7, PosY = 0}, new Seats {Code = "A9", PosX = 8, PosY = 0} }; </code></pre> <p>But the list below is not OK because there is a gap at (3,0):</p> <pre><code>List&lt;Seats&gt; bad1 = new List&lt;Seats&gt; { new Seats {Code = "A1", PosX = 0, PosY = 0}, new Seats {Code = "A2", PosX = 1, PosY = 0}, new Seats {Code = "A3", PosX = 2, PosY = 0}, new Seats {Code = "A5", PosX = 4, PosY = 0} }; </code></pre> <p>The list below is also not OK because there are five of them:</p> <pre><code>List&lt;Seats&gt; bad2 = new List&lt;Seats&gt; { new Seats {Code = "A1", PosX = 0, PosY = 0}, new Seats {Code = "A2", PosX = 1, PosY = 0}, new Seats {Code = "A3", PosX = 2, PosY = 0}, new Seats {Code = "A4", PosX = 3, PosY = 0}, new Seats {Code = "A5", PosX = 4, PosY = 0} }; </code></pre> <p>The list below is also not OK because the four Seats need to be in a horizontal row:</p> <pre><code>List&lt;Seats&gt; bad3 = new List&lt;Seats&gt; { new Seats {Code = "A1", PosX = 0, PosY = 0}, new Seats {Code = "A2", PosX = 1, PosY = 0}, new Seats {Code = "B1", PosX = 0, PosY = 1}, new Seats {Code = "B2", PosX = 1, PosY = 1} }; </code></pre> <p>For checking multiplication of 4 (it can be 8, 12, ...) I can just do:</p> <pre><code>list.Count % 4 == 0 </code></pre> <p>But I need help in how to check 'in a row'.</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.
    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