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 numpy | |
from numpy.linalg import norm | |
import math | |
earth_radius = 6.3781e6 | |
gravity = 9.81 | |
def lla2cart(lat, long, alt=earth_radius): | |
lat, long = math.radians(lat), math.radians(long) | |
x = math.cos(long) * math.cos(lat) |
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
SETUP=" | |
import sys | |
from itertools import compress | |
def vprimes(maximum=10**6): | |
maxidx = maximum//2 | |
sieve = [True] * maxidx # 2, 3, 5, 7... might be prime | |
j = 0 | |
for i in range(1, int(maxidx**0.5)+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
input: output: | |
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ | |
┃▓▓▓▓▓▓▓▓▓ ▓▓ ▓ ▓▓ ▓▓ ▓┃ ┃ ▓▓▓▓ ▓▓ ┃ | |
┃ ▓ ▓▓ ▓▓ ▓ ▓▓▓ ▓▓ ▓ ▓ ▓▓▓▓┃ ┃ ▓▓▓▓ ▓▓▓ ▓▓▓ ▓▓ ▓▓ ┃ | |
┃▓▓ ▓▓▓ ▓▓▓ ▓ ▓▓▓ ▓▓▓ ▓ ▓ ▓ ┃ ┃ ▓▓▓▓ ▓▓▓ ▓▓▓ ▓▓ ▓▓ ┃ | |
┃▓ ▓ ▓▓ ▓▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓ ▓┃ ┃ ▓▓▓ ░░ ▓▓▓▓▓ ┃ | |
┃ ▓▓ ▓▓▓▓ ▓▓ ▓ ▓ ▓ ▓▓▓▓▓▓┃ ┃ ▓▓▓▓ ░░ ▓▓▓▓▓▓┃ | |
┃ ▓ ▓ ▓ ▓▓ ▓ ▓▓ ▓▓▓▓ ▓ ▓▓ ▓┃ ┃ ▓▓▓▓▓▓ ▓▓▓ ▓▓▓▓▓▓┃ | |
┃ ▓▓ ▓▓ ▓▓ ▓ ▓ ▓▓▓ ▓ ▓ ▓┃ ┃ ▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓┃ | |
┃ ▓ ▓▓▓ ▓▓▓ ▓▓▓▓▓▓▓ ▓ ▓▓ ▓▓ ▓┃ ┃ ▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓┃ |
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
const char DIGIT_PAIRS[] = | |
"00" "01" "02" "03" "04" "05" "06" "07" "08" "09" | |
"10" "11" "12" "13" "14" "15" "16" "17" "18" "19" | |
"20" "21" "22" "23" "24" "25" "26" "27" "28" "29" | |
"30" "31" "32" "33" "34" "35" "36" "37" "38" "39" | |
"40" "41" "42" "43" "44" "45" "46" "47" "48" "49" | |
"50" "51" "52" "53" "54" "55" "56" "57" "58" "59" | |
"60" "61" "62" "63" "64" "65" "66" "67" "68" "69" | |
"70" "71" "72" "73" "74" "75" "76" "77" "78" "79" | |
"80" "81" "82" "83" "84" "85" "86" "87" "88" "89" |
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 <iterator> | |
#include <numeric> | |
#include <unordered_set> | |
#include <vector> | |
int32_t some_calculations(int32_t number) { | |
std::vector<int32_t> a; | |
std::unordered_set<int32_t> s; |
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
pub trait InternalIterator { | |
type Item; | |
fn each<F>(&mut self, mut f: F) -> bool | |
where F: FnMut(Self::Item) -> bool; | |
} | |
impl<I> InternalIterator for I | |
where I: Iterator, | |
{ | |
type Item = I::Item; |
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
def genPrimes(n): | |
found = [] | |
found_lo = [] | |
for x in range(2,n+1): | |
yas = True | |
for y in found_lo: | |
if x%y == 0: | |
yas = False | |
break | |
if yas: |
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
// ==UserScript== | |
// @name Sufficient Velocity User Filter | |
// @version 1.0 | |
// @description Restyle the page and allow selective ignore of specific threads | |
// @author Veedrac | |
// @match https://forums.sufficientvelocity.com/* | |
// @exclude https://forums.sufficientvelocity.com/watched/threads | |
// @run-at document-start | |
// @grant none | |
// ==/UserScript== |
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 <stdlib.h> | |
#include <iostream> | |
#include <memory> | |
class Tree { | |
std::unique_ptr<Tree> left; | |
std::unique_ptr<Tree> right; | |
public: | |
Tree(int depth) { |
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 itertools import combinations, combinations_with_replacement, product | |
need = 43, 25, 20, 16, 15, 13, 12, 12, 11, 10, 10, 8, 8, 4, 4, 3, 3, 1, 1, 1, 1 | |
def is_ok(pred): | |
# This is equivalent to the naïve Counter-based method, but | |
# optimized to be fast on PyPy. | |
counts = [0] * 256 | |
for tok in range(256): |
NewerOlder