Move History

Fork Selected
  • Code
    clean=lambda s:__import__("re").sub("[0-9]","",s)
    Test Cases
    import codewars_test as test
    from solution import clean
    import random as rand
    import string as s
    
    
    @test.describe("Test cases")
    def test_group():
        @test.it("Fixed test cases")
        def fixed():
            test.assert_equals(clean("2 plus 2 is 4"), " plus  is ")
            test.assert_equals(clean("0123456789"), "")
            test.assert_equals(clean("3h9fk37cf"), "hfkcf")
        
        @test.it("Random test cases")
        def random():
            def sol(str):
                return "".join("" if x.isdigit() else x for x in str)
            for i in range(20):
                bla = s.ascii_letters + s.digits
                bleh = [x for x in bla]
                rand.shuffle(bleh)
                bleh = "".join(bleh)
                print("asserting for string " + bleh)
                test.assert_equals(clean(bleh), sol(bleh))
  • Code
    • clean = lambda s: ''.join(x for x in s if not x.isdigit())
    • clean=lambda s:__import__("re").sub("[0-9]","",s)