Skip to main content
4 of 7
added 138 characters in body; added 60 characters in body
arrdem
  • 846
  • 5
  • 15

#Python - 114 113 153 192 184 characters from sys import * s="";c=a=argv[1] for f in a: o=c.find;p=f.lower if '@'<f<'\': \td=o(f)-o(p()) \tfor i in range(d):s+=")" \tc=(c[:o(p())]+c[o(f)+1:]) else:s+=("("+f) print s

Abuses python's indentation parser to use one space for a full tab, five for two tabs.

Edit 1 - saved an unneeded space in the range() function

Edit 2 - fixed to deal with improper parse grammars, unterminated tags.

Edit 3 - fixed a bug whereby "incorrect" parses could be generated by ambiguity in the tag tree. Implemented a stack-based strategy, rather than a counter.

Edit 4 - renamed s.find to o to prevent save the chars used to repeatedly call it. did the same for f.lower.

Edit 5 - added the space/tab hack, saving three chars.

arrdem
  • 846
  • 5
  • 15