Skip to content

Instantly share code, notes, and snippets.

@llimllib
Forked from ntlk/uniq.py
Created October 12, 2013 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llimllib/6954867 to your computer and use it in GitHub Desktop.
Save llimllib/6954867 to your computer and use it in GitHub Desktop.
The five boxing wizards jump quickly.
Pack my box with five dozen liquor jugs.
Pack my box with five dozen liquor jugs.
Pack my box with five dozen liquor jugs.
Pack my box with five dozen liquor jugs.
A quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
Pack my red box with five dozen quality jugs.
Pack my red box with five dozen quality jugs.
The quick brown fox jumped over the lazy dogs.
Who packed five dozen old quart jugs in my box?
Who packed five dozen old quart jugs in my box?
Who packed five dozen old quart jugs in my box?
My girl wove six dozen plaid jackets before she quit.
Few black taxis drive up major roads on quiet hazy nights.
A quick movement of the enemy will jeopardize six gunboats.
Who packed five dozen old quart jugs in my box?
import sys
lines = sys.stdin.readlines()
last_line = None
for line in lines:
if line != last_line:
sys.stdout.write(line)
last_line = line
from itertools import tee, izip
def pairs(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = tee(iterable)
next(b, None)
return izip(a, b)
import sys
lines = sys.stdin.readlines()
sys.stdout.write(lines[0])
for a,b in pairs(lines):
if a != b:
sys.stdout.write(b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment