Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Perl, 58 bytes

57 bytes code + 1 for -p.

Requires first item on one line, then the replacements on the next. Big thanks to @Dada@Dada who came up with a different approach to help reduce by 4 bytes!

$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee 

Usage

perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'Football -o -a +a +i' Fiitbill 
perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'mississippi -is -i +iz +p' mpzspzspppp 
perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'mississippi -ippi -i -mess +ee +e +tenn' tennessee 

Perl, 58 bytes

57 bytes code + 1 for -p.

Requires first item on one line, then the replacements on the next. Big thanks to @Dada who came up with a different approach to help reduce by 4 bytes!

$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee 

Usage

perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'Football -o -a +a +i' Fiitbill 
perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'mississippi -is -i +iz +p' mpzspzspppp 
perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'mississippi -ippi -i -mess +ee +e +tenn' tennessee 

Perl, 58 bytes

57 bytes code + 1 for -p.

Requires first item on one line, then the replacements on the next. Big thanks to @Dada who came up with a different approach to help reduce by 4 bytes!

$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee 

Usage

perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'Football -o -a +a +i' Fiitbill 
perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'mississippi -is -i +iz +p' mpzspzspppp 
perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'mississippi -ippi -i -mess +ee +e +tenn' tennessee 
added 195 characters in body
Source Link
Dom Hastings
  • 24.7k
  • 4
  • 58
  • 94

Perl, 5558 bytes

5457 bytes code + 1 for -p.

Requires first item on one line, then the replacements on the next. Big thanks to @Dada who came up with a different approach to help reduce by 4 bytes!

$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;$2"%eeg;q{$2}"%ee 

Usage

perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;$2"%ee'g;q{$2}"%ee' <<< 'Football -o -a +a +i' Fiitbill 
perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;$2"%ee'g;q{$2}"%ee' <<< 'mississippi -is -i +iz +p' mpzspzspppp 
perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'mississippi -ippi -i -mess +ee +e +tenn' tennessee 

Perl, 55 bytes

54 bytes code + 1 for -p.

Requires first item on one line, then the replacements on the next. Big thanks to @Dada who came up with a different approach to help reduce by 4 bytes!

$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;$2"%ee 

Usage

perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;$2"%ee' <<< 'Football -o -a +a +i' Fiitbill 
perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;$2"%ee' <<< 'mississippi -is -i +iz +p' mpzspzspppp 

Perl, 58 bytes

57 bytes code + 1 for -p.

Requires first item on one line, then the replacements on the next. Big thanks to @Dada who came up with a different approach to help reduce by 4 bytes!

$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee 

Usage

perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'Football -o -a +a +i' Fiitbill 
perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'mississippi -is -i +iz +p' mpzspzspppp 
perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;q{$2}"%ee' <<< 'mississippi -ippi -i -mess +ee +e +tenn' tennessee 
added 121 characters in body
Source Link
Dom Hastings
  • 24.7k
  • 4
  • 58
  • 94

Perl, 5955 bytes

5854 bytes code + 1 for -p.

Requires itemsfirst item on one line, then the replacements on the next. Big thanks to be separated@Dada who came up with a different approach to help reduce by newlines.4 bytes!

@a=map/.$a=<>;1while$a=~s%-(.+\S*)/g,<>;for$i(0..@a/2-1*?){s!$a[$i]!$a[$i+@a\+(\S*)%"s/2]!g}$1/$3/g;$2"%ee 

Usage

perl -pe '@a=map/.'$a=<>;1while$a=~s%-(.+\S*)/g,<>;for$i(0..@a/2-1*?){s!$a[$i]!$a[$i+@a\+(\S*)%"s/2]!g}'$1/$3/g;$2"%ee' <<< 'Football -o   -a   +a   +i' Fiitbill 
perl -pe '@a=map/.'$a=<>;1while$a=~s%-(.+\S*)/g,<>;for$i(0..@a/2-1*?){s!$a[$i]!$a[$i+@a\+(\S*)%"s/2]!g}'$1/$3/g;$2"%ee' <<< 'mississippi -is   -i   +iz   +p' mpzspzspppp 

Perl, 59 bytes

58 bytes code + 1 for -p.

Requires items to be separated by newlines.

@a=map/.(.+)/g,<>;for$i(0..@a/2-1){s!$a[$i]!$a[$i+@a/2]!g} 

Usage

perl -pe '@a=map/.(.+)/g,<>;for$i(0..@a/2-1){s!$a[$i]!$a[$i+@a/2]!g}' <<< 'Football -o  -a  +a  +i' Fiitbill 
perl -pe '@a=map/.(.+)/g,<>;for$i(0..@a/2-1){s!$a[$i]!$a[$i+@a/2]!g}' <<< 'mississippi -is  -i  +iz  +p' mpzspzspppp 

Perl, 55 bytes

54 bytes code + 1 for -p.

Requires first item on one line, then the replacements on the next. Big thanks to @Dada who came up with a different approach to help reduce by 4 bytes!

$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;$2"%ee 

Usage

perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;$2"%ee' <<< 'Football -o -a +a +i' Fiitbill 
perl -pe '$a=<>;1while$a=~s%-(\S*)(.*?)\+(\S*)%"s/$1/$3/g;$2"%ee' <<< 'mississippi -is -i +iz +p' mpzspzspppp 
Source Link
Dom Hastings
  • 24.7k
  • 4
  • 58
  • 94
Loading