Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Programming Challenge #1488

Name: Anonymous 2017-01-22 14:57

Implement a "diff" program.
Input: two strings or files that may potentially be quite long.
Output: An edit sequence of inserts and deletes to go from one to the other.

Name: Anonymous 2017-01-22 20:02

in sudocode:

result = []

for each letter in input1
do
result.add(new replaceop(actiontype.remove, letter))
done

for each letter in input2
do
result.add(new replaceop(actiontype.add, letter))
done

return result

Name: lets see [...] implement diff 2017-01-22 21:57

>>2
this seems wrong

Name: lets see [...] implement diff 2017-01-22 21:57

>>2
this is a degenerate solution. unacceptable.

Name: Anonymous 2017-01-22 22:37

>>4
Fits the spec you bitter stallman boy

Name: Anonymous 2017-01-23 1:31

void diff(char *alpha, char *beta) {
printf("delete \"%s\"; insert \"%s\"\n", alpha, beta);
}

Name: Anonymous 2017-01-23 5:28

function spstr(str, ix){
var l = str.length%ix;
var n = (str.length-l) / ix;
var tarr = [];
for(var i=0; i<n; i++){
tarr.push(str.substr(i*ix, i*ix+ix-1));
}
tarr.push(str.substr(n*ix, n*ix+l));
var karr = tarr.map(hstr);
return([tarr, karr]);
}

function hstr(str){
var t=0;
for(var i=0; i<str.length; i++){
t = (t + parseInt(str[i])) % 8195;
}
return(t);
}

function diffstr(inpA, inpB){
var n = inpA.length>inpB.length?inpA.length:inpB.length;
var n2 = Math.ceil(Math.sqrt(n));

var tk1 = spstr(inpA, n2);
var tk2 = spstr(inpB, n2);
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List