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 most 2 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:

CreatedSep 25, 2021
PublishedSep 25, 2021
Warriors Trained85
Total Skips5
Total Code Submissions155
Total Times Completed20
JavaScript Completions20
Total Stars3
% of votes with a positive feedback rating78% of 9
Total "Very Satisfied" Votes6
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes1
Total Rank Assessments9
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • user9307760 Avatar
  • NunoOliveira Avatar
  • Kacarott Avatar
Ad