Command-line utility that transcribes a number to the mayan numeral system. Other implementations
Compile the program with: rustc maya.rs
.
Then run ./maya 2017
function exec(a,b){ | |
let pgm = document.body.innerText.split(',').map(x=>parseInt(x)); | |
pgm[1] = a; pgm[2] = b; | |
for(let p=0; ; p+= 4){ | |
if(pgm[p]==1) pgm[pgm[p+3]] = pgm[pgm[p+1]] + pgm[pgm[p+2]]; | |
else if(pgm[p]==2) pgm[pgm[p+3]] = pgm[pgm[p+1]] * pgm[pgm[p+2]]; | |
else if(pgm[p]==99) break; | |
else throw new Error("invalid opcode "+pgm[p]); | |
} | |
return pgm[0]; |
#!/usr/bin/env python3 | |
import random | |
SECRET = ''.join(random.choice("0123456789") for i in range(64)) | |
class Sandbox: | |
def ask_age(self): | |
self.age = input("How old are you ? ") | |
self.width = input("How wide do you want the nice box to be ? ") |
-- Run online at: https://repl.it/repls/WeeSlightExams | |
-- hackernews thread: https://news.ycombinator.com/item?id=21543377 | |
solve funcs = filter (matches funcs) (possibilities funcs) | |
matches funcs truths = truths == zipWith (($).($truths).flip) funcs [0..] | |
possibilities [] = [[]] | |
possibilities (x:xs) = concatMap (sequence [(True:), (False:)]) (possibilities xs) | |
all_of = ((and.).) | |
one_of = ((or.).) |
function get_tile_counts(width, height, tile_width, tile_height, numtiles) { | |
var level_count = 0, level_widths=[], level_heights=[], level_tile_count=[], level_tile_count_x=[], level_tile_count_y=[]; | |
var imageW = width; | |
var imageH = height; | |
var tileWidth = tile_width; | |
var tileHeight = tile_height; | |
width = imageW; | |
height = imageH; | |
while (width > tileWidth || height > tileHeight) { |
/* | |
compile with: | |
rustc -C target-cpu=native -C opt-level=3 -C inline-threshold=1 -O mul_add.rs | |
*/ | |
use std::env; | |
fn main(){ | |
use std::time::{Instant}; | |
let args: Vec<String> = env::args().collect(); | |
let n=args[1].parse::<usize>().unwrap(); |
/*** | |
Tower of Hanoi solver. | |
https://en.wikipedia.org/wiki/Tower_of_Hanoi | |
Example : | |
``` | |
$ rustc hanoi.rs | |
$ ./hanoi 3 |
Command-line utility that transcribes a number to the mayan numeral system. Other implementations
Compile the program with: rustc maya.rs
.
Then run ./maya 2017
pub fn decrypt(mut input_buf: Vec<u8>) -> Result<Vec<u8>, InvalidEncryptedImage> { | |
if get_int(&input_buf, 0) != 0x0A_0A_0A_0A { return Ok(input_buf); } | |
let header_size = get_int(&input_buf, input_buf.len() as u32 - 4); | |
let encrypted_size_pos = header_size + 4; | |
let encrypted_pos = encrypted_size_pos + 4; | |
let encrypted_size = get_int(&input_buf, encrypted_size_pos); | |
let encrypted_end_pos = encrypted_pos + encrypted_size; | |
let footer_size = input_buf.len() as u32 - 4 - encrypted_end_pos; | |
let encrypted = input_buf.get(encrypted_pos as usize..(encrypted_pos + encrypted_size) as usize).unwrap(); | |
let mut encrypted_copy = Vec::from(encrypted); |
def test(client, n): | |
"""Stupid test function""" | |
q = f"SELECT * FROM test LIMIT {n}" | |
client.query(q) | |
setup = """ | |
from __main__ import test | |
from influxdb import InfluxDBClient |
html, body { | |
font-family: sans-serif; | |
margin: 0; | |
padding: 0; | |
font-size: 16px; | |
} | |
header > nav{ | |
display: flex; | |
border: 1px solid black; |