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 <errno.h> | |
#include <iconv.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
void print_bytes(const char* prefix, const char* str, size_t len); | |
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
#!/usr/bin/env python3 | |
"""Generate random strings from the template at xkcd.com/1930/.""" | |
import random | |
import re | |
from collections import namedtuple | |
XKCD_STRING = '''\ | |
Did you know that (the (fall|spring) equinox|the (summer|winter) solstice|the (Summer|Winter) | |
Olympics|the (earliest|latest) (sunrise|sunset)|Daylight (Saving|Savings) Time|leap (day|year)| |
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
"""A simple implementation of a recursive-descent parser for a language of boolean expressions.""" | |
import readline | |
def eval_str(expr): | |
"""Evaluate a boolean expression with the symbols '0', '1', '|', '&', '(' and ')'. All binary | |
operators must be wrapped in parentheses, even when it would be unambiguous to omit them. | |
""" | |
tokens = tokenize(expr) | |
ast = match_expr(tokens) |
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
"""A simple example of multiprocessing for a CPU-bound task in Python. | |
Adapted from https://www.toptal.com/python/beginners-guide-to-concurrency-and-parallelism-in-python | |
""" | |
from multiprocessing.pool import Pool | |
import time | |
def fib(n): | |
"""A (contrived) example of a CPU-intensive function that you may want to parallelize.""" |
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 <cstdlib> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include "rational_number.h" | |
#define GIVEN_NUMBERS 4 | |
#define DEFAULT_TARGET 24 | |
using namespace std; |
NewerOlder