@porkostomus does
Great!
I reopened the PR. @porkostomus is on a little bit of hiatus atm. I’m happy to merge anything you ask me to before Erik’s back on Tuesday
Thanks, @iHiD! Considering the schedule of the 48in24, it would be good to merge before Tuesday so your help will be much appreciated. I’ll update the PR with a more detailed status message.
Just for fun, I decided to write approaches to this exercise for the MIPS assembly track:
I’m not sure if there’s an actual maintainer for this track - maybe @iHiD or @ErikSchierboom could help?
Can I get a pair of eyeballs on Approaches for `leap` by BNAndras · Pull Request #330 · exercism/racket · GitHub? I’ll draft a set of approaches for Vim Script tomorrow.
The Vim script approach is drafted. I think writing an approach for Visual Basic would be pretty straightforward, and I’ll ping the Gleam team about writing approaches for them.
Approaches for powershell is drafted. I only need to update the folders for snippets, unfortunately i’m sick right now so that might be delayed til tomorrow when 48in24 already went live.
Approaches for Leap on powershell.
There is small nuance I think slipped in case of this exercise.
If we think in terms of logical evaluation these two sentences are the same:
a) year divisible by 4 AND NOT year divisible by 100 OR year divisible by 400
b) year divisible by 4 AND (NOT year divisible by 100 OR year divisible by 400)
In maths precedence of these operators are NOT → AND → OR, so we could at a glance think that parenthese are important. But we may skip it as the sentence:
“year is divisible by 400” equals “year is divisible by 4 AND year is divisible by 100”.
So we can evaluate b) to a)
The parens are important, think of the year 200. It is not divisible by 400, but by 100 and therefore 4.
200 % 100 == 0 && 200 % 4 == 0 => True
200 % 400 == 0 => False
I made a mistake in last sentence proving my point.
Instead “equals” I should use “implies”.
But it does not change the fact I was trying to prove.
Anegdotically, please put 200 in both sentences a) and b) and you get:
a) TRUE AND FALSE OR FALSE = FALSE
b) TRUE AND (FALSE OR FALSE) = FALSE
Of course we need more general proof, let me do this later.
I did a truth table to prove a) and b) are equivalent.
Please see the attachment.
To shorten I used following notation:
“?400”: year is divisible by 400.
“?4” and “?100”: by analogy.
“?~100”: NOT “?100” or year is not divisible by 100.
I assumed precedence as previously but it’s not forced in pure logic, so we can assume automatic parenthesis around AND sentence in my truth table.
The key is really to see that ?400 == True implies ?4 == True AND ?100 == True,
?100 == True implies ?4 == True,
also ?4 == False implies ?400 == False AND ?100 == False.
Hence only 4 cases in truth table.
Are you taking into account the fact that these operators may short circuit?
Logically, a and b
is the same as b and a
. However, in code, those may have different side effects (though the results will be the same).
Oh that, thanks!
I was only proving correctness of the two statements. Totally regardless of programming languages implementation.
It was interesting to me that you can arrange the statement differently not being suggested by the definition in the problem description.
Logically the same, computationally different