Guest User

Untitled

a guest
Nov 24th, 2014
461
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from sys import argv
  2.  
  3. elements = ["h","he","li","be","b","c","n","o","f","ne","na","mg","al","si","p","s","cl","ar","k","ca","sc","ti","v","cr","mn","fe","co","ni","cu","zn","ga","ge","as","se","br","kr","rb","sr","y","zr","nb","mo","tc","ru","rh","pd","ag","cd","in","sn","sb","te","i","xe","cs","ba","la","ce","pr","nd","pm","sm","eu","gd","tb","dy","ho","er","tm","yb","lu","hf","ta","w","re","os","ir","pt","au","hg","tl","pb","bi","po","at","rn","fr","ra","ac","th","pa","u","np","pu","am","cm","bk","cf","es","fm","md","no","lr","rf","db","sg","bh","hs","mt","ds","rg","cn","uut","fl","uup","lv","uus","uuo"]
  4.  
  5. def isWriteable(w):
  6.     if len(w)==0:
  7.         return True
  8.     if w[:1] in elements:
  9.         if w[:2] in elements:
  10.             return isWriteable(w[1:]) or isWriteable(w[2:])
  11.         else:
  12.             return isWriteable(w[1:])
  13.     elif w[:2] in elements:
  14.         return isWriteable(w[2:])
  15.     return False   
  16.  
  17. mw=""
  18.  
  19. with open(argv[1],'r') as f:
  20.     for i in f:
  21.         cw=str(i)[:-1].lower()
  22.         if isWriteable(cw) and len(cw)>len(mw):
  23.             mw=cw
  24.  
  25. print mw
RAW Paste Data