Skip to content

Instantly share code, notes, and snippets.

@mutaku
Created August 9, 2012 17:03
Show Gist options
  • Save mutaku/3305924 to your computer and use it in GitHub Desktop.
Save mutaku/3305924 to your computer and use it in GitHub Desktop.
make sure all sublists are only one element - iterable version
def checkpossibility(unsatlist):
try:
for x in sorted(unsatlist, key=len, reverse=True):
if len(x) > 1:
raise Exception
else:
pass
return True
except:
return False
@esteigler
Copy link

def checkpossibility(unsatlist):
for x in sorted(unsatlist, key=len, reverse=True):
if len(x) > 1:
return False
else:
pass
return True

@mutaku
Copy link
Author

mutaku commented Aug 14, 2012

@esteigler : yeah, I had settled on that here -> https://gist.github.com/3305832

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment