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
// This will open up a prompt for text to send to a console session on digital ocean | |
// Useful for long passwords | |
(function () { | |
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split(""); | |
function f() { | |
var character = t.shift(); | |
var i=[]; | |
var code = character.charCodeAt(); | |
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1 |
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
fn main() { | |
let counts: Vec<_> = get_test_input().split("\n").map(|line| (code_count(line), char_count(line))).collect(); | |
let expected = vec![(2, 0), (5, 3), (10, 7), (6, 1)]; | |
assert_eq!(expected, counts); | |
let solution = get_test_input().split("\n").map(code_count).sum::<usize>() - | |
get_test_input().split("\n").map(char_count).sum::<usize>(); | |
assert_eq!(12, solution); | |
let solution = get_input().split("\n").map(code_count).sum::<usize>() - |
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
/* how to keep reference to string in struct with lifetime */ | |
fn main() { | |
let a = A::new("aaaasfd"); | |
println!("{:?}", a); | |
} | |
#[derive(Debug)] | |
struct A<'a> { | |
s: &'a str, |
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
use std::ops::Range; | |
fn map_mut<T, F>(arr: &mut [T], range: Range<usize>, f: F) | |
where | |
F: Fn(&T) -> T | |
{ | |
let slice = arr[range].iter_mut(); | |
for element in slice { | |
*element = f(element); |
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
use std::ops::Range; | |
fn map_mut<T, F>(arr: &mut [T], range: Range<usize>, f: F) | |
where | |
F: Fn(&T) -> T | |
{ | |
let slice = arr[range].iter_mut(); | |
for element in slice { | |
*element = f(element); |
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
# Author: Ole Kristian Pedersen | |
from turtle import * | |
from time import sleep | |
TEXT = """ | |
______ _ _ | |
| ___ \ | | | | | |
| |_/ / _| |_| |__ ___ _ __ | |
| __/ | | | __| '_ \ / _ \| '_ \\ |