4 ms·
I can do 14 using parenthesis: case default(string) when await unchecked(nameof(value) as dynamic) is checked(sizeof(decimal)):
by miguelrochefort 8y ago
I can do 14 using parenthesis:
case default(string) when await unchecked(nameof(value) as dynamic) is checked(sizeof(decimal)):
- lostmsu 8y agoHe did not even try too hard. You can, obviously, add all of the standard type names and both true and false to your expression easily via ||. Add an out and ref too. Also, if you put a local function into an async lambda (not sure if that's possible), you can add all the control flow operators, and using too. The only things you won't be able to fit there, IMHO, are type keywords (class, interface, etc), namespace, visibility modifiers, static, abstract, virtual, override and operator. Actually, it might be easier to tell which keywords you can't fit into an expression.
- jameshart 8y agoThe challenge the post sets is to line up as many keywords as possible in sequence, without separating commas, semicolons, parens, braces, symbolic operators, etc. So yes, of course if you ignore the constraints on the problem it becomes much easier.
- miguelrochefort 8y agoThe challenge description has an example using parentheses, and doesn't explicitly prohibit them: > yield return sizeof(...)
- Dylan16807 8y agoThe part submitted for scoring is just "yield return sizeof", that's why he says it scores 3. The keywords can be surrounded with more code to make them compile, but none of it counts for the puzzle.
- oaiey 8y agoI agree. I wonder whether he consider an "expression" up to the place where another expression can be placed e.g. && combines two expressions into a third one.
- lostmsu 8y agoMissed the rule about nothing else but spaces in between. Can be brought up to 8 in the latest C# 7.x by adding another `is true` after `is false`. `case null when await this is false is true:` Actually, unless you count only distinct keywords, this can be extended indefinitely.