This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Data = number[] | |
| type Observation = number | |
| type Prediction = Observation | |
| function learn(xs: Data[], ys: Observation[]) { | |
| return (x: Data): Prediction => { | |
| // use xs and ys to predict outcome of x | |
| return 1 | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as tf from '@tensorflow/tfjs' | |
| /* | |
| * Experiment with | |
| * - multiplication, combined (ie x1+3*x2). May have to train 500 epochs to get satisfactory results. | |
| */ | |
| const randomInt = (max: number) => | |
| Math.floor(Math.random() * Math.floor(max)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package algorithms.shortestpath | |
| interface Node | |
| data class Edge(val node1: Node, val node2: Node, val distance: Int) | |
| /** | |
| * See https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm | |
| */ | |
| fun findShortestPath(edges: List<Edge>, source: Node, target: Node): ShortestPathResult { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package foo | |
| fun <T> permutations(list: List<T>): List<List<T>> = when { | |
| list.size > 10 -> throw Exception("You probably dont have enough memory to keep all those permutations") | |
| list.size <= 1 -> listOf(list) | |
| else -> | |
| permute(list.drop(1)).map { perm -> | |
| (list.indices).map { i -> | |
| perm.subList(0, i) + list.first() + perm.drop(i) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Smcn | |
| # ============= | |
| if [ $# -eq 0 ]; then | |
| echo "Enter date and module, ex 20-05-2021-modul-6" | |
| exit | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """ | |
| Very simple HTTP server in python for logging requests | |
| Usage:: | |
| ./server.py [<port>] | |
| """ | |
| from http.server import BaseHTTPRequestHandler, HTTPServer | |
| import logging | |
| import json |
OlderNewer