Spaces:
Sleeping
Sleeping
woletee
commited on
Commit
·
3442479
1
Parent(s):
84d3369
fixing the problem with the visualization thing
Browse files- templates/results.html +44 -40
templates/results.html
CHANGED
@@ -45,55 +45,59 @@
|
|
45 |
</ul>
|
46 |
|
47 |
<h2>Input / Output Pairs</h2>
|
48 |
-
|
49 |
-
<div
|
50 |
-
<div>
|
51 |
-
<div class="grid-title">Input Grid</div>
|
52 |
-
<div class="grid-box" id="input-{{ loop.index0 }}"></div>
|
53 |
-
</div>
|
54 |
-
<div>
|
55 |
-
<div class="grid-title">Output Grid</div>
|
56 |
-
<div class="grid-box" id="output-{{ loop.index0 }}"></div>
|
57 |
-
</div>
|
58 |
-
</div>
|
59 |
-
<script>
|
60 |
-
drawGrid("input-{{ loop.index0 }}", {{ pair[0]|tojson }});
|
61 |
-
drawGrid("output-{{ loop.index0 }}", {{ pair[1]|tojson }});
|
62 |
-
</script>
|
63 |
-
{% endfor %}
|
64 |
|
65 |
<h2>Best Program</h2>
|
66 |
-
<pre>{{
|
67 |
|
68 |
<script>
|
69 |
-
|
70 |
-
const container = document.getElementById(id);
|
71 |
-
container.style.gridTemplateRows = `repeat(${gridData.length}, 25px)`;
|
72 |
-
container.style.gridTemplateColumns = `repeat(${gridData[0].length}, 25px)`;
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
4: "#FFDC00", // yellow
|
80 |
-
5: "#B10DC9", // purple
|
81 |
-
6: "#FF851B", // orange
|
82 |
-
7: "#7FDBFF", // light blue
|
83 |
-
8: "#F012BE", // pink
|
84 |
-
9: "#111111" // dark gray
|
85 |
-
};
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
92 |
div.style.backgroundColor = colorMap[cell] || "#000000";
|
93 |
container.appendChild(div);
|
94 |
-
}
|
95 |
-
}
|
96 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
</script>
|
98 |
|
99 |
</body>
|
|
|
45 |
</ul>
|
46 |
|
47 |
<h2>Input / Output Pairs</h2>
|
48 |
+
|
49 |
+
<div id="pairs-container"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
<h2>Best Program</h2>
|
52 |
+
<pre>{{ best_program }}</pre>
|
53 |
|
54 |
<script>
|
55 |
+
const inputOutputPairs = {{ input_output_pairs | tojson }};
|
|
|
|
|
|
|
56 |
|
57 |
+
const colorMap = {
|
58 |
+
0: "#FFFFFF", 1: "#0074D9", 2: "#FF4136", 3: "#2ECC40",
|
59 |
+
4: "#FFDC00", 5: "#B10DC9", 6: "#FF851B", 7: "#7FDBFF",
|
60 |
+
8: "#F012BE", 9: "#111111"
|
61 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
+
function drawGrid(container, gridData) {
|
64 |
+
container.style.gridTemplateRows = `repeat(${gridData.length}, 25px)`;
|
65 |
+
container.style.gridTemplateColumns = `repeat(${gridData[0].length}, 25px)`;
|
66 |
+
gridData.forEach(row => {
|
67 |
+
row.forEach(cell => {
|
68 |
+
const div = document.createElement("div");
|
69 |
+
div.className = "cell";
|
70 |
div.style.backgroundColor = colorMap[cell] || "#000000";
|
71 |
container.appendChild(div);
|
72 |
+
});
|
73 |
+
});
|
74 |
}
|
75 |
+
|
76 |
+
const pairsContainer = document.getElementById("pairs-container");
|
77 |
+
|
78 |
+
inputOutputPairs.forEach((pair, index) => {
|
79 |
+
const container = document.createElement("div");
|
80 |
+
container.className = "grid-container";
|
81 |
+
|
82 |
+
const inputDiv = document.createElement("div");
|
83 |
+
inputDiv.innerHTML = `<div class="grid-title">Input Grid</div>`;
|
84 |
+
const inputGridBox = document.createElement("div");
|
85 |
+
inputGridBox.className = "grid-box";
|
86 |
+
inputDiv.appendChild(inputGridBox);
|
87 |
+
|
88 |
+
const outputDiv = document.createElement("div");
|
89 |
+
outputDiv.innerHTML = `<div class="grid-title">Output Grid</div>`;
|
90 |
+
const outputGridBox = document.createElement("div");
|
91 |
+
outputGridBox.className = "grid-box";
|
92 |
+
outputDiv.appendChild(outputGridBox);
|
93 |
+
|
94 |
+
drawGrid(inputGridBox, pair[0]);
|
95 |
+
drawGrid(outputGridBox, pair[1]);
|
96 |
+
|
97 |
+
container.appendChild(inputDiv);
|
98 |
+
container.appendChild(outputDiv);
|
99 |
+
pairsContainer.appendChild(container);
|
100 |
+
});
|
101 |
</script>
|
102 |
|
103 |
</body>
|