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.util.Arrays; | |
import java.util.Collection; | |
import java.util.List; | |
public class Main { | |
public static void main(String[] args) { | |
List<List<Integer>> nested = Arrays.asList( | |
Arrays.asList(1, 2, 3), | |
Arrays.asList(4, 5, 6), | |
Arrays.asList(7, 8, 9) |
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
#!python | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.patches as mpatches | |
def pi(x): | |
prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541] | |
assert x <= prime[-1] | |
i = 0 | |
while prime[i] < x: |
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.util.Map; | |
import java.util.TreeMap; | |
import java.util.SortedMap; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
import java.math.BigInteger; | |
import java.io.UnsupportedEncodingException; | |
public class ConsistentHash { | |
private static int MAX_REPLICA = 100; |
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
def caesar_enc(plain, key): | |
plain = plain.encode('utf-8') | |
cipher = bytearray(plain) | |
for i, c in enumerate(plain): | |
cipher[i] = (c + key) & 0xff | |
return bytes(cipher) | |
def caesar_dec(cipher, key): | |
plain = bytearray(len(cipher)) # at most, len(plain) <= len(cipher) | |
for i, c in enumerate(cipher): |
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 <gl/glew.h> | |
#include <string> | |
void GLAPIENTRY DebugMessageCallback(GLenum source, | |
GLenum type, | |
GLuint id, | |
GLenum severity, | |
GLsizei length, | |
const GLchar* message, | |
const void* userParam) |
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 <stdlib.h> | |
#include <time.h> | |
#include <stdio.h> | |
#include <assert.h> | |
#include <stdbool.h> | |
typedef struct { | |
size_t rows; | |
size_t columns; |
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
def compute_ean13_checksum(barcode): | |
assert len(barcode) == 12 and barcode.isdigit() | |
return (10 - sum(int(i) * j for i, j in zip(barcode, (1, 3) * 6)) % 10) % 10 |
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.ByteArrayInputStream | |
import java.io.InputStream | |
import java.io.PrintStream | |
import java.util.* | |
import java.util.concurrent.Callable | |
enum class Token constructor(val symbol: String) { | |
IF("if"), | |
ELSE("else"), |
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
# CMakeLists.txt | |
cmake_minimum_required(VERSION 3.0) | |
project(example) | |
set(CMAKE_CXX_STANDARD 11) | |
find_package(SDL2 REQUIRED) | |
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | |
set(CMAKE_COMPILER_IS_CLANGCXX 1) | |
endif () |
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
ASCII_A_CODE = ord('A') | |
def ascii_upper_encode(data): | |
code = '' | |
for byte in data: | |
code += chr((byte >> 4) + ASCII_A_CODE) | |
code += chr((byte & 0xf) + ASCII_A_CODE) | |
return code | |
def ascii_upper_decode(code): |
OlderNewer