-
Notifications
You must be signed in to change notification settings - Fork 1
/
record-search-algo.html
375 lines (265 loc) · 5.08 KB
/
record-search-algo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<html>
<head>
<style>
#log {
width:max-content;
}
.tag {
padding: 0 12px;
background: #cde;
width: auto;
display:inline-block;
font-weight: bolder;
/**animation: fadeIn 0.5s;**/
}
.tag:before {
content: "#";
font-weight: light;
padding: 0 8px;
color: #ddd;
}
.tag2:before {
content: "+";
font-weight: bolder;
padding: 0 8px;
color: #ddd;
}
@keyframes fadeIn {
0% { opacity: 0; transform: translateY(50px); }
100% { opacity: 1; transform: translateY(0px); }
}
</style>
</head>
<body>
<div id="tit"></div>
<input id="inp" onkeyup="fn(this.value)"></input>
<br>
<div id="log"></div>
<script>
let s = `broken
former
RecordTypes ()
first Fi
smallest Sm
fastest Fa
smallest-possible SmP
fastest-possible FaP
first-smallest
first-fastest
first-smallest-possible
first-fastest-possible
first-smallest-fastest
first-smallest-fastest-possible
first-fastest-smallest
first-fastest-smallest-possible
smallest-first
smallest-fastest
smallest-fastest-possible
smallest-first-fastest
smallest-first-smallest-possible
smallest-first-fastest-possible
first-smallest fism
first-fastest fifa
first-smallest-fastest fismfa
first-fastest-smallest fifasm
smallest-first smfi
smallest-fastest smfa
smallest-first-fastest smfifa
smallest-fastest-first smfafi
fastest-first fafi
fastest-smallest fasm
fastest-first-smallest fafism
fastest-smallest-first fasmfi
Feeding ()
tnt
glass gls
lamp lmp
redstone-block RB
UnknownA
stargate
Placement
centre
UnknownB ()
rail
carpet
State
always-on
Patterns ()
asdjke Pa
bar Pb
cave Pca
checkerboard Chb
corner Crn
funnel Fun
gold-play GP
pitch Pi
sissybar Si
vault Va
vortex Vo
Arrangement []
deep
inverted inv
reversed rvs
Alignment ()
horizontal H
vertical V
Shape ()
cuboid Cub
circle Cir
right-triangle RTir
triangle Tir
regular Reg
Restrictions.Component []+
sticky-block-less SBL
sticky-piston-less SPL
gravity-block-less GBL
observer ()
observer-less ObL
observer-only ObO
zomba Za
zomba-plus ZaP
zombi Zi
clock-less CL
entity-less EL
juke ()
juke-less JL
juke-only JO
target ()
target-less TL
target-only TO
torch-dust-only TDO
redstone-block-only RBO
Restrictions.Wiring []+
seamless Sml
flush F
deluxe Dlx
dent-less DL
expandable () Ex
finite-expandable FEx
infinite-expandable IEx
hipster ()
floor-hipster FH
wall-hipster WH
ceiling-hipster CH
trapdoor () Trp
floor-trapdoor FTrp
ceiling-trapdoor CTrp
relog-proof RP
stackable St
water-proof
UnknownC []
semi
full
super
DoorTypes ()
door
skydoor
UnknownD ()
single
duel
Misc
stairs
enchantment portal EnP
locational Lo
terracotta
`
let ar = s.split(/\n+/)
function ld (source, target) {
let sourceLen = source .length
let targetLen = target .length
if (sourceLen === 0) return targetLen;
if (targetLen === 0) return sourceLen;
const matrix = []
for (let i = 0; i <= targetLen; i++) {
matrix[i] = [i]
for (let j = 1; j <= sourceLen; j++) {
if (i == 0) {
matrix[i][j] = j
}
else {
matrix[i][j] = Math.min(
matrix[i - 1][j] + 1,
matrix[i][j - 1] + 1,
matrix[i - 1][j - 1] + (source[j - 1] === target[i - 1] ? 0 : 1)
)
}
}
}
return matrix[ targetLen ][ sourceLen ]
}
function mm (a,b){
let n = 0
for (let i = 0, j = 0; i < a.length; i++) {
let c = a[i]
for (let k = j; k < b.length; k++) {
let cc = b[k]
if (c!=cc) {
if (k == b.length-1) {
i = a.length
n = 0
break
}
continue;
}
j = k
n++
break
}
}
return n
}
let m2 = (a,b) => b.length - (a.split('').reduce((r,v) => r.replace(v,''),b).length);
let last = null
let fn = (v) => {
if (last) clearInterval(last);
last = setTimeout(() => {
let i = (v ?? prompt()).replace(/\s+/g,'-')
if (!i) {log.innerHTML = "";return;}
let l = null
let o = []
ar.forEach(v => {
if (!v) return;
v = v.trim().split(/\s+/)[0]
if((v.length / i.length) < 0.8) return;
let q =
//1
//i.split('').some((k) => v.includes(k))
mm(i,v)
//let qq = m2(i,v)
if (!q) return;
let p = ld(i,v)
let n = p // q
let nn = p/(q)
nn = (nn - Math.floor(nn)) < 0.6 ? Math.floor(nn) : Math.ceil(nn);
console.log(i, v, p, q, p/q )
if (!o[nn]) o[nn] = [];
o[nn].push(v+","+nn )
return
if (l==null || n < l) {
o = []
l = n
};
if (n == l) o.push(v);
})
console.log(o)
//if (o[0]) inp.value = o[0];
console.log( inp )
let n = setInterval(() => {
log.style.opacity -= 0.035
if (log.style.opacity > 0) return;
clearInterval(n)
log.style.opacity = 1
let da = o.filter(Boolean).splice(0,2).flat().splice(0,10)
if (!da.some(v => v.startsWith(i) )) da.splice(10,0, "+" + i);
log.innerHTML = da.map( (v,ii) => `<span onclick="if('${v}'.startsWith('+')) { ar.push('${v}'.replace('+','')); }; tit.innerHTML += '${v.split(/,/)[0]} '; inp.focus(); this.onclick = null" class='${ v.startsWith("+") ? "tag tag2" : "tag"}' style="color: #${v.split('').reduce((r,v)=>(r+v.charCodeAt())%16777215,0).toString(16)}; animation: cubic-bezier(0.25,1, 0.5,1) fadeIn ${0.5+(ii*0.5)}s;">${v.replace('+','')}</span>`).join("<br>")
})
//setTimeout(fn,100)
}, 250)
}
function sinp(v) {
inp.value = v
}
//fn()
</script>
</body>
</html>