Ad
Variables
Basic Language Features
Fundamentals
Conditional Statements
Control Flow
Loops
Arrays
Data Types
Code
Diff
  • def is_prime(num):
      newnum = num - 1
      while newnum > 1:
        if num % newnum == 0:
          return False
        newnum -= 1
        if newnum > 1:
          continue
        return True
    
    def get_primes(num):
      og, c = num, []
      while num > 0:
        if is_prime(num):
          c.append(num)
        num -= 1
      if og > 1:
        c.append(2)
      return sorted(c, reverse=False)
      
    
    • def get_primes(n):
    • nums = list(range(2, n+1))
    • primes = []
    • while len(nums) > 0:
    • prime = nums[0]
    • del nums[0]
    • primes.append(prime)
    • for i in range(len(nums)-1, -1, -1):
    • if nums[i] % prime == 0:
    • del nums[i]
    • return primes
    • def is_prime(num):
    • newnum = num - 1
    • while newnum > 1:
    • if num % newnum == 0:
    • return False
    • newnum -= 1
    • if newnum > 1:
    • continue
    • return True
    • def get_primes(num):
    • og, c = num, []
    • while num > 0:
    • if is_prime(num):
    • c.append(num)
    • num -= 1
    • if og > 1:
    • c.append(2)
    • return sorted(c, reverse=False)
Code
Diff
  • def high_and_low(str_in)
      str_in.split.minmax_by{|n|n.to_i}.reverse.join(' ')
    end
    • def high_and_low(str_in)
    • str_in.split.minmax_by{|n|-n.to_i}.join(' ')
    • str_in.split.minmax_by{|n|n.to_i}.reverse.join(' ')
    • end
Code
Diff
  • var returnhundred = () => 100;
    • const returnhundred = () => 100;
    • var returnhundred = () => 100;
Code
Diff
  • syntax error 
    • syntax error here again
    • syntax error
Fundamentals
Loops
Control Flow
Basic Language Features
Code
Diff
  • d=sorted
    • s=sorted
    • d=sorted
Fundamentals
Loops
Control Flow
Basic Language Features
Code
Diff
  • r=sorted
    • f=sorted
    • r=sorted
Code
Diff
  • reverse = lambda x: x[::-1] if isinstance(x, str) else int(str(x)[::-1])
    • reverse = lambda x: x[::-1] if type(x) is str else int(str(x)[::-1])
    • reverse = lambda x: x[::-1] if isinstance(x, str) else int(str(x)[::-1])
Fundamentals
Loops
Control Flow
Basic Language Features
Code
Diff
  • sort=sorted
    • sort_arr=sorted
    • sort=sorted
Arrays
Data Types
Strings
Numbers

In this kata you must create a function that accepts strings as an input. The goal is to return the biggest and smallest numbers in order of greatest to least in an array. The input may contain non-numeric characters, so watch out. If a number is given as input the program should return an empty array.

Ex. "12382hgsjas//6" --> [8, 1]

Ex. 12324334 --> []

Ex. ["gr", "0", 578898, "12", "shthj680000001gh"] --> [680000001, 12]

Happy coding, and good luck!

def small_big_num(infos):
    if isinstance(infos, int): return []
    elif isinstance(infos, str):
        infos = [int(i) for i in infos if i.isdigit()]
        return [max(infos), min(infos)]