| Bytes | Lang | Time | Link |
|---|---|---|---|
| 017 | 05AB1E | 250815T074105Z | Kevin Cr |
| 010 | Vyxal D | 210831T091825Z | emanresu |
| 135 | Python 3.8 prerelease | 210831T144426Z | Jakque |
| 210 | Haskell | 210831T104902Z | Wheat Wi |
| 258 | Python 2 | 170808T171234Z | totallyh |
| 113 | JavaScript | 170808T171545Z | user7234 |
| 101 | Python 2 + sequtils | 170808T172354Z | Erik the |
05AB1E, 17 bytes
0"D34çý.L"D34çý.L
Explanation:
0"D34çý"D34çý: standard 05AB1E quine taken from this 14-bytes answer.L: Levenshtein distance with the (implicit) input-string
Note: there are two shorter standard 05AB1E quines, which are 13 bytes each, but unfortunately:
- This one would be longer (20 bytes) with the added
.L:14405833537536D₅BJ.L- try it online; - This one doesn't work with inputs.
Vyxal D, 10 bytes
`:qp꘍`:qp꘍
Thanks to Aaron Miller for this one.
`:qp `:qp # Standard quine
꘍ ꘍ # Levenshtein distance
Vyxal D, 13 bytes
`q\`:Ė\`+꘍`:Ė
`q\`:Ė\`+ `:Ė # Standard eval quine (see https://codegolf.stackexchange.com/a/232956/100664)
꘍ # Leveshtein distance with input
10 bytes in Vyxal 2.6, whiich hasn't been released yet
Python 3.8 (pre-release), 135 bytes
exec(s:="l=lambda a,b:min(l(A:=a[1:],B:=b[1:])-(a[0]==b[0]),l(A,b),l(a,B))+1if b>''<a else len(a+b);print(l('exec(s:=%r)'%s,input()))")
took my solution of levenstein distance (https://codegolf.stackexchange.com/a/233868/103772) and adapted it to a quine. It is very (very) slow but it works
Haskell, 210 bytes
main=interact$show.((x++show x)%);x@(a:c)%y@(b:d)|a==b=c%d|1>0=1+minimum[x%d,c%y,c%d];x%y=length$x++y;x="main=interact$show.((x++show x)%);x@(a:c)%y@(b:d)|a==b=c%d|1>0=1+minimum[x%d,c%y,c%d];x%y=length$x++y;x="
Computes the levenshtein distance modified from here. (I wrote the code there too) This is combined with a standard quine mechanism. Not much special here.
If you want to play around with it I suggest making edits towards the end of the string. The algorithm is more or less \$O(n+m^4)\$ where \$n\$ is the location of the difference between the input and the source, and \$m\$ is the length of the string after the first difference. So if you add a character to the front of this the compute time is exponential with the length of input and you won't see your result on tio.
Python 2, 278 258 bytes
t=input();s,f='t=input();s,f=%r,lambda m,n:m or n if m*n<1else-~min(f(m-1,n),f(m,n-1),f(m-1,n-1)-((s%%s)[m-1]==t[n-1]));print f(len(s%%s),len(t))',lambda m,n:m or n if m*n<1else-~min(f(m-1,n),f(m,n-1),f(m-1,n-1)-((s%s)[m-1]==t[n-1]));print f(len(s%s),len(t))
This is just the usual quine in Python, mixed with the Levenshtein algorithm from this answer. Note that it gets quite extremely (thanks to Mr. Xcoder :P) slow.
JavaScript, 113 bytes
This is a valid quine.
f=t=>[...t].map((v,j)=>x=x.map((w,k)=>q=k--?Math.min(q,w,x[k]-(v==u[k]))+1:j+1),x=[...[,...u=`f=${f}`].keys()])|q
f=t=>[...t].map((v,j)=>x=x.map((w,k)=>q=k--?Math.min(q,w,x[k]-(v==u[k]))+1:j+1),x=[...[,...u=`f=${f}`].keys()])|q
console.log(f('f=t=>[...t].map((v,j)=>x=x.map((w,k)=>q=k--?Math.min(q,w,x[k]-(v==u[k]))+1:j+1),x=[...[,...u=`f=${f}`].keys()])|q'));
console.log(f('%'));
console.log(f('12345'));
Idea stolen from other answer.
Python 2 + sequtils, 101 bytes
from sequtils import*;_='from sequtils import*;_=%r;print edit(_%%_,input())';print edit(_%_,input())