Ad
Code
Diff
  • using System;
    
    public class Kumite {
      public static bool IsThree(int number) {
        var digitToSearch = 3;
        var amountOfDigits = (int)Math.Log10(number); 
        
        for (int i = 0; i <= amountOfDigits; i++)
        {
            var divisor = (int)Math.Pow(10, i);
            var truncate = number / divisor;
            var digit = truncate % 10;
            if (digit == digitToSearch)
            {
                return true;
            }
        }
        return false;
      }
    }
    • using System;
    • public class Kumite {
    • public static bool IsThree(int x) =>
    • x.ToString().Contains('3');
    • public static bool IsThree(int number) {
    • var digitToSearch = 3;
    • var amountOfDigits = (int)Math.Log10(number);
    • for (int i = 0; i <= amountOfDigits; i++)
    • {
    • var divisor = (int)Math.Pow(10, i);
    • var truncate = number / divisor;
    • var digit = truncate % 10;
    • if (digit == digitToSearch)
    • {
    • return true;
    • }
    • }
    • return false;
    • }
    • }