Beta
Bitwise logical negation
Description:
Task
Given a number n
, return the logical negation of n
, i.e., return 1
if n = 0
, otherwise return 0
.
Restrictions
- You may only use at most
28
characters - You may only use the following characters:
[0-9]
,[a-z]
,(
,)
,+
,~
,&
,|
,^
,<
,=
,>
([A-Z]
and whitespace characters are not allowed) - You may only use the character
+
at most2
times - You may not use the following operators:
&&
,&&=
,||
,||=
,<
,<=
,==
,===
,>=
,>
. This implies that only the following operators (and their respective assignment counterparts) are allowed:+
,~
,&
,|
,^
,<<
,>>
,>>>
Examples
negation(0) // 1
negation(1) // 0
negation(-1) // 0
negation(32) // 0
Constraints
-2147483648 ≤ n ≤ 2147483647
Puzzles
Restricted
Similar Kata:
Stats:
Created | Sep 25, 2021 |
Published | Sep 25, 2021 |
Warriors Trained | 85 |
Total Skips | 5 |
Total Code Submissions | 155 |
Total Times Completed | 20 |
JavaScript Completions | 20 |
Total Stars | 3 |
% of votes with a positive feedback rating | 78% of 9 |
Total "Very Satisfied" Votes | 6 |
Total "Somewhat Satisfied" Votes | 2 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 9 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |