Skip to content

Commit

Permalink
changed recursion and logic
Browse files Browse the repository at this point in the history
  • Loading branch information
RickGelhausen committed Oct 18, 2023
1 parent aed9933 commit 3b09472
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
Binary file added assets/fonts/Creepster.ttf
Binary file not shown.
49 changes: 24 additions & 25 deletions assets/js/recursions.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ function linearRecursion(a0, d, x) {

const sequence = [a0];

for (let n = 2; n < x; n++) {
const an = sequence[n - 2] + d;
for (let n = 1; n < x; n++) {
const an = sequence[n - 1] + d;
sequence.push(an);
}

Expand All @@ -63,35 +63,34 @@ function linearRecursion(a0, d, x) {



function checkLinearRecursion(){
a0 = document.getElementById("linRecA0").value;
x = document.getElementById("linRecX").value;
d = document.getElementById("linRecD").value;
function checkLinearRecursion() {
const a0 = parseFloat(document.getElementById("linRecA0").value);
const x = parseInt(document.getElementById("linRecX").value);
const d = parseFloat(document.getElementById("linRecD").value);
const lrtable = document.getElementById('lin-rec-table');
array = accessArray("linRecTable");
expected = linearRecursion(a0, d, x);
console.log("expected ",expected)
for (var i = 0; i < array.length; i++) {
const expected = linearRecursion(a0, d, x);

console.log("expected ", expected);

for (let i = 0; i < lrtable.rows[1].cells.length; i++) {
const cellElement = lrtable.rows[1].cells[i];
let current = cellElement.childNodes[0].value
var ei = expected[i]
if (i >= x){
if (current == "" || current == null) {
cellElement.style.backgroundColor = "var(--right-answer)"
}
else {
cellElement.style.backgroundColor = "var(--wrong-answer)"
const current = parseFloat(cellElement.childNodes[0].value);
const ei = expected[i];

if (i >= x) {
if (current === "" || current === null) {
cellElement.style.backgroundColor = "var(--right-answer)";
} else {
cellElement.style.backgroundColor = "var(--wrong-answer)";
}
} else {
if (current == "" || current == null) {
cellElement.style.backgroundColor = "var(--wrong-answer)"
}
else if (current == array[i]) {
cellElement.style.backgroundColor = "var(--right-answer)"
if (current === "" || current === null) {
cellElement.style.backgroundColor = "var(--wrong-answer)";
} else if (current === ei) {
cellElement.style.backgroundColor = "var(--right-answer)";
} else {
cellElement.style.backgroundColor = "var(--wrong-answer)"
cellElement.style.backgroundColor = "var(--wrong-answer)";
}

}
}
}
Expand Down
9 changes: 7 additions & 2 deletions bioinf-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ a:hover {
background-color: var(--active-item-color);
}

@font-face {
font-family: 'Creepster';
src: url('fonts/Creepster.ttf') format('truetype');
}

table td:first-child { border-right: 1px solid; }
table th {border-bottom: 1px solid;}
.navbar-default {background-color: var(--ufr-main-blue)}
Expand Down Expand Up @@ -172,8 +177,8 @@ pre {
margin-left: auto;
margin-right: auto;
box-shadow: 0 .2rem .5rem #d8d8d8, 0 0 .0625rem #d8d8d8 !important;
margin-top 40px;
margin-bottom 40px;
margin-top: 40px;
margin-bottom: 40px;

}
.math.display{
Expand Down
2 changes: 1 addition & 1 deletion exercise-sheet-0.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ title: "Exercise sheet 0: Math"
Given the recursive Formulation, fill in the array underneath:

$$
a_{n+1} = a_{n} + d, \quad \forall n : 2 \leqslant n < x
a_{n+1} = a_{n} + d, \quad \forall n : 0 < n < x
$$

```{r, echo=FALSE}
Expand Down
1 change: 0 additions & 1 deletion header.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<head>
<link rel="shortcut icon" href="figures/favicon.svg" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Creepster">
</head>

0 comments on commit 3b09472

Please sign in to comment.