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 java.util.Iterator; | |
import java.math.BigInteger; | |
class Main { | |
public static Iterable<BigInteger> fibonacci(final long N) { | |
return () -> new Iterator<BigInteger>() { | |
private long cursor = 0; | |
private BigInteger a = BigInteger.ZERO, | |
b = BigInteger.ONE; | |
public boolean hasNext() { |
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
from random import randrange | |
def miller_rabin(n, k): | |
if n == 2 or n == 3: | |
return True | |
if n < 2 or ~n & 1: | |
return False | |
s, d = 0, n - 1 | |
while ~d & 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <assert.h> | |
#include <math.h> | |
#include <poll.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <errno.h> | |
#include <getopt.h> |
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
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct | |
{ | |
char *text; | |
size_t len; | |
} filedata_t; | |
filedata_t * |
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
#include <iostream> | |
#include <string> | |
class Node | |
{ | |
friend class LinkedList; | |
private: | |
Node* _next; | |
std::string _data; | |
public: |
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
#include <iostream> | |
#include <sstream> | |
#include <fstream> | |
int main() { | |
std::string data = static_cast<std::ostringstream&> | |
( std::ostringstream() << std::ifstream("data.txt").rdbuf() ).str(); | |
std::cout << data << std::endl; | |
} |
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
#ifndef LOG_H | |
#define LOG_H | |
#include <iostream> | |
#include <iomanip> | |
#include <sstream> | |
#include <cctype> | |
template <typename T> | |
struct TYPE; |
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
#include <string> | |
#include <iostream> | |
#include <time.h> | |
using namespace std; | |
/***************************** Person Class **********************************/ | |
class Person | |
{ |
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
.intel_syntax noprefix | |
.globl fib | |
fib: | |
sub rsp, 24 | |
xor eax, eax | |
mov ecx, 1 | |
0: | |
xadd rax, rcx |
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
#include <stdio.h> | |
#include <stdlib.h> | |
static struct { | |
size_t buffer_size; | |
char *buffer, *ptr; | |
} bf; | |
void bf_init(size_t initial_cap) { | |
bf.buffer_size = initial_cap; |