Basic regex tasks. Write a function that takes in a numeric code of any length. The function should check if the code begins with 1, 2, or 3 and return `true` if so. Return `false` otherwise. 

You can assume the input will always be a number.

Difficulty: introductory

Starter code:

def validate_code(code):
	

Solutions:
def validate_code(code):
    return str(code).startswith(('1', '2', '3'))


def validate_code(code):
    return str(code)[0] in '123'

def validate_code(code):
    import re
    return bool(re.match(r"^[123]\d*$",str(code)))


def validate_code(code):
    import re
    return bool(re.match('[123]',str(code)))

def validate_code(code):
    return int(str(code)[0]) < 4

import re

def validate_code(code):
    return bool(re.match("^[1-3]",str(code)))

validate_code = lambda c: str(c)[0] in "123"

def validate_code(code):
    return True if str(code)[0] in set('123') else False

from re import match
from math import log10

def validate_code(code):
    # Without bothering with string conversion
    return 0 < code // 10**int(log10(code)) < 4
    
    # Title says regex so let's write one
    return bool(match("\A[1-3]", str(code)))

validate_code=lambda n:str(n).startswith(tuple('123'))

def validate_code(code):
    import re
    return True if re.match('^1|^2|^3', str(code)) is not None else False

import re
def validate_code(code):
  return bool(re.match("[123]{1}.*",str(code)))

def validate_code(code):
    return True if str(code)[0] in ("1", "2", "3") else False

import re
validate_code = lambda c: bool(re.search("^[1-3]", str(c)))

from math import ceil, log10

def validate_code(code):
    return first_digit(code) in (1, 2, 3)


def first_digit(num):
    num_of_digs = ceil(log10(num))
    amount_of_digs_to_remove = num_of_digs - 1
    return num // 10**(amount_of_digs_to_remove)  # removes digits starting from right

def validate_code(code):
    #your code here
    string = str(code)
    return True if string[0] in '123' else False

import re

def validate_code(code):
    return bool(re.match(r'^[1-3]',str(code)))

# easy non-regex solution would be the following
#
# def validate_code(code):
#     return list(str(code))[0] in list('123')


import re
def validate_code(code):
    if re.search(r'(\A1)|(\A2)|(\A3)', str(code)):
        return True
    return False

import re
def validate_code(code):
    #your code here
    return bool(re.match(r'[1-3]', str(code)))

def validate_code(code):
    return '1' <= str(code)[0] <= '3'

def validate_code(code):
    code = list(map(int, list(str(code))))
    return True if code[0] == 1 or code[0] == 2 or code[0] == 3 else False

def validate_code(code):
    code_str = str(code)
    if code_str[0] == '1' or code_str[0] == '2' or code_str[0] == '3':
        return True
    return False

def validate_code(code):
    code = str(code)
    print(code)
    if str(code)[0] in ['1','2','3']:
        return True
    else:
        return False

def validate_code(code):
    return str(code)[0] in '123'

    
#Основные задачи регулярных выражений. Напишите функцию, которая принимает числовой код
#любой длины. Функция должна проверить, начинается ли код с 1, 2 или 3, и вернуть true, если да. 
#В противном случае верните false.

#Вы можете предположить, что ввод всегда будет числом."""


def validate_code(code):
    return (str(code)[0]) <= '3'

def validate_code(code):
    import re
    
    if re.match(r'^[1-3]', str(code)) is not None:
        return True
    else:
        return False

def validate_code(code):
    wert = str(code);
    print(wert);
    
    if wert[0] == '1':
        return True;
    elif wert[0] == '2':
        return True;
    elif wert[0] == '3':
        return True;
    else:
        return False