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 os | |
def words(n): | |
if n >= 1000: | |
return words(n // 1000) + " thousand " + words(n % 1000) | |
elif n >= 100: | |
return words(n // 100) + " hundred " + words(n % 100) | |
elif n >= 20: | |
tens = [ |
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
#!/bin/bash | |
slashes=$(sed 's/\([\/\\]\)/\1/g' <<< "$1") | |
while [ -n "$slashes" ]; do | |
slash=$(cut -c1 <<< "$slashes") | |
case "$slash" in | |
" ") | |
slashes=$(cut -c2- <<< "$slashes"); | |
if [ "$(cut -c1 <<< "$slashes")" != "/" ]; then | |
echo -n "$slash" |
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 <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
char randascii() { | |
while (true) { | |
char r = rand() & 0x7f; | |
if (r >= 0x20 && r <= 0x7e) { | |
return r; |
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 <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char **argv) { | |
int number_of_doors = atoi(argv[1]); | |
int number_of_passes = atoi(argv[2]); | |
int open_doors = 0; | |
for (int i = 1; i <= number_of_doors; i++) { | |
int toggles = 0; |
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 <stdbool.h> | |
#include <stdio.h> | |
typedef bool (*gen_f)(size_t *i); | |
gen_f from_to(size_t from, size_t to) { | |
size_t i = from; | |
bool g(size_t * j) { | |
if (i <= to) { |
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 <stdbool.h> | |
#include <stdio.h> | |
int main(int argc, char **argv) { | |
int length, maxlength, stacksize; | |
length = maxlength = stacksize = 0; | |
while (true) { | |
int c; |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
typedef struct node { | |
int val; | |
struct node *next; | |
struct node *random; | |
} node; |
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 <stdio.h> | |
int count_letters(char *str, char *word) { | |
char c; | |
int letters = 0; | |
while ((c = *str++) && *word) { | |
if (c == *word) { | |
letters++; | |
word++; |
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 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( |
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 <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; |
NewerOlder