Character removal

Remove a specified char from a string. Also remove n letters each side alphabetically.

eg:
If char is 'm' and n is 1 then remove 'l', 'm' and 'n' from the string.

If char is 'p' and n is 2 then remove 'n', 'o', 'p', 'q' and 'r'.

n is in the range 0..9. n is the first char on stdin. The char to remove is last char on stdin

eg: 2abcdefghid
output: aghi
Why? First char '2' so n=2 Last char is 'd' so remove 'b', 'c', 'd', 'e', 'f'

Case is always lower. Alphabet wraps from z to a.

IN

2abcdefghid

OUT

aghi

IN

0zxmnjagdsialhttthskdtkt

OUT

zxmnjagdsialhhskdk

IN

9iajz

OUT

j

IN

9abcdefghijklmnopqrstuvwxyz

OUT

jklmnop
Login to submit solution


24 symbols pyth
Mon Sep 19 15:54:00 2016 Sait2000
-tz:*3G-J+26xGezKshzh+JK
53 symbols bash
Tue Aug 16 22:40:02 2016 hidefromkgb
sed '/2/caghi
/0/czxmnjagdsialhhskdk
/9i/cj
cjklmnop'
56 symbols bash
Tue Aug 16 21:54:23 2016 hidefromkgb
sed '/2/caghi
/0/czxmnjagdsialhhskdk
/9i/cj
/9/cjklmnop'
60 symbols bash
Tue Aug 16 20:44:38 2016 hidefromkgb
sed $'/2/caghi\n/0/czxmnjagdsialhhskdk\n/9i/cj\n/9/cjklmnop'
68 symbols perl
Mon Sep 29 01:15:25 2014 vakorol
#!/usr/bin/perl -p
$o=chop;s/.//;for$i(-$&..+$&){$p=(a..z)[($i-97+ord$o)%26];s/$p//g}
71 symbols perl
Sat Aug 9 21:18:02 2014 danieljabailey
#!/usr/bin/perl -p
$t=ord(chop)-97;/^./;$_=$';$c.=chr(($t+$_)%26+97)for-$&..$&;s/[$c]//g
77 symbols perl
Sun Jun 22 12:09:40 2014 avkhozov
#!/usr/bin/perl -p
$t=ord(chop)-97;/^./;$n=$&;$_=$';$c.=chr(($t+$_)%26+97)for-$n..$n;s/[$c]//g
87 symbols perl
Fri Jun 13 17:34:39 2014 danieljabailey
#!/usr/bin/perl -n
$t=ord(chop)-97;/^./;$n=$&;$_=$';for(-$n..$n){$c.=chr(($t+$_)%26+97);}s/[$c]//g;print
92 symbols bash
Mon Jul 25 05:48:18 2016 hidefromkgb
t=`cat`;n=.{${t:0:1}};tr -d "`echo {a..z} {a..z}|grep -Po $n$n${t: -1}\ $n$n|uniq`"<<<${t:1}
93 symbols perl
Fri Jun 13 17:32:09 2014 danieljabailey
#!/usr/bin/perl -n
chomp;$t=ord(chop)-97;/^./;$n=$&;$_=$';for(-$n..$n){$c.=chr(($t+$_)%26+97);}s/[$c]//g;print
93 symbols bash
Mon Jul 25 01:34:47 2016 hidefromkgb
t=`cat`;n=.{${t:0:1}};tr -d `echo {a..z} {a..z}|tr -d \ |grep -Po $n${t: -1}$n|uniq`<<<${t:1}
97 symbols bash
Sun Jul 24 13:58:24 2016 hidefromkgb
t=$(cat);n=.{${t:0:1}};echo ${t:1}|tr -d `echo {a..z} {a..z}|tr -d \ |grep -Po $n${t: -1}$n|uniq`
98 symbols perl
Fri Jun 13 11:29:27 2014 dionys
#!/usr/bin/perl -lnaF
$d=shift@F;$r=$d+ord pop@F;$l=$r-$d*2;print grep{$o=ord;$o>$r-26&&$o<$l ||$o>$r&&$o<$l+25}@F
101 symbols perl
Fri Jun 13 17:21:36 2014 danieljabailey
#!/usr/bin/perl -n
chomp;$t=ord(chop)-97;$n=substr$_,0,1;s/^.//;for(-$n..$n){$c.=chr(($t+$_)%26+97);}~s/[$c]//g;print;
103 symbols perl
Fri Jun 13 03:49:34 2014 danieljabailey
#!/usr/bin/perl -n
chomp;$t=chop;$n=substr$_,0,1;s/^.//;for$x(-$n..$n){$c.=chr((ord($t)+$x-97)%26+97);}~s/[$c]//g;print;
110 symbols perl
Fri Jun 13 03:31:18 2014 dionys
#!/usr/bin/perl -lnaF
$d=shift@F;$r=$d+ord pop@F;$l=$r-$d*2;$m=$r-26;$s=$l+25;print grep{$o=ord;$o>$m&&$o<$l ||$o>$r&&$o<$s}@F
119 symbols perl
Fri Jun 13 03:20:10 2014 dionys
#!/usr/bin/perl -ln
@s=split//;$d=shift@s;$r=$d+ord pop@s;$l=$r-$d*2;$m=$r-26;$s=$l+25;print grep{$o=ord;$o>$m&&$o<$l ||$o>$r&&$o<$s}@s
126 symbols perl
Thu Jun 12 22:50:47 2014 danieljabailey
#!/usr/bin/perl -n
chomp;$t=chop;$n=substr$_,0,1;$_=~s/^.//;$i=$_;for(-$n..$n){$e=ord($t)+$_;$e=($e-97)%26+97;$c.=chr$e;}$i=~s/[$c]//g;print$i;
128 symbols perl
Thu Jun 12 22:49:02 2014 danieljabailey
#!/usr/bin/perl -n
chomp;$t=chop;$n=substr$_,0,1;$_=~s/^.//;$i=$_;for(-$n..$n){$e=ord($t)+$_;$e=(($e-97)%26)+97;$c.=chr$e;}$i=~s/[$c]//g;print$i;
143 symbols perl
Thu Jun 12 22:43:34 2014 danieljabailey
#!/usr/bin/perl -n
chomp;$t=chop;$n=substr$_,0,1;$_=~ s/^.//;$i=$_;for(-$n..$n){$e=ord($t)+$_;$e=$e<97?$e+26:$e>122?$e-26:$e;$c.=chr($e);}$i=~s/[$c]//g;print$i;

View all solutions