This file contains 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 -S deno run --allow-env --allow-ffi | |
import { DB } from "https://deno.land/x/sqlite/mod.ts"; | |
const schema = ` | |
CREATE TABLE IF NOT EXISTS User ( | |
id INTEGER PRIMARY KEY AUTOINCREMENT, | |
username TEXT | |
); | |
CREATE TABLE IF NOT EXISTS Wallet ( |
This file contains 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 permutations(lis): | |
N = len(lis) | |
i = 0 | |
c = [*range(0, max(2,N+1))] | |
while True: | |
yield lis | |
i = 1 | |
while c[i] == 0: | |
c[i] = i | |
i += 1 |
This file contains 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 asyncdispatch | |
import deques | |
import options | |
import httpclient | |
import strformat | |
export httpclient # for AsyncResponse | |
#[ | |
Wrapping AsyncHttpClient for pooling and timeout, also see |
This file contains 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
you are a zoo keeper, You wanna keep animals to be healthy (not overweight) so you apply a diet plan. | |
Problem: | |
An animal has intial weight S at the start, For every day, you can choose to lose weight (a[i]) or have food (b[i]) or , but you have to make sure every day animal doesnt exceed T (target weight) | |
for N days plan, how many possbile combinations can have | |
condition | |
・1 ≦ N ≦ 35 | |
・1 ≦ Ai, Bi ≦ 1,000,000,000 (1 ≦ i ≦ N) | |
・(sum of A_i) < S ≦ T ≦ 1,000,000,000 | |
sample in | |
2 10 20 |
This file contains 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
proc fletcher16*(arr: openArray[uint8]): uint16 = | |
var | |
c1: int = 0 | |
c2: int = 0 | |
for d in arr: | |
c1 += d.int | |
c2 += c1 | |
result = (((c2 mod 255) shl 8) + (c1 mod 255)).uint16 | |
This file contains 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
<?php | |
/** | |
* LDAP PHP Change Password Webpage | |
* | |
* Copyright (C) 2010 Matt Rude <http://mattrude.com> | |
* Copyright (C) 2019 Jack Tang <[email protected]> | |
* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by |
This file contains 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 util | |
import ( | |
"time" | |
) | |
<?php | |
$className = "StringMap"; | |
$arr = [ | |
"Bool" => "bool", |
This file contains 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
There is a colony of 8 cells arranged in a straight line where each day every cell competes with its adjacent cells(neighbour). Each day, for each cell, if its neighbours are both active or both inactive, the cell becomes inactive the next day,. otherwise itbecomes active the next day. | |
Assumptions: The two cells on the ends have single adjacent cell, so the other adjacent cell can be assumsed to be always inactive. Even after updating the cell state. consider its pervious state for updating the state of other cells. Update the cell informationof allcells simultaneously. | |
Write a fuction cellCompete which takes takes one 8 element array of integers cells representing the current state of 8 cells and one integer days representing te number of days to simulate. An integer value of 1 represents an active cell and value of 0 represents an inactive cell. |
This file contains 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
#define FOR(i, n) for (i = 0;i < n;++i) | |
#define sv static void | |
typedef unsigned char u8; | |
typedef unsigned long u32; | |
typedef unsigned long long u64; | |
typedef long long i64; | |
typedef i64 gf[16]; // 1024-bit = 128 bytes | |
static const gf _121665 = {0xDB41, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
This file contains 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 cluster = require('cluster') | |
const N = 8 | |
if(cluster.isMaster){ | |
let workers = {} | |
let globals = [] | |
for(let i=0; i<N; i++) workers[i] = cluster.fork({id: i}); | |
cluster.on('message', (worker, {message, timestamp, to}) => { | |
globals.push({timestamp, message}) | |
globals.sort(function(x,y){ |
NewerOlder