Skip to main content
added 53 characters in body
Source Link
Destroigo
  • 411
  • 2
  • 6

C# (.NET Core), 6262, 49 bytes

Without LINQ. Bitwise operations

EDIT: dana with a -13 byte golf changing the while to a recursive for and returning a bool instead of integer.

x=>{int j=0;while(x>0){j+=j=0;for(x&1;x>0;x/=2)>0?1:j+=x%2*2-1;x>>=1;}return1;return j>0?1:0;j>0;}

Try it online!Try it online!

C# (.NET Core), 62 bytes

Without LINQ. Bitwise operations.

x=>{int j=0;while(x>0){j+=(x&1)>0?1:-1;x>>=1;}return j>0?1:0;}

Try it online!

C# (.NET Core), 62, 49 bytes

Without LINQ.

EDIT: dana with a -13 byte golf changing the while to a recursive for and returning a bool instead of integer.

x=>{int j=0;for(;x>0;x/=2)j+=x%2*2-1;return j>0;}

Try it online!

Source Link
Destroigo
  • 411
  • 2
  • 6

C# (.NET Core), 62 bytes

Without LINQ. Bitwise operations.

x=>{int j=0;while(x>0){j+=(x&1)>0?1:-1;x>>=1;}return j>0?1:0;}

Try it online!