Last active
February 12, 2025 09:17
-
-
Save roblogic/7447f8466d935c0a6d3d6671719abfb3 to your computer and use it in GitHub Desktop.
New attempt at https://codegolf.stackexchange.com/q/95619/15940; based on [this](https://gist.github.com/roblogic/27ea1a4fd79623b295e16e0561fcb6d7)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
debug=# | |
jw(){ | |
(($#1>$#2))&&x=$1 y=$2||x=$2 y=$1 | |
x=$x:l y=$y:l h=$[$#y/2+1] | |
$debug echo x $x y $y h $h | |
r(){ | |
l=$#2 g=$2 s= | |
for i ({0..$#1});{ | |
p=${1:$i:1} v=$[i-h<0?0:i-h] w=$[i+h>l?l:i+h] | |
$debug echo i $i p $p v $v w $w | |
for j ({$v..$w});{ | |
$debug echo j $j p $p g $g gj ${g:$j:1} | |
[[ $p = ${g:$j:1} ]]&&{ s=$s$p g=${g:0:$j}.${g:$j+1} ; break } | |
} | |
} | |
echo $s | |
} | |
m=`r "$x" "$y"` n=`r "$y" "$x"` d=$#m e=$#n | |
$debug echo m $m n $n d $d e $e | |
((d==0|e==0|d!=e))||{ echo 0.0;exit;} | |
for ((i=0;i<d;i++));{ [ "${m:$i:1}" != "${n:$i:1}" ]&&((u++));};z=$((u/2)) | |
bc -l<<<"($d/$#y+$e/$#x+($d-$z)/$d)/3" | |
} | |
jw 1234567890qwertyuiopasdfghjklzxcvbnm mnbvcxzlkjhgfdsapoiuytrewq0987654321 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment