Skip to main content
tweak title
Source Link
roblogic
  • 4k
  • 18
  • 23

Bash 4+, 115 .. 77 bytes

Replaces first char of the first (non-empty) input string with 1,2,3 until no match is found to either input. Try it Online!

-9, -12, -9, -8 bytes all thanks to GammaFunction

x="${1:-$2}"
for s in {1..3}"${x:1}"
{ [[ $s = @($1|$2) ]]||break;}
echo "$s"

(quite an improvement over the original...)

Bash 4+, 77 bytes

Replaces first char of the first (non-empty) input string with 1,2,3 until no match is found to either input. Try it Online!

-9, -12, -9, -8 bytes all thanks to GammaFunction

x="${1:-$2}"
for s in {1..3}"${x:1}"
{ [[ $s = @($1|$2) ]]||break;}
echo "$s"

(quite an improvement over the original...)

Bash, 115 .. 77 bytes

Replaces first char of the first (non-empty) input string with 1,2,3 until no match is found to either input. Try it Online!

-9, -12, -9, -8 bytes all thanks to GammaFunction

x="${1:-$2}"
for s in {1..3}"${x:1}"
{ [[ $s = @($1|$2) ]]||break;}
echo "$s"

(quite an improvement over the original...)

ahh yes it all makes sense now
Source Link
roblogic
  • 4k
  • 18
  • 23

Bash 4+, 8577 bytes

Replaces first char of the first (non-empty) input string with 1,2,3 until no match is found to either input. Try it Online!

  • saved 9 bytes thanks to ideas from GammaFunction
  • saved another 12 bytes using more string shenanigans by GammaFunction
  • chopped another 9 due to Gamma's obscure excellent bashisms :)

-9, -12, -9, -8 bytes all thanks to GammaFunction

x="${1:1-$2}"
for((;i++<4;)) s in {
o=$i$1..3}"${x:-${2:1}}"
{ [[ $o$s = @($1|$2) ]]||{ echo "$o";exit;]]||break;}
}echo "$s"

Try it Online!

(quite an improvement over the original...)

Bash 4+, 85 bytes

Replaces first char of the first (non-empty) input string with 1,2,3 until no match is found to either input

  • saved 9 bytes thanks to ideas from GammaFunction
  • saved another 12 bytes using more string shenanigans by GammaFunction
  • chopped another 9 due to Gamma's obscure excellent bashisms :)
x="${1:1}"
for((;i++<4;)){
o=$i${x:-${2:1}}
[[ $o = @($1|$2) ]]||{ echo "$o";exit;}
}

Try it Online!

(quite an improvement over the original...)

Bash 4+, 77 bytes

Replaces first char of the first (non-empty) input string with 1,2,3 until no match is found to either input. Try it Online!

-9, -12, -9, -8 bytes all thanks to GammaFunction

x="${1:-$2}"
for s in {1..3}"${x:1}"
{ [[ $s = @($1|$2) ]]||break;}
echo "$s"

(quite an improvement over the original...)

joke
Source Link
roblogic
  • 4k
  • 18
  • 23

Bash 4+, 85 bytes

Replaces first char of the first (non-empty) input string with 1,2,3 until no match is found to either input

  • saved 9 bytes thanks to ideas from GammaFunction
  • saved another 12 bytes using more string shenanigans by GammaFunction
  • chopped another 9 due to Gamma's obscureobscure excellent bashisms :)
x="${1:1}"
for((;i++<4;)){
o=$i${x:-${2:1}}
[[ $o = @($1|$2) ]]||{ echo "$o";exit;}
}

Try it Online!

(quite an improvement over the original...)

Bash 4+, 85 bytes

Replaces first char of the first (non-empty) input string with 1,2,3 until no match is found to either input

  • saved 9 bytes thanks to ideas from GammaFunction
  • saved another 12 bytes using more string shenanigans by GammaFunction
  • chopped another 9 due to Gamma's obscure bashisms :)
x="${1:1}"
for((;i++<4;)){
o=$i${x:-${2:1}}
[[ $o = @($1|$2) ]]||{ echo "$o";exit;}
}

Try it Online!

Bash 4+, 85 bytes

Replaces first char of the first (non-empty) input string with 1,2,3 until no match is found to either input

  • saved 9 bytes thanks to ideas from GammaFunction
  • saved another 12 bytes using more string shenanigans by GammaFunction
  • chopped another 9 due to Gamma's obscure excellent bashisms :)
x="${1:1}"
for((;i++<4;)){
o=$i${x:-${2:1}}
[[ $o = @($1|$2) ]]||{ echo "$o";exit;}
}

Try it Online!

(quite an improvement over the original...)

i bow to the master
Source Link
roblogic
  • 4k
  • 18
  • 23
Loading
:)
Source Link
roblogic
  • 4k
  • 18
  • 23
Loading
saving 9 bytes thanks to commenter
Source Link
roblogic
  • 4k
  • 18
  • 23
Loading
saving 11 bytes thanks to commenter
Source Link
roblogic
  • 4k
  • 18
  • 23
Loading
Source Link
roblogic
  • 4k
  • 18
  • 23
Loading