pub fn set_status_borsh(&mut self, #[serializer(borsh)] message: Vec<u8>) {}
To call this function you need to pass arguments borsh serialized, and those bytes encoded as base64
""" | |
Exploring bloom filters using counters instead of bit masks. | |
""" | |
from random import sample, seed, randint | |
from hashlib import md5 | |
from functools import partial | |
# TODO: Use more random & faster hash functions | |
def hash_md5(A, seed, mod): | |
l = list(md5(str(A + (seed << 10)).encode()).digest()) |
tot_val = 10000 | |
tot_per_shard = 200 | |
bad_ratio = .20 | |
rounds = 5000 | |
compromised_ratio = 1. / 3 | |
assert tot_val % tot_per_shard == 0 | |
bad = int(bad_ratio * tot_val) | |
good = tot_val - bad |
,id,date,user,problem,judgement,time,memory,size,lang,contest | |
0,375916,63,2017CNC045,A,Accepted,207.0,1000.0,0,C++11,1560 | |
1,375917,91,2017CNC022,A,Accepted,144.0,1000.0,0,C++11,1560 | |
2,375919,109,2017cnc2033,A,Accepted,138.0,1000.0,0,C++,1560 | |
3,375920,111,2017CNC024,A,Accepted,194.0,1000.0,0,C++11,1560 | |
4,375922,120,2017cnc2015,A,Accepted,134.0,1000.0,0,C++,1560 | |
5,375923,126,2017CNC047,A,Accepted,142.0,1000.0,0,C++11,1560 | |
6,375924,129,2017CNC100,A,Accepted,140.0,1000.0,0,C++11,1560 | |
7,375925,132,2017CNC069,A,Accepted,144.0,1000.0,0,C++11,1560 | |
8,375926,134,2017CNC021,A,Accepted,187.0,1000.0,0,C++,1560 |
#include <vector> | |
#include <iostream> | |
#include <map> | |
#include <random> | |
#include <numeric> | |
using namespace std; | |
mt19937 rng(0); |
def tPoS(tokens, seats): | |
lo, hi = 0, 1 | |
def get_seats(value): | |
total = 0 | |
for tok in tokens: | |
total += tok // value | |
return total | |
while get_seats(hi) >= seats: |
use borsh::{BorshDeserialize, BorshSerialize}; | |
use near_bindgen::{env, ext_contract, near_bindgen}; | |
use serde::{Deserialize, Serialize}; | |
#[global_allocator] | |
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; | |
#[ext_contract(ext)] | |
pub trait ExtCrossContract { | |
fn fork(&mut self); |
{ | |
"version": "0.2.0", | |
"configurations": [{ | |
"name": "Launch with lldb", | |
"type": "lldb", | |
"request": "launch", | |
"program": "${fileDirname}/attic/sol", | |
"args": ["${fileDirname}"], | |
"cwd": "${workspaceFolder}", | |
"stdio": ["${fileDirname}/testcases/0.in"], |
# %%% | |
import PIL.Image | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# %% | |
im = PIL.Image.open("panda.jpeg") | |
arr = np.array(im).mean(2) |
""" | |
https://twitter.com/bitshiftmask/status/1323809212875608066?s=20 | |
Let P(i, j) be the probability that if there are `i` devices, then after one | |
round `j` devices selected a unique number, so they are out. The expected | |
value of the number of rounds required so that each device selected a unique number is: | |
E(n) = p(n, n) * E(0) + p(n, n - 1) * E(1) + ... + p(n, 0) * E(n) | |
E(n) * (1 - p(n, 0)) = p(n, n) * E(0) + p(n, n - 1) * E(1) + ... |