Ad

Empty strings and None are both falsy.

Code
Diff
  • def verifySum(s1, s2):
        if not s1 or not s2:
            return None
        else:
            return len(s1) == len(s2)
    • def verifySum(s1, s2):
    • if s1 == None or s2 == None or len(s1) == 0 or len(s2) == 0:
    • if not s1 or not s2:
    • return None
    • else:
    • return len(s1) == len(s2)

Simplified code.

Code
Diff
  • class Kata{
      
      public static String verifySum(String nameOne, String nameTwo) {
            if (nameOne == null || nameTwo == null) return "NULL";
            else return nameOne.chars().sum() == nameTwo.chars().sum() ? "TRUE" : "FALSE";
        }
    }
    • 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";
    • if (nameOne == null || nameTwo == null) return "NULL";
    • else return nameOne.chars().sum() == nameTwo.chars().sum() ? "TRUE" : "FALSE";
    • }
    • }