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
# 12 MHz clock | |
set_io -nowarn CLK 35 | |
# RS232 | |
set_io -nowarn RX 6 | |
set_io -nowarn TX 9 | |
# LEDs and Button | |
set_io -nowarn BTN_N 10 | |
set_io -nowarn LEDR_N 11 |
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
`default_nettype none | |
`define W 24 | |
module top ( | |
input CLK, | |
output LED1, | |
output LED2, | |
output LED3, | |
output LED4, |
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
// BEGIN kbob | |
// This is identical to https://vulkan-tutorial.com/Drawing_a_triangle/Swap_chain_recreation | |
// as of 2018-06-13 except for code between the "BEGIN kbob" and "END kbob" comments. | |
// The original code is still there but commented out with "//-". | |
// | |
// Built with MoltenVK 1.1.73 and GLFW 20180519 for MacOS, the original never recreated | |
// the swap chain. It continued to draw at the original 800 by 600 resolution and scaled | |
// the result to fit the resized window. | |
// | |
// Also, according to GLFW doc, the glfwGetWindowSize() is not the right function to call. |
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
#define EXPECT | |
#include <assert.h> | |
#include <math.h> | |
#include <stdbool.h> | |
#include <stddef.h> | |
#include <stdio.h> |
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 <assert.h> | |
#include <stdint.h> | |
#include <unistd.h> | |
/* print nine digit positive */ | |
char *p9dp(uint32_t n, char *p) | |
{ | |
uint32_t a = n % 10; | |
n /= 10; | |
if (n) { |
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
struct TrieNode { | |
is_terminal: bool, | |
children: [Option<Box<TrieNode>>; 256], | |
} | |
impl TrieNode { | |
fn new() -> TrieNode { | |
let mem : TrieNode = unsafe { std::mem::zeroed() }; | |
mem | |
} |
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 itertools | |
def infinite_combinations(n, iterator): | |
seen = [] | |
for item in iterator: | |
for subset in itertools.combinations(seen, n - 1): | |
yield subset + (item,) | |
seen.append(item) |
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/python | |
from itertools import count | |
def ramanujan_number(): | |
cubes = (i**3 for i in count(1)) | |
smaller_cubes = [] | |
sums = {} | |
for n in cubes: | |
for m in smaller_cubes: |
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/python | |
# https://plus.google.com/u/0/114070220225686847236/posts/d7xrq9ph7WJ | |
# There are no repeated digits, and no adjacent digits with a | |
# difference of one, in the number 13524. How many such arrangements | |
# of 5 digits are there? What's the shortest program you can write to | |
# find out? | |
import itertools |
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/python | |
from itertools import count, cycle, islice, izip, repeat | |
def fizzbuzz(n): | |
class d(int): __add__ = lambda self, other: other | |
def i(x): return x | |
def f(x): return x + 'Fizz' | |
def b(x): return x + 'Buzz' | |
def p(x): print x |