You are viewing a single comment's thread. Return to all comments →
Single line solution, just for fun, and cuz I love the ternery operator ;-) (passed all 7 TC's)...
System.out.println((n%2==1 || (n>=6 && n<=20)) ? "Weird" : "Not Weird");
;) oh yes you do!
This is my favourite solution. Good stuff.
You don't need parentheses - precedence of the ternary operator is lower than logical OR https://introcs.cs.princeton.edu/java/11precedence/
From that article: "Most programmers do not memorize them all, and even those that do still use parentheses for clarity."
Wow... You're the real MVP.