HackerRank Language

  • + 0 comments

    Python 3 solution. I was lazy to format the string into a regex :-))

    s = 'COPY THE FULL STRING FROM THE TEXT HERE, like: C:CPP...'
    
    valid_langs = set(lang.strip() for lang in s.split(':'))
    
    n = int(input())
    for _ in range(n):
        api_id, lang = input().split(' ')
        if pow(10, 4) <= int(api_id) < pow(10, 5) and lang in valid_langs:
            print('VALID')
        else:
            print('INVALID')