Ad
Code
Diff
  • using System;
    
    class Kata
    {
      private static string LANGUAGE = "C#";
      
      public static void Main()
      {
        string[] hello = {"H","e","l","l","o"};
        
        Array.ForEach(hello, s => Console.Write(s));
        
        Console.WriteLine(", " + LANGUAGE + "!" );
        
      }
      
      
    }
    • using System;
    • class Kata
    • {
    • private static string LANGUAGE = "C#";
    • public static void Main()
    • {
    • string[] hello = {"H","e","l","l","o"};
    • string result = "";
    • foreach(string s in hello){
    • result = result + s;
    • }
    • Array.ForEach(hello, s => Console.Write(s));
    • Console.WriteLine(result + ", " + LANGUAGE + "!" );
    • Console.WriteLine(", " + LANGUAGE + "!" );
    • }
    • }
Code
Diff
  • using System;
    
    class Kata
    {
      private static string LANGUAGE = "C#";
      
      public static void Main()
      {
        string[] hello = {"H","e","l","l","o"};
        string result = "";
        
        foreach(string s in hello){
          result = result + s;
        }
        
        Console.WriteLine(result + ", " + LANGUAGE + "!" );
        
      }
      
      
    }
    • using System;
    • class Kata
    • {
    • private static string LANGUAGE = "C#";
    • public static void Main()
    • {
    • string[] hello = {"H","e","l","l","o"};
    • string result = "";
    • for(int i = 0 ; i < hello.Length; i ++)
    • {
    • result = result + hello[i];
    • }
    • foreach(string s in hello){
    • result = result + s;
    • }
    • Console.WriteLine(result + ", " + LANGUAGE + "!" );
    • }
    • }

You didn't need to use StringBuilder for it but yea Java 11 made it really simple.

Code
Diff
  • public class Kata {		
    	public static String multiply(String input,int times){
        String str = "";
        for(int i = 0; i < times; i++) {
          str += input;
        }
        return str;
    	}
    }
    • public class Kata {
    • public static String multiply(String input,int times){
    • StringBuilder str = new StringBuilder();
    • String str = "";
    • for(int i = 0; i < times; i++) {
    • str.append(input);
    • str += input;
    • }
    • return str.toString();
    • return str;
    • }
    • }
Code
Diff
  • public class Kumite{
      public static String switchout(String in, String replace, String instead){
        return in.replaceAll(replace, instead);}}
    • switchout = str.replace
    • public class Kumite{
    • public static String switchout(String in, String replace, String instead){
    • return in.replaceAll(replace, instead);}}
Code
Diff
  • class fizzbuzz {
      public static String ts(int num){
        if(num % 3 == 0 && num % 5 != 0)
          return "Fizz";
        if(num % 3 != 0 && num % 5 == 0)
          return "Buzz";
        if(num % 3 == 0 && num % 5 == 0)
          return "FizzBuzz";
        return String.valueOf(num);
      }
    }
    • def fizzBuzz(num):
    • return 'Fizz' *(not num % 3) + 'Buzz' *(not num % 5) or str(num)
    • class fizzbuzz {
    • public static String ts(int num){
    • if(num % 3 == 0 && num % 5 != 0)
    • return "Fizz";
    • if(num % 3 != 0 && num % 5 == 0)
    • return "Buzz";
    • if(num % 3 == 0 && num % 5 == 0)
    • return "FizzBuzz";
    • return String.valueOf(num);
    • }
    • }
Code
Diff
  • def verifySum(s1, s2):
        if s1 == None or s2 == None or len(s1) == 0 or len(s2) == 0:
            return None
        else:
            return len(s1) == len(s2)
    • 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";
    • }
    • }
    • def verifySum(s1, s2):
    • if s1 == None or s2 == None or len(s1) == 0 or len(s2) == 0:
    • return None
    • else:
    • return len(s1) == len(s2)

You get a sentence in a string. Convert every word that has 4 letters or is longer to the word "yeet". If the sentence is longer than 4, it should replace the word with "yeet" but with as many "e"s as there are other letters except the ones on the ends.
It should return the sentence with the words that were changed and the words that weren't changed at the same place as they were before. It should also keep the punctations.
Have fun yeeting words

public class yeet {

  public static String yeetWords(String Words){
	    String[] s = Words.split(" ");
	    String end = "";    
      String r = "";
	    if(s[s.length-1].endsWith(".") || s[s.length-1].endsWith("!") || s[s.length-1].endsWith("?")){
	      end = s[s.length-1].substring(s[s.length-1].length()-1);
	    }
      for(int i = 0; i<s.length; i++){
        String st = s[i];
        String rs = "";
        int le = st.length()-1;
        if(st.length() >= 4){
          if(st.endsWith(end)){
            le = le-1;
          }
          rs = "y" + st.substring(1,1);
          for(int e = 1; e<le; e++){
            rs = rs + "e";
          }
          rs = rs + "t";
        } else {
          rs = st;
        }
        r = r + rs + " ";
      }
	    return r.trim() + end;
  }

}

wenn der übergebenen string mit a anfängt, gebe true zurück

public class test{
  public static Boolean anfanga(String s){
    if(s.startsWith("a")){
      return true;
    } else {
      return false;
    }
  }
}