Skip to main content
added 11 characters in body
Source Link
auhmaan
  • 896
  • 5
  • 7

C# (Visual C# Interactive Compiler), 4343 38 bytes


Golfed Try it online!Try it online!

i=>Convert.ToString(i,2).CountSum(c=>c>48c=>c)%2<1

Ungolfed

i => Convert.ToString( i, 2 ).CountSum( c => c > 48 ) % 2 < 1

Full code with tests

Func<Int32, Boolean> f = i => Convert.ToString( i, 2 ).CountSum( c => c > 48 ) % 2 < 1;

Int32[] testCases = { 3, 11, 777, 43, 55 };
    
foreach( Int32 testCase in testCases ) {
    Console.Write( $" Input: {testCase}\nOutput: {f(testCase)}" );
    Console.WriteLine("\n");
}

Console.ReadLine();

Releases

  • v1.1 - -5 bytes - Replaced Count to Sum
  • v1.0 - 43 bytes - Initial solution.

Notes

  • None

C# (Visual C# Interactive Compiler), 43 bytes


Golfed Try it online!

i=>Convert.ToString(i,2).Count(c=>c>48)%2<1

Ungolfed

i => Convert.ToString( i, 2 ).Count( c => c > 48 ) % 2 < 1

Full code

Func<Int32, Boolean> f = i => Convert.ToString( i, 2 ).Count( c => c > 48 ) % 2 < 1;

Int32[] testCases = { 3, 11, 777, 43, 55 };
    
foreach( Int32 testCase in testCases ) {
    Console.Write( $" Input: {testCase}\nOutput: {f(testCase)}" );
    Console.WriteLine("\n");
}

Console.ReadLine();

Releases

  • v1.0 - 43 bytes - Initial solution.

Notes

  • None

C# (Visual C# Interactive Compiler), 43 38 bytes


Golfed Try it online!

i=>Convert.ToString(i,2).Sum(c=>c)%2<1

Ungolfed

i => Convert.ToString( i, 2 ).Sum( c => c ) % 2 < 1

Full code with tests

Func<Int32, Boolean> f = i => Convert.ToString( i, 2 ).Sum( c => c ) % 2 < 1;

Int32[] testCases = { 3, 11, 777, 43, 55 };
    
foreach( Int32 testCase in testCases ) {
    Console.Write( $" Input: {testCase}\nOutput: {f(testCase)}" );
    Console.WriteLine("\n");
}

Console.ReadLine();

Releases

  • v1.1 - -5 bytes - Replaced Count to Sum
  • v1.0 - 43 bytes - Initial solution.

Notes

  • None
Source Link
auhmaan
  • 896
  • 5
  • 7

C# (Visual C# Interactive Compiler), 43 bytes


Golfed Try it online!

i=>Convert.ToString(i,2).Count(c=>c>48)%2<1

Ungolfed

i => Convert.ToString( i, 2 ).Count( c => c > 48 ) % 2 < 1

Full code

Func<Int32, Boolean> f = i => Convert.ToString( i, 2 ).Count( c => c > 48 ) % 2 < 1;

Int32[] testCases = { 3, 11, 777, 43, 55 };
    
foreach( Int32 testCase in testCases ) {
    Console.Write( $" Input: {testCase}\nOutput: {f(testCase)}" );
    Console.WriteLine("\n");
}

Console.ReadLine();

Releases

  • v1.0 - 43 bytes - Initial solution.

Notes

  • None