Skip to content

Instantly share code, notes, and snippets.

View dionyziz's full-sized avatar
🐼

Dionysis Zindros dionyziz

🐼
View GitHub Profile
\usepackage{algorithm}
\usepackage{algpseudocode}
\def\chain{\mathcal{C}}
\newcommand{\true}{\textsf{true}}
\newcommand{\false}{\textsf{false}}
\begin{figure}[t]
\begin{algorithm}[H]
\caption{\label{alg.backbone} The backbone protocol}
const ADVERSARIAL_POWER = 0.49
const BLOCK_LIMIT = 500
const MONTE_CARLO = 10
function simulate() {
let honestBlocks = 1
let adversaryHeadStart = 0
let chainLength = 1
while (chainLength < BLOCK_LIMIT) {
import random
import matplotlib.pyplot as plt
import numpy as np
MONTE_CARLO_REPEAT = 30
TIME_INTERVAL = 100
def simulate(eta, Delta):
convergence_opportunities = 0
t = 0
class List {
static fromArray(arr) {
if (arr.length == 0) {
return new EmptyList()
}
return new FullList(
arr[0],
() => List.fromArray(arr.slice(1))
)
}
/*
This has a compile error:
test3.cpp:14:18: error: use of undeclared identifier 'a'
std::cout << a;
^
1 error generated.
*/
#include <iostream>
template<typename T>
#include <cstdio>
#include <iostream>
using namespace std;
class A {
public:
virtual int a() {
return 5;
}
import java.io.*;
import java.util.*;
public class Solution {
public static class A {
}
public static class B extends A {
total pressure
|
| /\
| |^^|
v |{}| <--- static pressure
_______________/~~\________________
/ | | \
`========--------. .---------========'
# testcase 1, expected output 68719476736
mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
mem[42] = 1
# testcase 2, expected output 0
mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
mem[0] = 1
mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX0
mem[0] = 0
mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX0X
with open('in.txt') as f:
_, buses = f.read().splitlines()
def iterative_crt(a1, n1, a2, n2):
return pow(n1, -1, n2) * (a2 - a1) * n1 + a1
residues = 0
moduli = 1
for i, bus in enumerate(buses.split(',')):
if bus != 'x':