Skip to main content
declaration is not counted
Source Link
gcq
  • 251
  • 2
  • 5

Python 104104 83

def f(s): , o=[], o=[];c=""c=""): for i in s: try:int(i);c+=i except:o+=[c];c="" return [i for i in o+[c] if i] 

@Abhijit answer is far clever, this is just a "minified" version of what i had in mind.

assert f("abc123def456") == ["123", "456"] assert f("aitew034snk582:3c") == ["034", "582", "3"] assert f("as5493tax54\\[email protected]") == ["5493", "54", "430", "52", "9"] assert f("sasprs]tore\"re\\forz") == [] 

This yields no output, so the code is working, if ran one by one, as some variables are defined at the declaration.

Python 104

def f(s):  o=[];c="" for i in s: try:int(i);c+=i except:o+=[c];c="" return [i for i in o+[c] if i] 

@Abhijit answer is far clever, this is just a "minified" version of what i had in mind.

assert f("abc123def456") == ["123", "456"] assert f("aitew034snk582:3c") == ["034", "582", "3"] assert f("as5493tax54\\[email protected]") == ["5493", "54", "430", "52", "9"] assert f("sasprs]tore\"re\\forz") == [] 

This yields no output, so the code is working.

Python 104 83

def f(s, o=[], c=""): for i in s: try:int(i);c+=i except:o+=[c];c="" return [i for i in o+[c] if i] 

@Abhijit answer is far clever, this is just a "minified" version of what i had in mind.

assert f("abc123def456") == ["123", "456"] assert f("aitew034snk582:3c") == ["034", "582", "3"] assert f("as5493tax54\\[email protected]") == ["5493", "54", "430", "52", "9"] assert f("sasprs]tore\"re\\forz") == [] 

This yields no output, so the code is working, if ran one by one, as some variables are defined at the declaration.

Source Link
gcq
  • 251
  • 2
  • 5

Python 104

def f(s): o=[];c="" for i in s: try:int(i);c+=i except:o+=[c];c="" return [i for i in o+[c] if i] 

@Abhijit answer is far clever, this is just a "minified" version of what i had in mind.

assert f("abc123def456") == ["123", "456"] assert f("aitew034snk582:3c") == ["034", "582", "3"] assert f("as5493tax54\\[email protected]") == ["5493", "54", "430", "52", "9"] assert f("sasprs]tore\"re\\forz") == [] 

This yields no output, so the code is working.