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 collections import defaultdict | |
from itertools import permutations | |
from pprint import pprint | |
# this is going to calculate the output of the game | |
# the number of colors guessed correctly and the number of | |
# colors placed correctly | |
def calculate_score(correct, guess): | |
correct_colors = sum(1 for color in guess if color in correct) | |
correct_place = sum(1 for (a, b) in zip(correct, guess) if a == b) | |
return (correct_colors - correct_place, correct_place) |
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
# http://www.russinoff.com/papers/pratt.pdf | |
import math | |
number = 2**255 - 19 | |
certificate = [2, | |
[2, 3, 65147, 74058212732561358302231226437062788676166966415465897661863160754340907], | |
[2, 1, 1, 1], | |
[[], [], [], | |
[2, |
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
IEnumerable<int> GeneratePagination(int currentPage, int pageCount) { | |
var itemsAroundCurrent = 1; | |
var itemsAtEnds = 1; | |
var minimumSkip = 2; | |
var pagesOnScreen = (itemsAtEnds + minimumSkip + itemsAroundCurrent - 1) * 2 + 1; | |
if (pageCount <= pagesOnScreen) { | |
return Enumerable.Range(1, pagesOnScreen); | |
} | |
var skipEdge = itemsAtEnds + minimumSkip; |
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
// http://hewo.xedoloh.com/2015/04/base-256/ | |
const BASE_START = "bghjklnpqrstvwyz"; | |
const BASE_MID = "aeio"; | |
const BASE_END = "cdfm"; | |
const b256_encode = (source) => { | |
let buffer = ''; | |
for (let byte of source) { | |
buffer += BASE_START[(byte >> 4)]; | |
buffer += BASE_MID[((byte >> 2) & 0b11)]; |
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
fn swap_ranges_copy(vec: &mut [u8], offset1: usize, offset2: usize, len: usize) { | |
let tmp = vec.to_vec(); | |
vec[offset1..offset1+len].copy_from_slice(&tmp[offset2..offset2+len]); | |
vec[offset2..offset2+len].copy_from_slice(&tmp[offset1..offset1+len]); | |
} | |
fn swap_ranges(vec: &mut [u8], mut offset1: usize, mut offset2: usize, mut len: usize) { | |
if offset1 < offset2 && offset1 + len >= offset2 { | |
// The ranges have the following layout here: | |
// [o1--------] |
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
ZERO = (lambda hf: (lambda ax: ax)) | |
TWENTY_SIX = lambda vf: lambda vx: \ | |
vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vf(vx)))))))))))))))))))))))))) | |
INCREMENT = (lambda jnum: lambda jf: lambda jx: jf(jnum(jf)(jx))) | |
Z_COMBINATOR = (lambda gf: | |
((lambda gx: gf(lambda gy: gx(gx)(gy))) | |
(lambda gx: gf(lambda gy: gx(gx)(gy))))) | |
TRUE = (lambda bx: lambda by: bx) |
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
macro_rules! field_offset { | |
($ty:path, $field:ident$(.$cfield:ident)*) => { | |
unsafe { | |
union Transmuter<T: 'static> { | |
p: *const T, | |
r: &'static T, | |
i: usize, | |
} | |
let base = Transmuter::<$ty> { | |
p: core::ptr::NonNull::dangling().as_ptr(), |
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
all: | |
rustc -O -Clto=fat -Cpanic=abort --crate-type=staticlib --emit=obj shellcode.rs -o shellcode.obj | |
cl.exe /Zi /nologo test.c shellcode.obj | |
test.exe |
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
/// Construct a circle from three tangent points. | |
/// | |
/// Returns `None` if there is no unique solution. This happens when | |
/// the triangle formed by three points has zero area. | |
/// | |
/// The algorithm goes as follows: | |
/// Construct two segment bisectors, defined parametrically: | |
/// | |
/// Bisector for segment `ab`: | |
/// mid_ab + t * norm_ab = p, where t \in Real |
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
var page=1 | |
var c = copy | |
fetch("https://www.intel.com/libs/apps/intel/services/dynamicProductCardForIntelProducts.json", {"credentials":"include","headers":{"accept":"*/*","accept-language":"en-US,en;q=0.9,ru;q=0.8","content-type":"application/x-www-form-urlencoded; charset=UTF-8","csrf-token":"undefined","sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin","x-requested-with":"XMLHttpRequest"},"referrer":"https://www.intel.com/content/www/us/en/products/processors/xeon/view-all.html","referrerPolicy":"no-referrer-when-downgrade","body":`epmId=&language=en&location=us&tagPath=rmarketingproducts%3Aprocessors%2Fintelxeonprocessors&category=processors¤tPagePath=%2Fcontent%2Fwww%2Fus%2Fen%2Fproducts%2Fprocessors%2Fxeon%2Fview-all&Intel+Technology=All&Processor+Type=All&boundaryCache=3072%2C78848&Cache=3072%2C78848&boundaryClockSpeed=1100%2C4100&ClockSpeed=1100%2C4100&boundaryCoreCount=2%2C56&CoreCount=2%2C56&rangePrice=59.66%2C15749.99&price=59.66%2C15749.99&sortBy=release_date&acti |