Cut out the word from the text

Delete all occurrences of the word mentioned in the first row from the text below.
Word can be written in any form: from left to right, from right to left, from top to bottom or from bottom to top.

IN

test
qawtest
dsertyu
ftfe234
ferew23
ssresse
etfdswe

OUT

qaw    
dsertyu
f fe234
f rew23
s resse
e fdswe

IN

perl
3fdas3211
fdaslrepd
fdpfdaswf
ddefdsafl
dfrdfadsr
dslfasdfe
fda234adp

OUT

3fdas3211
fdas    d
fd fdaswf
dd fdsaf 
df dfads 
ds fasdf 
fda234ad 
Login to submit solution


15 symbols pyth
Tue Oct 25 16:13:59 2016 Sait2000
ju_C:Rz*;lzG4.z
20 symbols pyth
Mon Sep 19 17:11:54 2016 Sait2000
J.zV4=J_C:Rz*;lzJ)jJ
126 symbols python3
Fri Oct 28 04:10:15 2016 Sait2000
import sys
t=input()
a=sys.stdin
for i in' '*4:a=map(''.join,zip(*[s.replace(t,i*len(t))for s in a][::-1]))
print(*a,sep='\n')
128 symbols python3
Sat Oct 22 21:20:29 2016 Sait2000
from sys import*
t=input()
a=stdin
for i in' '*4:a=map(''.join,zip(*[s.replace(t,i*len(t))for s in a][::-1]))
print(*a,sep='\n')
129 symbols python3
Sat Oct 22 21:16:46 2016 Sait2000
from sys import*
t=input()
a=stdin
for i in' '*4:a=map(''.join,zip(*[s.replace(t,i*len(t))for s in a][::-1]))
print('\n'.join(a))
143 symbols python3
Mon Sep 19 17:31:37 2016 Sait2000
t,*a=input(),
try:
 while 1:a+=input(),
except:0
for i in' '*4:a=map(''.join,zip(*[s.replace(t,i*len(t))for s in a][::-1]))
print('\n'.join(a))
146 symbols python3
Mon Sep 19 17:28:41 2016 Sait2000
t,*a=input(),
try:
 while 1:a+=input(),
except:0
for i in' '*4:a=[*map(''.join,zip(*[s.replace(t,i*len(t))for s in a[::-1]]))]
print('\n'.join(a))
154 symbols perl
Fri Dec 27 17:55:17 2013 vlet
#!/usr/bin/perl -p0
s/^(.+)\n//;($z=$w=$1)=~s/./ /g;sub r{@e=();$l=1+index$_,"\n";$e["@-"%$l].=$&while/./g;join"\n",@e}for$j(1,2){for$d($w,~~reverse$w){$_=~s/$d/$z/g}$_=r}
225 symbols haskell
Wed Mar 18 09:03:33 2015 YoshikuniJujo
import Data.List
main=interact$unlines.(\(w:s)->b w.t w$map(r w.l w)s).lines
x=transpose
v=reverse
l _""=""
l w a@(c:s)|w`isPrefixOf`a=map(const ' ')w++drop(length w)a|0<1=c:l w s
r w=v.l w.v
t w=x.map(l w).x
b w=x.map(r w).x
242 symbols perl
Fri Dec 27 16:23:12 2013 vlet
#!/usr/bin/perl -p0
s/^(.+)\n//;($z=$w=$1)=~s/./ /g;
sub f{@_==1?@_:map{my$e=$_[$_];my@a=@_;splice@a,$_,1;map{$e.$_}f(@a)}(0..@_-1)}
sub r{@e=();$l=index($_,"\n")+1;$e["@-"%$l].=$&while/./g;join"\n",@e}
for$j(1..2){for$d(f(split//,$w)){$_=~s/$d/$z/g}$_=r($_)}
454 symbols haskell
Fri Dec 27 10:16:47 2013 Anton Cheshkov
import Data.List
main = getLine >>= \x -> getContents >>= \i -> putStr (unlines (t (c x (t $ c x (lines i)))))
t = foldl (#) ([]).(map f)
c x k = map (\l -> r $ x @@ (r $ x @@ l) ) k
r = reverse
q = length
(@@) x y = z x (replicate (q x) ' ') y 
f = map (:[])
(#) [] [] = []
(#) [] (y:s) = [y] ++ s
(#) (x:s) [] = [x] ++ s
(#) (x:k) (y:l) = [x ++ y] ++ (k # l)
z a b s@(x:xs) = if isPrefixOf a s then b++z a b (drop (q a) s) else x:z a b xs
z _ _ [] = []
476 symbols haskell
Fri Dec 27 10:11:24 2013 Anton Cheshkov
import Data.List

main = getLine >>= \x -> getContents >>= \i -> putStr (unlines (t (c x (t $ c x (lines i)))))
t = foldl (#) ([]) . (map f)
c x ll = map (\l -> r $ x @@ (r $ x @@ l) ) ll
r = reverse
(@@) x y = rep x (replicate (length x) ' ') y 
f = map (:[])
(#) [] [] = []
(#) [] (y:ys) = [y] ++ ys
(#) (x:xs) [] = [x] ++ xs
(#) (x:xs) (y:ys) = [x ++ y] ++ (xs # ys)
rep a b s@(x:xs) = if isPrefixOf a s then b++rep a b (drop (length a) s) else x:rep a b xs
rep _ _ [] = []

View all solutions