What does this relevance do? I’m looking for what the Yes/No represents that is returned.
tuple string items ( ((it mod 400) whose(it = 0) | (it + 1) whose(it = 1) of (it mod 100) | (it mod 4) whose(it = 0) | 1 ) of integers in (0, 400, 1) ) of "Yes, No"
I would play around with this in QnA / the fixlet debugger in different ways.
Submissions for guesses is closed, the answer is now posted below.
Hints
Play around with integers in (0, 400, 1) … this is intentionally set to something obscure. Try it by itself and play around with stuff.
What these input values represent is part of the key to figuring it out.
Also, try this part in isolation: ((it mod 400) whose(it = 0) | (it + 1) whose(it = 1) of (it mod 100) | (it mod 4) whose(it = 0) | 1 ) of integers in (0, 400, 1)
The first thing to understand about this relevance is the math logic behind it, which is where the mod part comes in.
The other part is to understand what the | is doing together with the whose statements.
Lets start with the | part, and consider this:
Q: "this" whose(FALSE) | "that"
A: that
T: 0.024 ms
I: singular string
the above statement returns that because the left side of the | returns nothing, so then it continues to the next statement and evaluates that. If the left side of the | did not have a whose filter to set it to false, then this would have been returned.
You can kind of think of it as a switch case statement in programming or a different way to write if/then/else that is a bit more efficient in some ways.
The next part is mod which deals with remainder in division.
If you were to rewrite this core part of the relevance in semi English pseudo code, you would have:
if evenly divisible by 400 return 0
if evenly divisible by 100 return 1
if evenly divisible by 4 return 0
else return 1
If you understand the significance of 400, 100, 4, and “1” in this order, you could actually figure this out without actually understanding the relevance or the math at all, but a key part is what is the thing we are checking the remainder? What do the numbers here represent? :
A very big hint is that the day I posted this relevance challenge matters to the solution.
integers in (0, 400, 1) produces the numbers 0 through 400 counting by 1’s, but you could change it to play around with other values. They key is that these numbers for this purpose represent Years. When the math is done against the calendar year being input into it, you get a Yes or a No returned by way of:
Q: tuple string items ( 0 ; 1 ) of "Yes, No"
A: Yes
A: No
T: 0.042 ms
I: plural string
So after all that, what does this relevance do? What is the answer I was looking for? It tells you if the year input into it is a leap year or not! And this challenge was posted on Feb 29th for that reason.
See here:
Q: tuple string items ( ((it mod 400) whose(it = 0) | (it + 1) whose(it = 1) of (it mod 100) | (it mod 4) whose(it = 0) | 1 ) of /* The current year as integer: */ 2024 ) of "Yes, No"
A: Yes
T: 0.037 ms
I: plural string
I didn’t actually know this at the time, but was pointed about by @brolly33 , but this relevance actually does the same thing, but without doing math:
Q: leaps of (2024 as year)
A: True
T: 0.028 ms
I: plural boolean