Uniq

Return only repeated lines from input stream sorted in lexicographical order.

IN

1
2
3
4
5
4
1

OUT

1
4

IN

qwer
asdf
zxcv
rewq
qwer
asdf

OUT

asdf
qwer
Login to submit solution


10 symbols pyth
Wed Sep 28 07:46:13 2016 Sait2000
j{.-JS.z{J
12 symbols bash
Mon May 26 14:32:12 2014 ledyba
sort|uniq -d
12 symbols pyth
Wed Sep 21 03:19:41 2016 Sait2000
VrS.z8IthNeN
14 symbols bash
Fri Feb 7 12:03:37 2014 maksim
sort | uniq -d
34 symbols perl
Mon Aug 25 04:50:46 2014 gabrielmad
#!/usr/bin/perl -p0a
$_=join'
',grep$a{$_}++,sort@F
35 symbols perl
Sat Jan 11 11:55:38 2014 bugov
#!/usr/bin/perl -p0a
$_=join'
',grep{$a{$_}++}sort@F
67 symbols ruby2.0
Sat Jul 5 14:37:41 2014 Nakilon
puts gets(p).split.group_by{|i|i}.select{|i,j|j[1]}.map{|i,|i}.sort
84 symbols haskell
Wed Mar 18 10:34:26 2015 YoshikuniJujo
import Data.List
main=interact$unlines.map head.filter((>1).length).group.sort.lines
117 symbols python2
Wed Jul 30 21:49:58 2014 vik
import sys
s=[q.strip() for q in sys.stdin]
l=list(set(s))
for i in l:s.remove(i)
s.sort()
print '\n'.join(s).strip()
130 symbols python3
Thu Feb 6 16:53:11 2014 maksim
import sys
s = [S.strip() for S in sys.stdin]
l = list(set(s))
for i in l: s.remove(i)
s.sort()
print('\n'.join(s).strip(),end='')
133 symbols python3
Fri Aug 8 23:12:51 2014 z423x5c6
import sys
a=[]
b=[]
for i in sys.stdin:
 i=i.strip('\n')
 if i in a:
  if i not in b:b+=[i]
 else:a+=[i]
print('\n'.join(sorted(b)))

View all solutions