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
| \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} |
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 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) { |
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 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 |
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
| class List { | |
| static fromArray(arr) { | |
| if (arr.length == 0) { | |
| return new EmptyList() | |
| } | |
| return new FullList( | |
| arr[0], | |
| () => List.fromArray(arr.slice(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
| /* | |
| 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> |
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 <cstdio> | |
| #include <iostream> | |
| using namespace std; | |
| class A { | |
| public: | |
| virtual int a() { | |
| return 5; | |
| } |
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 java.io.*; | |
| import java.util.*; | |
| public class Solution { | |
| public static class A { | |
| } | |
| public static class B extends A { | |
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
| total pressure | |
| | | |
| | /\ | |
| | |^^| | |
| v |{}| <--- static pressure | |
| _______________/~~\________________ | |
| / | | \ | |
| `========--------. .---------========' |
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
| # 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 |
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
| 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': |
NewerOlder