remove dupes from array
given a random string that contains a ruby-esque array, make sure that there are no duplicate elements
Start file
[11, 2, 3,5 , 1,1, 22, 4]
End file
[1, 2, 3, 4, 5, 11, 22]
View Diff
1c1 < [11, 2, 3,5 , 1,1, 22, 4] --- > [1, 2, 3, 4, 5, 11, 22]
Solutions
The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!
Check out these helpful resources to improve your Vim skills... Game on.
#145 Reed Riley / @ReedRile - Score: 28 - 08/12/12 @ 15:07
llct], 2, 3, 4, 5, 11, 22<Esc>ZZ
0 comments
#146 Kiss György / @Walkman_ - Score: 29 - 01/07/12 @ 20:51
lx5f,x;;dt<0xc4><0xb7>dt]4Bplli <Esc>llxxZZ
0 comments
#147 Omer Rauchwerger / @rauchy - Score: 29 - 01/29/12 @ 06:58
lxwewewexlr4wer5wei 1<Esc>wel3xZZ
0 comments
#148 James Chiang / @jamesjn5 - Score: 29 - 03/31/12 @ 20:53
lxf5i 4, <Esc>f dt,<Esc>f,xf,;ct]<Esc>:x<CR>
0 comments
#149 Nathan Manousos / @trafnar - Score: 29 - 04/01/12 @ 22:36
ddi[1, 2, 3, 4, 5, 11, 22]<Esc>ZZ
0 comments
#150 Rod Knowlton / @codelahoma - Score: 29 - 04/24/12 @ 06:13
wa, 2, 3, 4, 5, 11, 22<Esc>ldt]ZZ
0 comments
#151 Golf Sinteppadon / @MiniGolf2000 - Score: 29 - 04/27/12 @ 15:33
lxf5<C-X>i <Right><Del><Del><Right><Right><Del>5<Right> 1<Esc>ww<Right><Right>d$a]<Esc>ZZ
0 comments
#152 Alan / @aluong91 - Score: 29 - 07/17/12 @ 01:19
lxf5i 4, <Esc>llct2, 11, <Esc>f,dt]ZZ
0 comments
#153 robin hafen / @robin_hafen - Score: 29 - 09/28/12 @ 07:18
lxf5i 5<BS>4, <Esc>lldt]i, 11, 22<Esc>ZZ
0 comments
#154 Tom von Clef / @tomvonclef - Score: 30 - 12/16/11 @ 11:27
<Right>xwewewex<Right>r4wer5wei 1<Esc>we<Right>xxxZZ
0 comments
#155 Raphael Randschau / @nicolai86 - Score: 30 - 12/25/11 @ 06:28
ddi[1, 2, 3, 4, 5, 11, 22]<Esc>:x<CR>
0 comments
#156 Matthew Cupps / @matthewcupps - Score: 31 - 12/20/11 @ 13:48
ddi[1, 2, 3, 4, 5, 11, 22]<Esc>:wq<CR>
0 comments
#157 Jason Felice / @eraserhd - Score: 31 - 12/20/11 @ 17:00
R[1, 2, 3, 4, 5, 11, 22]<Esc>lD:wq<CR>
0 comments
#158 Sergi Sorribas / @lerovitch - Score: 31 - 12/22/11 @ 04:19
:s/\D/,\r/g<CR>:sor nu<CR>9J^xr[$r]ZZ
0 comments
#159 Tara Bass / @tara_bass - Score: 31 - 12/22/11 @ 22:10
:s/\D/,\r/g<CR>:sor nu<CR>9J0xr[$r]ZZ
0 comments
#160 ümit kablan / @udslk - Score: 31 - 03/10/12 @ 23:53
lxf3la 4, <Right><Esc>dwuldwf1lxf]dF,:wq<CR>
0 comments
#161 Jomo / @yoyoyojomo - Score: 31 - 03/14/12 @ 10:47
:s/\D/,\r/g<CR>:sor nu<CR>9J$r]^xr[ZZ
0 comments
#162 arye lukashevski / @aryelukashevski - Score: 32 - 01/14/12 @ 09:59
o[1, 2, 3, 4, 5, 11, 22]<Esc>kdd:wq<CR>
0 comments
#163 Mike Rayner / @mikesfake - Score: 32 - 01/23/12 @ 10:57
ddi[1, 2, 3, 4, 5, 11, 22]<Esc>:wq!<CR>
0 comments
#164 Chris Penkett / @chrispenkett - Score: 33 - 04/03/12 @ 09:52
:s/\D/,\r/g<CR>:sor nu<CR>9J^2s[<Esc>A<BS>]<Esc>ZZ
0 comments
#165 vansan / @VinceVansan - Score: 33 - 08/22/12 @ 03:26
:s/\D/, \r/g|sor nu<CR>9J^2s[<Esc>$xr]ZZ
0 comments
#166 krusty_ar / @krusty_ar - Score: 34 - 02/20/12 @ 09:01
<Right>x/5<CR>i4<Left> <Right>, <Right><Esc><Right>d/]<CR>a<Left>, 11, 22<Esc>:wq<CR>
0 comments
#167 Viktor Jackson / @AntiStalinista - Score: 34 - 05/05/12 @ 00:02
:s/\D/,<C-V><CR>/g<CR>:sort un<CR>d2di[<Esc>7J$r]ZZ
0 comments
#168 Mislav Marohnić / @mislav - Score: 35 - 12/05/11 @ 14:08
:s/\v\D+/,\r/g<CR>:sor nu<CR>2Di[<Esc>7J$r]ZZ
0 comments
#169 captain_morgan / @captain_morgan - Score: 45 - 11/28/11 @ 13:26
lx6wi 4, `<BS><Esc>llc5wi, <BS><BS><BS>, 11<Esc>w<Esc><Esc>2Edt]JJ<Left>v<Left><Left>dZZ
0 comments
#170 Dan Masquelier / @danmasq - Score: 45 - 12/08/11 @ 11:53
x/ <CR>2x$r,_qvf,a<CR><Esc>q6@vVgg:sort un<CR>i[<Esc>VGJ$r]ZZ
0 comments
#171 Noel Alejandro / @noelrock333 - Score: 46 - 06/25/12 @ 13:46
lx5l2la r4<Esc>ui <Esc>lr42lxhx2lr52li 1<Esc>7lxxhx<Esc><Esc>:w<CR><C-W>q
0 comments
#172 Markus / @markus1189 - Score: 51 - 04/19/12 @ 08:36
:rubydo $_ = eval("#{$_}.sort.uniq").to<BS><BS>inspect<CR>ZZ
0 comments
#173 Thijs Brobbel / @tiesmaster - Score: 52 - 12/03/11 @ 04:57
x:s/,/<C-V><CR>/g<CR>$x:%s/ //g<CR>:%!sort -un<CR>i[<Esc>A<Del>, <Esc>.....A]<Esc>ZZ
@tiesmaster: Just read the rules of VimGolf, rule 6: "No plugins, macros, etc, are allowed - level playing field". Using unix tool sort isn't the idea then, I suppose.
@gumnos: Just so you know, Vim has an internal sort command that would do the same for you and save 2 characters ("%sort un") :)
2 comments
#174 Robert / @NiedruRoberts - Score: 53 - 12/15/11 @ 01:29
ld2w$bbbPf4hhdt]F5Pa, <Esc>llxxwd2wd2wF2puPwwwwldwi <Esc>:wq<CR>
0 comments
#175 Petrik de Heus / @four54 - Score: 63 - 01/14/12 @ 14:06
:%s/\D/ \r/g<CR><Esc>:sor un<CR><Esc>:<Esc><Esc>dddd<Esc><Esc>:%s/ /,/g<CR>J<Esc>ggJJJJJJ<Esc>$r]<Esc>0i[<Esc>ZZ
0 comments
#176 Joe Van Dyk / @joevandyk - Score: 66 - 01/14/12 @ 11:42
lv<Esc><Esc>whhi1, 1, 2, 3, 5, <BS><BS><BS><BS><BS>, 4, 5, 11, 22l<BS>DA<BS><BS><Esc>lDA]<Esc>0wlhxxx:w<CR>ZZ
0 comments
#177 Timothy Hahn / @timyhahn - Score: 66 - 04/23/12 @ 10:33
lx<Esc>/5i,<BS><BS><BS><BS>/5<CR>i, 4,<BS><BS><BS><BS>4,<BS><BS> 4, <Esc>/,<CR>la<BS><BS><BS><BS> <BS>m<BS>, <Right><Right><BS><Right><Right><Right><Right><Right><Right><Right><Right><BS><BS><BS><Esc>:wq<CR>
0 comments
#178 Poojalakshmi / @spoojalakshmi - Score: 84 - 03/23/12 @ 07:49
<Left><Esc>i<Left><BS><BS><BS><BS><BS><BS><BS><Esc>ii<BS><BS><BS><BS><BS><Right><Right>,<Del><Del><Right><Right><Right><Right><Right><Right>4,<Right><Right><Right><Right><Right><Right><Del><Right><Right><Right><Right><Right><Del><Del><Del><Left><Left><Left><Left><Left><Left><Left><Left><Left><Right><BS><BS> <BS><Right><Right><Left><Left><Left> <Left><Left><Left> <Left><Left><Left><Left><Left><Left><Left><Esc><Esc>:wq<CR>
0 comments
#179 hnws / @hnws - Score: 108 - 12/13/11 @ 10:08
:%s/ //<CR>:<Up>g<CR><Up>:<Up><BS><BS><BS><BS><BS>/,/\r/g<CR>lxggx:<Up><Up><Up><Up><C-C>v<Down><Down><Down><Down><Down><Down><Down><Down><Down><Down>:~sor<BS><BS><BS><BS>!sort -n<CR>dd:<Up><Up><Up><Left><Left><Right><Left><Left><Left><Left><BS>\n<Right><Right><Right><BS><BS>m<BS>,\ <CR>i[<Esc>$xxa]<Esc>:wq<CR>
0 comments
#180 ZOMG / @monkeybot42 - Score: 114 - 09/29/12 @ 15:44
:%s/,/<C-V><CR>/g<CR>:%s/\[ //g<CR>:<Up><Left><Left><Left><Left><Left><BS><CR>:<Up><Left><Left><Left><Left><Left>[<Right><Left>\<Right><Right>]<Left><Left>\]<CR>:%!sort<CR>:<Up><C-C>:<Up><Up><Down><CR>jkj:sort<CR>:sort nu<CR>i[<Esc>uVGJ:%s/ /, /g<CR>0i[<Esc>A]<Esc>:wqa<CR>
0 comments
#181 Jasmin Rahimic / @jasmin_rahimic - Score: 170 - 12/06/11 @ 16:47
<Down><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Esc><Esc><Esc>lx6<Esc><Esc><Esc><Esc><Esc><Esc><Esc><Esc><Esc><Esc><Esc><Esc><Esc><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><Esc>lx6wi 4<Esc>llc5w,ll<BS><BS><Esc>llc5w<Esc>uuuuuuuuu<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><BS><BS><BS>lx6wi 4, <Esc>llc5w, 11<Esc>2Edt]ZZ
0 comments
VimGolf