Ad
Code
Diff
  • import java.util.Arrays;
    import java.util.Collections;
    
    public class Kata {
        public static int findMax(int[] my_array) {
            // Write a method that returns the largest integer in the list.
            // You can assume that the list has at least one element.
          
            // without using ready implementation
            return Arrays.stream(my_array)
                          .reduce(my_array[0], (acc, elem) -> acc > elem ? acc : elem);
        }
    }
    • import java.util.Arrays;
    • import java.util.Collections;
    • public class Kata {
    • public static int findMax(int[] my_array) {
    • // Write a method that returns the largest integer in the list.
    • // You can assume that the list has at least one element.
    • // without using ready implementation
    • return Arrays.stream(my_array)
    • .max()
    • .getAsInt();
    • .reduce(my_array[0], (acc, elem) -> acc > elem ? acc : elem);
    • }
    • }
Code
Diff
  • def add(x, o):
        return sum(int(d) for d in x if o == 0 or o%2 ^ int(d)%2 == 0)
    
    • # just squished your version a little more
    • add=lambda s,o:sum(filter(lambda n:o<1or~n+o&1,map(int,s)))
    • def add(x, o):
    • return sum(int(d) for d in x if o == 0 or o%2 ^ int(d)%2 == 0)