Skip to content

Commit c5896a3

Browse files
authored
Merge pull request #1 from byandrev/feat/footer
update footer texts
2 parents 7e6d28b + df7cc59 commit c5896a3

File tree

2 files changed

+128
-8
lines changed

2 files changed

+128
-8
lines changed

index.html

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,18 +272,12 @@ <h3 class="text-2xl font-bold mb-2">Collaborate</h3>
272272
class="text-blue-500 underline"
273273
>UFPS</a
274274
>
275-
| Computer theory - Eduard Puerto
275+
| Computer theory
276276
</p>
277277
</div>
278278

279279
<p>
280-
Development by
281-
<a
282-
target="_blank"
283-
class="text-blue-500 underline"
284-
href="https://byandrev-blog.vercel.app"
285-
>Andres Parra</a
286-
>
280+
Development with ❤️
287281
</p>
288282
</footer>
289283

src/afnd.js

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
import { animateNode, renderError, renderOut } from "./animateNode.js";
2+
3+
function verifyAFND(paper, graph, automata, string) {
4+
// function epsilonClosure(states) {
5+
// const epsilonClosureStates = new Set(states);
6+
// const stack = Array.from(states);
7+
8+
// while (stack.length > 0) {
9+
// const state = stack.pop();
10+
11+
// if (automata.transitions[state] && automata.transitions[state]["ε"]) {
12+
// for (const nextState of automata.transitions[state]["ε"]) {
13+
// if (!epsilonClosureStates.has(nextState)) {
14+
// epsilonClosureStates.add(nextState);
15+
// stack.push(nextState);
16+
// }
17+
// }
18+
// }
19+
// }
20+
21+
// return epsilonClosureStates;
22+
// }
23+
24+
// function move(states, symbol) {
25+
// const nextStates = new Set();
26+
27+
// for (const state of states) {
28+
// setTimeout(() => {
29+
// animateNode(
30+
// paper,
31+
// graph,
32+
// state,
33+
// symbol,
34+
// automata.finalStates.includes(state)
35+
// );
36+
37+
// if (
38+
// automata.transitions[state] &&
39+
// automata.transitions[state][symbol]
40+
// ) {
41+
// for (const nextState of automata.transitions[state][symbol]) {
42+
// nextStates.add(nextState);
43+
// }
44+
// }
45+
// }, 1000);
46+
// }
47+
// return nextStates;
48+
// }
49+
50+
// let i = 0;
51+
// let currentStates = epsilonClosure(new Set([automata.initialState]));
52+
// let symbol = string[i];
53+
54+
// const interval = setInterval(() => {
55+
// currentStates = epsilonClosure(move(currentStates, symbol));
56+
57+
// if (i >= string.length) {
58+
// for (const state of currentStates) {
59+
// if (automata.finalStates.includes(state)) {
60+
// console.log("YES");
61+
// return true;
62+
// }
63+
// }
64+
65+
// clearInterval(interval);
66+
// }
67+
68+
// i++;
69+
// symbol = string[i];
70+
// }, 1000);
71+
72+
const getNextStates = (states, symbol) => {
73+
const nextStates = new Set();
74+
75+
for (const state of states) {
76+
if (automata.transitions[state] && automata.transitions[state][symbol]) {
77+
for (const nextState of automata.transitions[state][symbol]) {
78+
nextStates.add(nextState);
79+
}
80+
}
81+
}
82+
83+
return nextStates;
84+
};
85+
86+
let currentStates = [automata.initialState];
87+
88+
const verify = (states, symbol) => {
89+
let i = 0;
90+
let state = states[0];
91+
92+
const interval = setInterval(() => {
93+
animateNode(
94+
paper,
95+
graph,
96+
state,
97+
symbol,
98+
automata.finalStates.includes(state)
99+
);
100+
101+
if (i >= string.length) {
102+
clearInterval(interval);
103+
return;
104+
}
105+
106+
states = getNextStates(states, symbol);
107+
108+
if (states.length <= 0) {
109+
return;
110+
}
111+
112+
console.log("Current: ", states);
113+
114+
i++;
115+
symbol = string[i];
116+
117+
verify(states, symbol);
118+
}, 1000);
119+
};
120+
121+
verify(currentStates, string[0]);
122+
123+
return false;
124+
}
125+
126+
export { verifyAFND };

0 commit comments

Comments
 (0)