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
const std = @import("std"); | |
const builtin = @import("builtin"); | |
pub fn main() !void { | |
const n = 20; | |
var idx : [n]u8 = undefined; | |
for (&idx, 0..) |*id, i| { | |
id.* = @intCast(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
#include <stdio.h> | |
#include <stdlib.h> | |
struct Node{ | |
struct Node *parent; | |
struct Node *left; | |
struct Node *right; | |
int index; | |
int value; | |
}; |
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 math | |
class SegmentTree: | |
def __init__(self, arr, function, neutral_element): | |
self.m = len(arr) | |
k = math.ceil(math.log2(self.m)) + 1 | |
self.n = 2**k | |
self.arr = arr | |
self.tree = [neutral_element for _ in range(self.n)] | |
self.foo = function | |
self.neutral_element = neutral_element |
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
# strongly inspired from https://hkeylocalmachine.com/?p=518 | |
$listener = New-Object System.Net.HttpListener | |
$listener.Prefixes.Add('http://+:8000/') | |
$listener.Start() | |
while ($true){ | |
$context = $listener.GetContext() |
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
function foo(n::UInt) | |
if n == 1 || n == 0 | |
return n | |
end | |
if n%2 == 0 | |
return 4 * foo(UInt(n/2)) | |
else | |
return 4 * foo(UInt(floor(n/2))) + 1 | |
end | |
end |
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
\documentclass[12pt,a4paper]{scrartcl} | |
\usepackage[utf8]{inputenc} | |
\usepackage[ngerman]{babel} | |
\usepackage{listings} | |
\usepackage{amsmath,amssymb,amstext,amsthm} | |
\usepackage{tikz} | |
\usepackage{hyperref} | |
\usepackage{url} | |
\usepackage[headsepline]{scrpage2} |
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
"Hallo Welt!" | Select-String ".* (.*)" | ForEach-Object {$_.Matches.Groups[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
func consoleSize() (int, int) { | |
cmd := exec.Command("stty", "size") | |
cmd.Stdin = os.Stdin | |
out, err := cmd.Output() | |
if err != nil { | |
log.Fatal(err) | |
} | |
s := string(out) |
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 main | |
import ( | |
"fmt" | |
"encoding/json" | |
) | |
func main() { | |
dict := make(map[int]string) | |
dict[12] = "Lukas" |
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
def polynomial(degree): | |
def poly(x): | |
return np.asarray([x**g for g in range(degree)]).reshape((degree, x.shape[0])).transpose() | |
return poly |
NewerOlder