15
I was in the bus today, and noticed this sign:
seated standing wheelchairs
max1 37 30 00
max2 36 26 01
max3 34 32 00
The number of seated passengers, standees, and wheelchairs all have to be no larger than some row in the table. (See chat for details.)
For the purposes of this challenge we will generalise this idea: Given a non-negative integer list of a strictly positive length N (number of passenger types) and a non-negative integer matrix of strictly positive dimensions (N columns and one row per configuration, or the transpose of this), return a list of indices/truthy-falsies/two-unique-values indicating which configurations limits are fulfilled.
E.g. with the above matrix:
30,25,1
→ [1]
(0-indexed) [2]
(1-indexed) or [false,true,false]
(Boolean) or ["Abe","Bob","Abe"]
(two unique values) etc.
The following test cases use the above matrix and the 0/1 for false/true:
[30,30,0]
→ [1,0,1]
[30,31,0]
→ [0,0,1]
[35,30,0]
→ [1,0,0]
[0,0,1]
→ [0,1,0]
[0,0,0]
→ [1,1,1]
[1,2,3]
→ [0,0,0]
The following test cases use the following matrix:
1 2 0 4
2 3 0 2
[1,2,1,2]
→ [0,0]
[1,3,0,1]
→ [0,1]
[1,2,0,3]
→ [1,0]
[1,2,0,1]
→ [1,1]
Am I misunderstanding this challenge or can
[30,31,0]
be[1, 1, 1]
because it's covered bymax3
? – Okx – 2018-08-05T17:47:15.887Is swapping truth values allowed? (e.g. any truthy value in place of
0
and any falsy one in place of1
?) – Mr. Xcoder – 2018-08-05T17:48:24.287@Okx You're misunderstanding something.
[x,31,z]
rules outmax1
andmax2
because they don't allow 31 standees. – Adám – 2018-08-05T17:50:42.930@Mr.Xcoder Is that usually allowed in challenges like this? – Adám – 2018-08-05T17:52:03.523
I used to think (see (2)) (also see Martin's comment) this is allowed by default, but I haven't found a meta consensus. I have proceeded by posting this meta question, whose conclusion that the OP should be asked first. I usually allow it, I don't see the reason why they shouldn't be swapped.
– Mr. Xcoder – 2018-08-05T17:56:30.277@Mr.Xcoder I think I'll leave it like this for now (several answers are already in), but I'll try to keep it in mind for next time. – Adám – 2018-08-05T18:06:52.517
@Mr.Xcoder To my understanding: If you are using the same truthy value / falsy value (always use
1
for thuthy,0
for falsy), they are "two unique values" which is allowed by this post; If your truthy value / falsy value variance between testcases (sometime use0
for falsy, but sometime usefalse
for falsy), they are not allowed. – tsh – 2018-08-06T06:37:32.627@tsh Right, that's correct with the current formulation of the OP. – Adám – 2018-08-06T07:42:27.230
I think Okx's misunderstanding could be avoided if the example matrix wasn't square. – JiK – 2018-08-06T17:03:04.120
@JiK Right. That's why I included the other test matrix as well. – Adám – 2018-08-06T17:26:32.217