Ad
Code
Diff
  • def is_even(n):
        return n % 2 ^ 1
        
    • def is_even(n):
    • return not(n%2)
    • return n % 2 ^ 1
Code
Diff
  • def is_even(x): return (x << 1 & 2) >> 1 < 1
    • def is_even(x): return x & 1 ^ 1
    • def is_even(x): return (x << 1 & 2) >> 1 < 1
Code
Diff
  • is_even=lambda x: ~ x & 1
    • is_even=lambda x: x & 1 ^ 1
    • is_even=lambda x: ~ x & 1
Code
Diff
  • def is_even(x):
        return x & 1 ^ 1
    
    • def is_even(x):
    • return not x & 1
    • return x & 1 ^ 1
Code
Diff
  • even_or_odd = lambda n: "Odd" if n & 1 else "Even"
    • even_or_odd = lambda n: "Odd" if n % 2 else "Even"
    • even_or_odd = lambda n: "Odd" if n & 1 else "Even"
Code
Diff
  • def is_even(x):
        return 1 ^ x % 2
    
    • def is_even(x):
    • return abs((x % 2)-1)
    • return 1 ^ x % 2
Code
Diff
  • is_even = lambda x: not x % 2
    
    • is_even = lambda x: not bool(x % 2)
    • is_even = lambda x: not x % 2
Code
Diff
  • package cat;
    public class kata{
    public static int doubleValue(int x) {
        return x << 1;
    }
    }
    • package cat;
    • public class kata{
    • public static int doubleValue(int x) {
    • return x * 2;
    • return x << 1;
    • }
    • }
Code
Diff
  • def even_or_odd(n):
        return ("Even", "Odd")[n % 2]
    
    
    • def even_or_odd(n):
    • return ["Even", "Odd"][n % 2]
    • return ("Even", "Odd")[n % 2]
Code
Diff
  • is_even = lambda x: not x & 1
    
    • is_even = lambda x: not(x % 2)
    • is_even = lambda x: not x & 1
Code
Diff
  • is_even = lambda x: not x & 1
    
    
    • is_even = lambda x: x % 2 == 0
    • is_even = lambda x: not x & 1
Code
Diff
  • is_even = lambda x: not x >> 1 << 1 < x
    
    
    • is_even = lambda x: not (x % 2)
    • is_even = lambda x: not x >> 1 << 1 < x
Code
Diff
  • package cat;
    public class kata{
    public static int doubleValue(int x) {
        return x + x;
    }
    }
    • package cat;
    • public class kata{
    • public static int doubleValue(int x) {
    • return x * 2;
    • return x + x;
    • }
    • }
Code
Diff
  • import java.lang.Math;
    interface Kata {
      static int doubleValue(int x) {
        boolean isNeg=x<0;
        if (isNeg){
          x= -x;
        }
        x=x+x;
        StringBuilder b= new StringBuilder();
        while (x!=0){
          b.append(x%2==0?"h":"a-");
          x=x/2;
        }
        b=b.reverse();
        String s=b.toString().replaceAll("-", "");
        int curr=s.length()-1;
        int acc=0;
        int i=0;
        while (i<s.length()){
          acc+= s.charAt(i)=='a'? (int) Math.pow(2,curr):0;
          i++;
          curr--;
        }
        return isNeg?-acc:acc;
      }
    }
    • import java.lang.Math;
    • interface Kata {
    • static int doubleValue(int x) {
    • boolean isNeg=x<0;
    • if (isNeg){
    • x= -x;
    • }
    • x=x+x;
    • StringBuilder b= new StringBuilder();
    • while (x!=0){
    • b.append(x%2==0?"0":"1");
    • b.append(x%2==0?"h":"a-");
    • x=x/2;
    • }
    • b=b.reverse();
    • String s=b.toString();
    • String s=b.toString().replaceAll("-", "");
    • int curr=s.length()-1;
    • int acc=0;
    • int i=0;
    • while (i<s.length()){
    • acc+= s.charAt(i)=='1'? (int) Math.pow(2,curr):0;
    • acc+= s.charAt(i)=='a'? (int) Math.pow(2,curr):0;
    • i++;
    • curr--;
    • }
    • return isNeg?-acc:acc;
    • }
    • }
Code
Diff
  • def is_even(x):
        return divmod(x,2)[1] == 0
    
    • def is_even(x):
    • return True if divmod(x,2)[1] == 0 else False
    • return divmod(x,2)[1] == 0
Loading more items...