Skip to content

Instantly share code, notes, and snippets.

View list_deepcopy.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct node {
int val;
struct node *next;
struct node *random;
} node;
View longestword.c
#include <stdio.h>
int count_letters(char *str, char *word) {
char c;
int letters = 0;
while ((c = *str++) && *word) {
if (c == *word) {
letters++;
word++;
@zoeisnowooze
zoeisnowooze / longtext.py
Last active Jun 14, 2022
Loooooong teeeeeext
View longtext.py
import argparse
import shutil
import subprocess
def main():
parser = argparse.ArgumentParser(description="Multiplies the vowels.")
parser.add_argument("string", metavar="STRING", type=str, help="a string")
parser.add_argument("n", metavar="N", type=int, help="an integer")
parser.add_argument(
View coin_combo.c
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define DEBUG 0
#define IMPOSSIBLE (INT_MAX >> 1)
int main(int argc, char **argv) {
int num_coins, amount;
@zoeisnowooze
zoeisnowooze / main.rs
Created Feb 21, 2022
longest-sub-seq
View main.rs
use std::env;
use std::ops::RangeInclusive;
trait RangeInclusiveExt {
fn len(&self) -> usize;
}
impl RangeInclusiveExt for RangeInclusive<usize> {
fn len(&self) -> usize {
*self.end() - *self.start() + 1
View case_permutations.rs
pub fn case_permutations(s: String) -> Vec<String> {
let mut stack: Vec<String> = vec![String::with_capacity(s.capacity())];
for c in s.chars() {
if c.is_ascii_alphabetic() {
let mut new_stack: Vec<String> = vec![];
for p in stack {
let mut lower = p.clone();
lower.push(c.to_ascii_lowercase());
new_stack.push(lower);
View phone_letter.rs
#![allow(unused)]
extern crate itertools;
use itertools::Itertools;
fn phone_letter(number: &str) -> Vec<String> {
number
.chars()
.filter_map(|digit| match digit {
'2' => Some(vec!['a', 'b', 'c']),
View group_anagrams.c
#include <stdio.h>
#include <stdlib.h>
static int FACTORS[] = {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};
struct map_entry {
int sort_key;
int arg_index;
};
View scan_secrets.js
const fs = require("fs");
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default;
PATTERNS = [
/BEGIN ((EC|PGP|DSA|RSA|OPENSSH) )?PRIVATE KEY/,
/AIza[A-Za-z0-9_-]{35}/,
/sk_live_[A-Za-z0-9]{24}/,
];
@zoeisnowooze
zoeisnowooze / peaks.rs
Last active Nov 10, 2021 — forked from rust-play/playground.rs
Code shared from the Rust Playground
View peaks.rs
#![allow(unused)]
fn peaks<T: std::cmp::PartialOrd>(values: Vec<T>) -> Vec<usize> {
values
.windows(3)
.enumerate()
.filter_map(|(i, window)| {
if window[0] < window[1] && window[1] > window[2] {
Some(i + 1)
} else {