This commit is contained in:
2024-12-06 10:26:07 +01:00
parent 0c0bb5e198
commit 49a3571c09
+18 -15
View File
@@ -1,4 +1,3 @@
// Doesn't works
import { open } from 'node:fs/promises'; import { open } from 'node:fs/promises';
@@ -36,19 +35,23 @@ function keep_only_errors(line: number[]) {
}, []) }, [])
} }
const result = all_diffs.map((line) => { let correct_lines = 0
return keep_only_errors(line) all_diffs.forEach((line, line_index) => {
}) const errors = keep_only_errors(line)
if (errors.length == 0) {
const orig_lines_spliced = all_diffs.map((line, index) => { correct_lines++
const l = Array.from(orig_lines[index]) return
const errors_indexes = keep_only_errors(line)
if (errors_indexes.length > 0) {
l.splice(errors_indexes[0], 1)
} }
return l
const ol = orig_lines[line_index]
for (const i in ol) {
const orig_line_spliced = Array.from(ol)
orig_line_spliced.splice(Number(i), 1)
if (keep_only_errors(compute_diff(orig_line_spliced)).length == 0) {
correct_lines++
return
}
}
}) })
console.log(correct_lines)
console.log(orig_lines_spliced.map(compute_diff).map(keep_only_errors).reduce((t, c) => c.length == 0 ? t + 1 : t, 0))
all_diffs