Ad
Code
Diff
  • public class AgeSumDigits
    {
      public static boolean SumOfDigits(int[] ages) {   
      int m = ages[0];
      int s = ages[1];
      int p = ages[2];
      
      String mS = String.valueOf(m);
      String cS = String.valueOf(s) + String.valueOf(p);
      return mS.chars().map(c -> c - '0').sum() < cS.chars().map(c -> c - '0').sum();
      
      } 
    }
    • public class AgeSumDigits
    • {
    • public static boolean SumOfDigits(int[] ages) {
    • int m = ages[0];
    • int s = ages[1];
    • int p = ages[2];
    • // Coding with passion ;)
    • return (calcSum(m) < calcSum(s)+calcSum(p)) ? true : false;
    • }
    • static int calcSum(int age){
    • int sum = 0;
    • while(age>0){
    • sum += age % 10;
    • age /= 10;
    • }
    • return sum;
    • }
    • String mS = String.valueOf(m);
    • String cS = String.valueOf(s) + String.valueOf(p);
    • return mS.chars().map(c -> c - '0').sum() < cS.chars().map(c -> c - '0').sum();
    • }
    • }
Code
Diff
  • class Kata{
      
      public static String verifySum(String nameOne, String nameTwo) {
            if (nameOne == null || nameTwo == null) {
                return "NULL";
            }
    
            
            return nameOne.chars().sum() == nameTwo.chars().sum() ? "TRUE" : "FALSE";
        }
    }
    • class Kata{
    • public static String verifySum(String nameOne, String nameTwo) {
    • int[] sumOfNames = new int[]{0, 0};
    • if (nameOne == null || nameTwo == null) {
    • return "NULL";
    • }
    • for (int i = 0; i < nameOne.length(); i++){
    • sumOfNames[0] += nameOne.charAt(i);
    • }
    • for (int i = 0; i < nameTwo.length(); i++){
    • sumOfNames[1] += nameTwo.charAt(i);
    • }
    • return sumOfNames[0] == sumOfNames[1] ? "TRUE" : "FALSE";
    • return nameOne.chars().sum() == nameTwo.chars().sum() ? "TRUE" : "FALSE";
    • }
    • }