Hong-Phuc Bui
2025-10-17 0079221776106e3ca91076938e80d37e38eacc29
1. Vorlesung
2 files deleted
42 files modified
2 files added
285 ■■■■ changed files
.gitignore 8 ●●●●● patch | view | raw | blame | history
README.md 5 ●●●●● patch | view | raw | blame | history
textbased-programms/arithmetic-op.js 10 ●●●● patch | view | raw | blame | history
textbased-programms/binary.js 2 ●●● patch | view | raw | blame | history
textbased-programms/chess.js 5 ●●●●● patch | view | raw | blame | history
textbased-programms/cys-a3.js 2 ●●● patch | view | raw | blame | history
textbased-programms/dice-simulation.js 2 ●●● patch | view | raw | blame | history
textbased-programms/drawing-hands.js 6 ●●●● patch | view | raw | blame | history
textbased-programms/echo.js 2 ●●● patch | view | raw | blame | history
textbased-programms/euclidean-algorithm.js 2 ●●● patch | view | raw | blame | history
textbased-programms/flipping-a-coin.js 2 ●●● patch | view | raw | blame | history
textbased-programms/gravitation.js 12 ●●●●● patch | view | raw | blame | history
textbased-programms/harmonic.js 2 ●●● patch | view | raw | blame | history
textbased-programms/hash-and-star.js 2 ●●● patch | view | raw | blame | history
textbased-programms/hello-name.js 2 ●●● patch | view | raw | blame | history
textbased-programms/helloworld-html.js 2 ●●● patch | view | raw | blame | history
textbased-programms/helloworld-terminal.js 2 ●●● patch | view | raw | blame | history
textbased-programms/linked-list.html 6 ●●●● patch | view | raw | blame | history
textbased-programms/linked-list.js 32 ●●●● patch | view | raw | blame | history
textbased-programms/literal-object.html 11 ●●●●● patch | view | raw | blame | history
textbased-programms/literal-object.js 5 ●●●● patch | view | raw | blame | history
textbased-programms/loop-test.html 19 ●●●●● patch | view | raw | blame | history
textbased-programms/loop-test.js 10 ●●●●● patch | view | raw | blame | history
textbased-programms/luhn.js 8 ●●●● patch | view | raw | blame | history
textbased-programms/monitor.js 2 ●●● patch | view | raw | blame | history
textbased-programms/new-program.py 2 ●●● patch | view | raw | blame | history
textbased-programms/newton-method-sqrt.html 7 ●●●●● patch | view | raw | blame | history
textbased-programms/newton-method-sqrt.js 4 ●●●● patch | view | raw | blame | history
textbased-programms/point-to-text.html 5 ●●●●● patch | view | raw | blame | history
textbased-programms/point-to-text.js 2 ●●● patch | view | raw | blame | history
textbased-programms/power-of-2-multi.html 5 ●●●●● patch | view | raw | blame | history
textbased-programms/power-of-2-multi.js 4 ●●●● patch | view | raw | blame | history
textbased-programms/power-of-2.html 4 ●●● patch | view | raw | blame | history
textbased-programms/power-of-2.js 4 ●●●● patch | view | raw | blame | history
textbased-programms/prime-bigint-function.html 7 ●●●●● patch | view | raw | blame | history
textbased-programms/prime-bigint-function.js 8 ●●●● patch | view | raw | blame | history
textbased-programms/prime-bigint.html 6 ●●●●● patch | view | raw | blame | history
textbased-programms/prime-bigint.js 7 ●●●●● patch | view | raw | blame | history
textbased-programms/quadratic-equation.html 2 ●●● patch | view | raw | blame | history
textbased-programms/quadratic-equation.js 16 ●●●● patch | view | raw | blame | history
textbased-programms/taylor-serie-exp.js 10 ●●●● patch | view | raw | blame | history
textbased-programms/taylor-serie-trigonometry.js 10 ●●●● patch | view | raw | blame | history
textbased-programms/triangle-star.html 6 ●●●●● patch | view | raw | blame | history
textbased-programms/triangle-star.js 2 ●●● patch | view | raw | blame | history
textbased-programms/virus-expand.html 7 ●●●● patch | view | raw | blame | history
textbased-programms/virus-expand.js 6 ●●●● patch | view | raw | blame | history
.gitignore
New file
@@ -0,0 +1,8 @@
*/.idea/*
.idea/*
.idea
helloworld-terminal/dfhi-dom.js
*/data.csv
**/img/permutation.*
*/.parcel-cache
node_modules
README.md
New file
@@ -0,0 +1,5 @@
Beispiel-Projekten im Jahrgang 2024/2025
textbased-programms/arithmetic-op.js
@@ -6,10 +6,10 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
    let a = 12;
    let b = 5;
    let c = Math.floor(12/5); // 2
    let d = (12/5) | 0;
window.main = (...argv)=> {
    const a = 12;
    const b = 5;
    const c = Math.floor(a/b); // 2
    const d = (a/b) | 0;
    terminal.print(c);
};
textbased-programms/binary.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    let n = BigInt(argv[0]);
    let power = 1n;
    const LIMIT = n / 2n;
textbased-programms/chess.js
@@ -11,7 +11,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    let n = Number.parseInt(argv[0]);
    terminal.clear();
    printTopBottomLine(n);
@@ -33,8 +33,7 @@
};
function printTopBottomLine(n, symbol='_')
{
const printTopBottomLine = (n, symbol='_') => {
    terminal.print('.');
    for(let i = 0; i < n; ++i) {
        terminal.print(symbol);
textbased-programms/cys-a3.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    let a = 0,
        b = 1;
    for(let i = 0; i < 15; ++i) {
textbased-programms/dice-simulation.js
@@ -8,7 +8,7 @@
/**
 * Simulation eines Würfel
 * */
window.main = function(...argv) {
window.main = (...argv) => {
    const IMG_DIR = "./dice-simulation/assert";
    let min = 1;
textbased-programms/drawing-hands.js
@@ -5,15 +5,15 @@
import {terminal} from "./dfhi.js";
function leftHand() {
const leftHand = () => {
    return rightHand();
}
function rightHand() {
const rightHand = () => {
    return leftHand();
}
window.main = function(...argv) {
window.main = (...argv) => {
    terminal.printl(leftHand() + " draws first!");
};
textbased-programms/echo.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    terminal.clear();
    for(let arg of argv) {
        terminal.printl(arg);
textbased-programms/euclidean-algorithm.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    let a = Number.parseInt(argv[0], 10);
    let b = Number.parseInt(argv[1], 10);
    let t = b;
textbased-programms/flipping-a-coin.js
@@ -1,6 +1,6 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    if( Math.random() < 0.5) {
        terminal.printl("Kopf");
    } else {
textbased-programms/gravitation.js
@@ -12,12 +12,10 @@
const G = 6.67430;
window.main = function(...argv) {
    /*const mass1 = parseFloat(argv[0]);
    const mass2 = parseFloat(argv[1]);
    const r = parseFloat(argv[2]);
    let force = G * mass1 * mass2 / (r*r);
    */
    //(a < b+ c) && (b < a + c) && (c < b + a);
window.main = (...argv) => {
    const mass1 = Number(argv[0]);
    const mass2 = Number(argv[1]);
    const r = Number(argv[2]);
    const force = G * mass1 * mass2 / (r*r);
    terminal.printh(force);
};
textbased-programms/harmonic.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    const n = Number.parseInt(argv[0]);
    let h = 0;
    for(let i = 1; i <=n; ++i) {
textbased-programms/hash-and-star.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    let n = Number.parseInt(argv[0]);
    let stars = '<table>';
    // Code to create table (with tr and td....
textbased-programms/hello-name.js
@@ -6,7 +6,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    let name = argv[0];
    terminal.print(`Hallo, ${name}!`)
};
textbased-programms/helloworld-html.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    let name = argv[0];
    let color = 'blue';
    let greeting = `<span style='color:${color}'>
textbased-programms/helloworld-terminal.js
@@ -7,6 +7,6 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    terminal.printl("Hello world");
};
textbased-programms/linked-list.html
@@ -7,9 +7,9 @@
    <link rel="stylesheet" href="dfhi.css" />
</head>
<body>
<p class="description">(Passen Sie die Beschreibung des Programs hier an.)</p>
<label for="argv"><code>main</code>'s arguments:</label> <input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
<p class="description">Demo Linked List. </p>
<p>To start program click run</p>
<button name="run" id="run" >Run</button>
<pre id="text-output"></pre>
textbased-programms/linked-list.js
@@ -5,7 +5,20 @@
import {terminal} from "./dfhi.js";
function insert(list, value) {
window.main = () => {
    let list = {
        head: {
            value: "b",
            next: null
        }
    };
    append(list, "c");
    terminal.printl(toString(list)); // → (head) -> b -> c -> (null)
    insert(list, "a");
    terminal.printl(toString(list)); // → (head) -> a -> b -> c -> (null)
};
const insert = (list, value) => {
    try{
        let head = {
            value: value,
@@ -19,7 +32,7 @@
    }
}
function append(list, value) {
const append = (list, value) => {
    try{
        let nextElement = list.head;
        while(nextElement.next != null) {
@@ -36,7 +49,7 @@
    }
}
function toString(list) {
const toString = (list) => {
    try{
        let nextElement = list.head;
        let representation = `(head) -> ${nextElement.value}`;
@@ -52,16 +65,5 @@
    }
}
window.main = function(...argv) {
    let list = {
        head: {
            value: "b",
            next: null
        }
    };
    append(list, "c");
    terminal.printl(toString(list)); // → (head) -> b -> c -> (null)
    insert(list, "a");
    terminal.printl(toString(list)); // → (head) -> a -> b -> c -> (null)
};
textbased-programms/literal-object.html
@@ -7,13 +7,16 @@
    <link rel="stylesheet" href="dfhi.css" />
</head>
<body>
<p class="description">(Passen Sie die Beschreibung des Programs hier an.)</p>
<label for="argv"><code>main</code>'s arguments:</label> <input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
<p class="description">Demo literal object</p>
<button name="run" id="run" >(Re)run</button>
<pre id="text-output"></pre>
<script type="module" src="literal-object.js"></script>
<p>
    Was passiert mit dem Objekt <code>v2</code> bzw. <code>v3</code>
    wenn Sie <code>v1.key1 = 13</code> nach der Schleife schreiben?
    (S. Sourcecode)
</p>
</body>
</html>
textbased-programms/literal-object.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    let v1 = undefined,
        v2 = undefined,
        v3 = undefined;
@@ -20,4 +20,7 @@
            case 2:{v3 = obj; break;}
        }
    }
    terminal.print(v1);
    terminal.print(v2);
    terminal.print(v3);
};
textbased-programms/loop-test.html
File was deleted
textbased-programms/loop-test.js
File was deleted
textbased-programms/luhn.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    let sumEvent = 0n;
    let sumOdd = 0n;
    let credit = argv[0];
@@ -20,10 +20,10 @@
        n = n/10n;
    }
    console.log({sumOdd, sumEvent});
    let sum =(sumEvent + sumOdd) % 10n;
    const sum =(sumEvent + sumOdd) % 10n;
    if (sum === 0n) {
        terminal.printl(`${credit} maybe OK`);
        terminal.printl(`${credit} may be a valid credit number`);
    } else {
        terminal.printl(`${credit} definitiv Wrong`);
        terminal.printl(`${credit} is not a valid credit number`);
    }
};
textbased-programms/monitor.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    // b:h als ratio, Bruch (numerator/denominator)
    const numerator = Number.parseFloat(argv[0]);
    const denominator = Number.parseFloat(argv[1]);
textbased-programms/new-program.py
@@ -45,7 +45,7 @@
import {{terminal}} from "./dfhi.js";
window.main = function(...argv) {{
window.main = (...argv) => {{
    terminal.print("{program}");
}};
"""
textbased-programms/newton-method-sqrt.html
@@ -8,9 +8,10 @@
</head>
<body>
<p class="description">Programm zum Testen der Implementierung von Newton-Verfahen. Klicken Sie auf dem „Ok“ Button um das Erebnis anzeigen zu lassen.
Das Programm akzeptiert keine Eingabe.</p>
<!--code>main</code>'s arguments: <input disabled="disabled" type="text" id="argv" name="argv" /-->
<p class="description">Programm zum Testen der Implementierung von Newton-Verfahren.
    Klicken Sie auf dem „Ok“ Button um das Erebnis anzeigen zu lassen.
    Das Programm akzeptiert keine Eingabe.
</p>
<button name="run" id="run" >Ok</button>
textbased-programms/newton-method-sqrt.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    const testData = [0, 1.25, 3.758, 4.229, 6.735, 123456.789, (1<<30) + 1];
    for(const c of testData) {
        const cquad = c*c;
@@ -15,7 +15,7 @@
    }
};
function sqrt(c) {
const sqrt = (c) => {
    const EPSILON = 1E-16;
    let xn = c;
    let q = c/xn; // auxiliary variable to avoid multiple division c/xn
textbased-programms/point-to-text.html
@@ -7,8 +7,9 @@
    <link rel="stylesheet" href="dfhi.css" />
</head>
<body>
<code>main</code>'s arguments: <input type="text" id="argv" name="argv" />
<p class="description">Zuordnung Punkten zu Leistung</p>
<label for="argv">Geben Sie die Punkte zwischen 0 und 100 ein!</label>
<input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
textbased-programms/point-to-text.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    let points = Number.parseFloat(argv[0]);
    if (points < 0) {
        terminal.printl("Kein gültiger Punkt");
textbased-programms/power-of-2-multi.html
@@ -7,8 +7,9 @@
    <link rel="stylesheet" href="dfhi.css" />
</head>
<body>
<code>main</code>'s arguments: <input type="text" id="argv" name="argv" />
<p class="description">Programm zum Berechnen 2^n</p>
<label for="argv">Geben Sie die Zahl n ein!</label>
<input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
textbased-programms/power-of-2-multi.js
@@ -5,8 +5,8 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
    let n = Number.parseInt(argv[0], 10);
window.main = (...argv) => {
    const n = Number.parseInt(argv[0], 10);
    let power = 1;
    let i = 0;
    while (i <= n) {
textbased-programms/power-of-2.html
@@ -8,7 +8,9 @@
</head>
<body>
<code>main</code>'s arguments: <input type="text" id="argv" name="argv" />
<p class="description">Programm zum Berechnen 2^n</p>
<label for="argv">Geben Sie die Zahl n ein!</label>
<input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
textbased-programms/power-of-2.js
@@ -5,8 +5,8 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
    let n = Number.parseInt(argv[0], 10);
window.main = (...argv) => {
    const n = Number.parseInt(argv[0], 10);
    let power = 1;
    let i = -1;
    while( ++i <= n) {
textbased-programms/prime-bigint-function.html
@@ -7,9 +7,10 @@
    <link rel="stylesheet" href="dfhi.css" />
</head>
<body>
<code>main</code>'s arguments: <input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
<p class="description">Primzahl test</p>
<label for="argv">Geben Sie eine natürliche Zahl ein!</label>
<input type="text" id="argv" name="argv" />
<button name="run" id="run" >OK</button>
<pre id="text-output"></pre>
textbased-programms/prime-bigint-function.js
@@ -8,9 +8,9 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
    let n = BigInt(argv[0]);
    let primeTest = isPrime(n);
window.main = (...argv) => {
    const n = BigInt(argv[0]);
    const primeTest = isPrime(n);
    if (primeTest) {
        terminal.printl(`${n} ist eine Primzahl`);
    } else {
@@ -18,7 +18,7 @@
    }
};
function isPrime(n) {
const isPrime = (n) => {
    let p = BigInt(n);
    if (p < 2n) {
        return false;
textbased-programms/prime-bigint.html
@@ -8,8 +8,10 @@
</head>
<body>
<code>Main Function</code>'s arguments: <input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
<p class="description">Primzahl test</p>
<label for="argv">Geben Sie eine natürliche Zahl ein!</label>
<input type="text" id="argv" name="argv" />
<button name="run" id="run" >OK</button>
<pre id="text-output"></pre>
textbased-programms/prime-bigint.js
@@ -5,9 +5,10 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
    let n = BigInt(argv[0]);
    for (var factor = 2n; factor <= n/factor; ++factor) { // factor is used after the for-loop, therefore var
window.main = (...argv) => {
    const n = BigInt(argv[0]);
    // factor is used after the for-loop, therefore var
    for (var factor = 2n; factor <= n/factor; ++factor) {
        if (n % factor === 0n) {
            break;
        }
textbased-programms/quadratic-equation.html
@@ -8,7 +8,7 @@
    <link rel="stylesheet" href="dfhi.css" />
</head>
<body>
<p class="description">Programm zum Lösen einer quadratischen Gleichung</p>
<label for="argv">Geben Sie die Parameter a, b, c einer quadratischen Gleichung, getrennt von Leerzeichen ein!
Zum Beispiel <code>1 -3 2</code><br/>
</label>
textbased-programms/quadratic-equation.js
@@ -5,14 +5,14 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
    let a = Number(argv[0]),
        b = Number(argv[1]),
        c = Number(argv[2]);
    let delta = b*b - 4*a*c;
    let d = Math.sqrt(delta);
    let x1 = (-b + d) / (2*a),
        x2 = (-b - d) / (2*a);
window.main = (...argv) => {
    const a = Number(argv[0]),
          b = Number(argv[1]),
          c = Number(argv[2]);
    const delta = b*b - 4*a*c;
    const d = Math.sqrt(delta);
    const x1 = (-b + d) / (2*a),
          x2 = (-b - d) / (2*a);
    
    terminal.printl(`Equation: ${a}x^2 + (${b})x + (${c})`);
    terminal.printl(`first solution: ${x1}`);
textbased-programms/taylor-serie-exp.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    const x = Number.parseFloat(argv[0]);
    const variant1 = exp1(x);
    const variant2 = exp2(x);
@@ -23,7 +23,7 @@
function exp1(x) {
const exp1 = (x) => {
    let sum = 1.0;
    const NUM_OF_TERM = 10;
    //DEBUG: let expression = "1";
@@ -41,7 +41,7 @@
    return sum;
}
function exp2(x) {
const exp2 = (x) => {
    let sum = 1.0;
    const NUM_OF_TERM = 1000;
    for(let n = 1; n <= NUM_OF_TERM; ++n){
@@ -54,7 +54,7 @@
    return sum;
}
function exp3(x) {
const exp3 = (x) => {
    let sum = 0.0,
        term = 1.0;
    for(let n = 1; sum !== sum + term; ++n) {
@@ -67,7 +67,7 @@
    return sum;
}
function exp4(x) {
const exp4 = (x) => {
    let sum = 0.0,
        term = 1.0;
    for(let i = 1; sum !== sum+term; ++i) {
textbased-programms/taylor-serie-trigonometry.js
@@ -5,8 +5,8 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
    //const x = Number.parseFloat(argv[0]);
window.main = (...argv) => {
    //const x = Number(argv[0]);
    //const x_rad = x * Math.PI / 180;
    const alpha = [0, 30, 45, 60, 90];
    alpha.map(x => x*Math.PI/180).forEach( a => {
@@ -17,13 +17,13 @@
};
function makeTest(testName, value, impl, ref) {
const makeTest = (testName, value, impl, ref) => {
    const result = impl(value);
    const expected = ref(value);
    terminal.print(`${testName} result: ${result} expected : ${expected}\n`);
}
function sin(x) {
const sin = (x) => {
    let sum = x;
    let term = -(x**3 / 6);
    const xsqr = x*x;
@@ -36,7 +36,7 @@
    return sum;
}
function cos(x) {
const cos = (x) => {
    let sum = 1;
    const xsqr = x*x;
    let g = 2;
textbased-programms/triangle-star.html
@@ -7,11 +7,13 @@
    <link rel="stylesheet" href="dfhi.css" />
</head>
<body>
<p class="description">Programm zum Ausgeben eines Dreiecks aus <code>*</code></p>
<p class="description">
    Geben Sie die Anzahl der Zeile ein (z.B. 6)!
</p>
<code>main</code>'s arguments: <input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
<pre id="text-output"></pre>
<script type="module" src="triangle-star.js"></script>
textbased-programms/triangle-star.js
@@ -5,7 +5,7 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
window.main = (...argv) => {
    let n = Number.parseInt(argv[0], 10);
    const character = "*",
        separator = " ";
textbased-programms/virus-expand.html
@@ -7,8 +7,11 @@
    <link rel="stylesheet" href="dfhi.css" />
</head>
<body>
<p class="description">(Passen Sie die Beschreibung des Programs hier an.)</p>
<label for="argv"><code>main</code>'s arguments:</label> <input type="text" id="argv" name="argv" />
<p class="description">
    Geben Sie die Anzahl der infizierten Rechner und die Verbreitungsrate ein!
</p>
<label for="argv"><code>main</code>'s arguments:</label>
<input type="text" id="argv" name="argv" />
<button name="run" id="run" >Rerun</button>
textbased-programms/virus-expand.js
@@ -5,9 +5,9 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
    let n = Number.parseInt(argv[0], 10);
    let k = Number.parseFloat(argv[1]);
window.main = (...argv) => {
    const n = Number.parseInt(argv[0], 10);
    const k = Number.parseFloat(argv[1]);
    terminal.printl(`n = ${n}`);
    terminal.printl(`k = ${k}`);
    terminal.printl("Min Fälle");