Reformat some Python
Fix some very bizarrely laid-out code.
Start file
def fed(j):
n = sum([1000000000,
200000000,
30000000,
4000000,
500000,
60000,
7000,
800,
90,
j])
print('abc'+str(n)+'def')
End file
def fed(j):
n = 1234567890 + j
print('abc%ddef' % n)
View Diff
2,12c2,3
< n = sum([1000000000,
< 200000000,
< 30000000,
< 4000000,
< 500000,
< 60000,
< 7000,
< 800,
< 90,
< j])
< print('abc'+str(n)+'def')
---
> n = 1234567890 + j
> print('abc%ddef' % n)
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.
#131 Lasse Immonen / @turtleman10 - Score: 55 - 12/29/10 @ 06:27
<fd-35>3G9ddeeelveeeeedi%d<Esc>eei % n<Esc>kvbbbda1234567890 + j<Esc>ZZ
0 comments
#132 manlon / @manlon - Score: 56 - 12/29/10 @ 10:12
<fd-35>/s<CR>DA1234567890 + j<Esc>jVjjjjjjjjd2f'df'i%d<Esc>f)i % n<Esc>:wq<CR>
0 comments
#133 Esteban Ordano / @eordano - Score: 57 - 04/06/11 @ 21:02
/s<CR><Esc>d/1<CR>q1ld/ \d<CR>xq7@1JhR + j<Esc>lx/c<CR><Esc>Rc%ddef' % n)<Esc>ld$:wq<CR>
0 comments
#134 Abhishek Mukherjee / @abhishekmukherg - Score: 59 - 12/29/10 @ 08:32
<fd-35>/s<CR>df[lqqDJxlq@q@@@@@@@@@@@@lC +<Esc>JllDjF'cf'%d<Esc>f'a % n<Esc>ZZ
0 comments
#135 Bjørn Einar Bjartnes / @bjartnes - Score: 59 - 01/27/12 @ 04:35
jfsdwxxqalDJxq8@ai0 + <Esc>llDjdbdbdbhxxxhxxi%f<BS>d<Esc>llllli % n<Esc>ZZ
0 comments
#136 lionel young / @lionelyoung - Score: 60 - 12/28/10 @ 23:05
<fd-35>:%s/0//g<CR>2gg10J:s/, //g<CR>2wdf[f]d$i0 + <Esc>jF'cf'%d<Esc>$i % n<Esc>ZZ
0 comments
#137 Andrey A. Ugolnik / @andreyugolnik - Score: 60 - 01/19/11 @ 10:51
jdGon = 1234567890 + j<CR> print('abc%ddef' % n)<Esc>Vk<I <Esc>ZZ
0 comments
#138 Sid Kasivajhula / @CountVajhula - Score: 62 - 12/28/10 @ 23:39
<fd-35>jfsdf[lqaDJxlDJxlq@a@a@aJhxa+ <Esc>llD/;<BS>'<CR>ncf'%d<Esc>na % n<Esc>:wq<CR>
0 comments
#139 Michael Lustfield / @Profarius - Score: 63 - 12/28/10 @ 22:25
<fd-35><Down>20ddo n = 1234567890 + j<CR> print('abc%ddef' % n)<Esc>:x<CR>
0 comments
#140 Paul Tarjan / @ptarjan - Score: 63 - 12/29/10 @ 03:48
<fd-35>VGdidef fed(j):<CR><Tab>n = 1234567890 + j<CR>print('abc%ddef' % n)<Esc>ZZ
0 comments
#141 Jan B. / @bracki - Score: 64 - 12/29/10 @ 01:13
<fd-35>GddggpjdGf+xdw5x<Left>cw%d<Esc>f'i<Right> % n<Esc>O<Esc>i<Tab>n = 1234567890 + j<Esc>:x<CR>
0 comments
#142 Geoffrey Bachelet / @ubermuda - Score: 65 - 12/29/10 @ 00:57
<fd-35><Down>V9<Down>J:%s/00\+, //g<CR>fsdf[ws +<Esc>w<Right>d$<Esc><Down>F'cf'%d<Esc>wa % n<Esc>:wq<CR>
0 comments
#143 Arania Jain / @AraniaJain - Score: 65 - 12/29/10 @ 01:30
<Down>dddddddddddddddddddddd<Insert><End><NL><Home>I<BS><0xce><0xd4><BS><Up><Down><Up><End><Del><Del><Esc>:x<NL>
0 comments
#144 Alexey Komissarouk / @alexeymk - Score: 65 - 12/29/10 @ 05:26
<fd-35>/s<CR>R1234567890 + j<Del><Del><Esc><Down>:d9<CR>/c<CR>a%ddef<Right> % n(<Esc>i)<Esc><Right>D<Esc>:wq<CR>
0 comments
#145 smokey42 / @smokey42 - Score: 65 - 12/29/10 @ 06:41
<fd-35>on = 123456789<fc-04><PageUp>0 +j<BS> j<Esc><CR>d10d<fd-5e>f'nf'df'i%d<End><Left> % n<Esc>ZZ
0 comments
#146 Solomon White / @rubysolo - Score: 68 - 12/29/10 @ 09:39
<fd-35>jjVjjjjjjj20<:%s/0*,\n//g<CR>ell2dwElC0 + j<Esc>jbbbb5cw%d<Esc>Ei %n<BS> n<Esc>ZZ
0 comments
#147 Thanassis Tsiodras / @ttsiodras - Score: 69 - 01/03/11 @ 10:20
:%s,0,,g<CR>:2<CR>JJJJJJJJJ:.,.s/, //g<CR>fs5xf9a0 + <Esc>llDjF'8xR%d<Esc>f'a % n<Esc>:wq<CR>
0 comments
#148 Rob Howard / @damncabbage - Score: 72 - 12/29/10 @ 03:11
/1<CR>qald$Jxq7@aJ<Left>r a+<Esc>:s/[sum()\[\]]*//g<CR>2/'<CR>dtdi%d<Esc>$i & <BS><BS>% n<Esc>:wq<CR>
0 comments
#149 Fraxtil / @Fraxtil - Score: 73 - 12/28/10 @ 23:30
<fd-35>:%s/0*,\n *//g<CR>:%s/s.*\[//g<CR>:2s/j.*/0 + j/<CR>:%s/'+.*+'/%d/<CR>/)<CR>i % n<Esc>:x<CR>
0 comments
#150 Dhruva Sagar / @dhruvasagar - Score: 73 - 12/29/10 @ 00:30
<fd-35>:%s/0*,\n *//|%s/s.*\[//|2s/k<BS>j.*/0 + j/|%s/'+.*+'/%d/<CR><End>i % n<Esc>:wq<CR>
0 comments
#151 Jonathan Pui / @jpui - Score: 74 - 12/29/10 @ 00:11
<fd-35>:%s/0\+,\n\s+//<BS><BS><BS>\+//<CR>fsdf[fji0 + <Esc>lld$jdF'df'a<Esc>i%d<Esc>f'a % n<Esc>:wq<CR>
0 comments
#152 Chris Flynn / @flynnguy - Score: 74 - 12/29/10 @ 07:55
<fd-35>jJJJJJJJJ:s/0\+, //g<CR><fd-5e>ww<fd-5e>5x$DJa+ <Esc>llDj:s/'+str(n)+'/%d/<CR>$i % n<Esc>:wq<CR>
0 comments
#153 Sushant / @sushftw - Score: 75 - 12/29/10 @ 04:51
<fd-35>/s<CR>C1234567890 + j<Esc><Down>d8<Down><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>C%ddef' % n)<Esc>ZZ
0 comments
#154 Ben Dowling / @coderholic - Score: 83 - 12/31/10 @ 09:13
:%s/0*,\n *//g<CR>4ld5l<End><Del><Del>i0 + <Down><BS><BS><BS><BS><BS><BS><BS>%d<Del><Del><Del><End><Left> % n<Esc>:x<CR>
0 comments
#155 Gordy F / @gordyf - Score: 85 - 12/28/10 @ 22:48
<fd-35>/s<CR>C12354<BS><BS>4567890 + j<Esc><Down>d8<Down><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>C%ddef' % n)<Esc>:wq<CR>
0 comments
#156 Guillaume Bonnoron / @gbonnoron - Score: 90 - 12/31/10 @ 03:42
j10ccn = 1234567890+j<BS><BS> + j<Esc>^i<BS><Tab><BS> <Esc>:s<BS>%s/'+str\(n<BS><BS><BS>(n)+'/%d/<CR>$i % n<Esc>ZZ
0 comments
#157 Charles Maresh / @CMaresh - Score: 104 - 12/29/10 @ 06:58
<fd-35>:%s/0<BS>0{\<BS><BS>\{0<BS>2,\}//g<BS><CR>:%s/,<BS>,\n//<CR>V:s/ \{2,\}//g<CR>>>.fs<C-V>f[x$xxi + <Esc>jf'<C-V>F'c%d<Esc>$i % n<Esc>:wq<CR>
0 comments
#158 Christian Stefanescu / @0_chris - Score: 106 - 12/28/10 @ 22:29
<fd-35><fd-5e><Down><fd-5e>10dd<Up><End><CR>I<CR><Up>n = 1234567890 <kPlus> j<Esc><fd-5e><Down><Left><Left><Left><Left><Left><Left><Left><fd-5e>5dwi%d<Right><Right><Right><Right> % n<Esc>:wq<CR>
0 comments
#159 theshadowhost / @theshadowhost - Score: 106 - 12/29/10 @ 05:32
<fd-35>zojwwwv)khc1<Esc>qayplpuqqaycpuyypuvypqhlDvyp<C-A>qavyp<C-A>q5@a@@@@hhxr8li9<Esc>A + j<Esc>jbbbbveeeelllc%d<Esc>f' a<Esc><Esc>a % n<Esc>:x<CR>
0 comments
#160 nat / @natblue55 - Score: 108 - 01/01/11 @ 16:55
<Down>10J:s/,/+/g<CR>wwdw.vfj<Left><Left><Left>xra<C-C><C-C>r_<Right><Left>r+<Left>a<C-R>=<C-R>*<CR> <Esc>A<BS><BS><Esc><Down>r%bb<Left><Left><Left><Left><Left><Left><Left><Right><Right>.i<C-C><C-C>i<C-C><C-C><Right><Right><Right>v<Right><Right><Right><Right><Right><Right><Right><Right>x<Right><Right><Right>a $<BS>% n<Esc><Left><Left><Left><Left><Left><Left><Left><Left>ad<Esc>:wq<CR>
0 comments
#161 Benjaminister / @Benjaminister - Score: 110 - 12/29/10 @ 00:10
<fd-35>:%s/\(\d\)0*,\n\s*/\1<CR>:s/s\D*\(\d*\)j.*/\10 + j<CR>j:s/'+.*'def'/<Left><Left><BS><BS><BS><BS><Right>)<Right><Right>%ddef' % n<CR>$a)<Esc>ZZ
0 comments
#162 Andy Chong / @andycjw - Score: 112 - 12/29/10 @ 19:34
jlllllllli1234567890 + j<Esc>lvjjjjjjjjjlllduvjjjjjjjjjjkldljhhhhhhhvlllllllll%llllllllllllllxi%d<Esc>)hhli %n<Esc> hi <Esc>:wq<CR>
0 comments
#163 Irfan Ahmad / @erfaan - Score: 299 - 12/29/10 @ 06:10
<Down><Down>dddddddddddddddd<Right>i<Del><Del><Up><Left><Left><Left><Left><Left><Left><Left><Left><Left><BS><BS><BS><BS><BS><Right><Del>234567890<Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del> <kPlus><Del><Right><Right><Down><Home><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Left><Del><Del><Del><Del><Del><Del><Del><Del><Del><Del>%d<Right><Right><Right><Right> % n<Esc>:wq<CR>
0 comments
VimGolf