Which of these statements evaluates to the largest value?

Week of September 21, 2026 172 responses

This quiz has ended. You can still submit an answer to see results.

Note: Answering past quizzes does not count toward your streak.

Sign in to participate
Umar
Umar on 24 Sep 2026
Streak started, sanity optional. Matlab's apostrophe is a double agent (transpose or string?), so even lexers have to track whether the previous token was a value. One linter's notes say a quote after whitespace always starts a string, so that space in [''' '' '''] is the tiebreaker.
John D'Errico
John D'Errico on 21 Sep 2026 (Edited on 21 Sep 2026)
One would think that given my last name, I should be an expert in apostrification. (Is that a word? Surprsingly, it does appear to be a word.) And so you would think the answer was obvious to me, but it did take some thought.
Actually, it is not difficult, as long as you appreciate the rules of doubled apostrophes and character catenation. Just take your time and count. For me, I took each one, predicted the expected length, then verified my expectation.
Cute quiz question though.
char(nthroot(sum('Ouch!'),4)*17-8)
Rik
Rik on 22 Sep 2026
I had to dive pretty deep into the syntax machinery for strings and chars for my minify function. Since the extremely complicated regex that I found was only able to do half the job, I had to write a parser, which you can see in the DetermineParseState function inside minify. The test set also includes nonsensical things like:
""' %transposes a scalar string (which doesn't do anything)
ans = ""
dpb
dpb on 12 Oct 2026
Like @goc3 and @the cyclist, impossible for old eyes to discern what is " and ' without blowing it up enough to be able to tell apart...if were to really try, I'd probably use a double() on the strings to be able to know which was which first.
John D'Errico
John D'Errico on 12 Oct 2026 (Edited on 12 Oct 2026)
It depends on the font. A mono-spaced font will tell the difference. For example, which is which below?
''
"
One trick is to click on the above, and use the cursor control keys on my keyboard, I can see the former is a 2 character pair, whereas the latter is just one character. I needed to click only once on the latter.
However, if we look at the two in a code block, MATLAB clearly distinguishes between the two.
''
"
And that tells it all. Now, without evaluating any of those code fragments, we see all the quotes were single quotes by putting them in a code block, even without evaluating them.
length([''''''''])
length([''''''' '])
length(['''''' ''])
length(['' '''' ''])
length([''' '' '''])
length(['' '' '' ''])
But had I simply set them in a mon-spaced font, the difference is also clear.
length([''''''''])
length([''''''' '])
length(['''''' ''])
length(['' '''' ''])
length([''' '' '''])
length(['' '' '' ''])
That works, even for my also admittedly old eyes. (Note the monospaced font here.)
Ned Gulley
Ned Gulley on 22 Sep 2026
I love this one! Look for that trick buried in a future quiz...
M_A_C
M_A_C on 21 Sep 2026
Character and String arrays are among the most difficult things in MATLAB for me. By the way, the square brackets are decorative or deceptive; with or without them, option E generates a variable of type char of length 5. Thank you for such an instructive quiz and an explanation.
goc3
goc3 on 21 Sep 2026
I can tell which are single quotes. And, I can tell which are two single quotes OR double quotes. Other than that, I have to zoom way in to count...
the cyclist
the cyclist on 21 Sep 2026 (Edited on 21 Sep 2026)
I do these sorts of character array manipulations quite a bit (to construct input for SQL commands), and still got it wrong.
MATLAB having both character arrays and string arrays can add to the confusion! (I had to paste these into the editor to be certain whether any of the symbols were actually double-quotes.)

Tags

No tags entered yet.