Skip to content

Instantly share code, notes, and snippets.

View TSavo's full-sized avatar

T Savo TSavo

View GitHub Profile
pragma solidity 0.4.21;
contract ERC20Interface {
function totalSupply() public constant returns (uint256);
function balanceOf(address tokenOwner) public constant returns (uint256 balance);
function allowance(address tokenOwner, address spender) public constant returns (uint256 remaining);
function transfer(address to, uint256 tokens) public returns (bool success);
function approve(address spender, uint256 tokens) public returns (bool success);
function transferFrom(address from, address to, uint256 tokens) public returns (bool success);
[
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "tokenOwner",
"type": "address"
},
{
@TSavo
TSavo / Github Leaderboard.md
Created March 17, 2016 18:48
Github Leaderboard Challenge

GitHub Archive leaderboard challenge

GitHub Archive provides stats for projects on GitHub via a RESTful HTTP service.

Create a command-line program that lists the most active repositories for a given time range. It should support the following interface:

  gh_repo_stats [--after DATETIME] [--before DATETIME] [--event EVENT_NAME] [-n COUNT]
@TSavo
TSavo / gist:222b1f7d886f17ee4b73
Last active March 18, 2016 14:31
The Hard Hash Problem
A SHA-256 hash contains 256 bits of data. A "Hard Hash" of difficulty N is one who's first N bits are 0.
Write a program which accepts an input string, and a difficulty as it's parameters,
and finds a Hard SHA-256 Hash of that difficulty for any string that includes the input string.
Appending and prepending to the input string is allowed (and expected).
Output the final string and the Hard Hash on stdout.
Answer the following questions:
What are the chances for finding a Hard Hash for difficulty N?
How would you solve this problem for a massive number of strings at a very high difficulty?
You have a function rand5() that generates a random integer from 1 to 5.
Use it to write a function rand7() that generates a random integer from 1 to 7.
rand5() returns each integer with equal probability.
rand7() must also return each integer with equal probability.
Your company delivers breakfast via autonomous quadcopter drones. And something mysterious has happened.
Each breakfast delivery is assigned a unique ID, a positive integer.
When one of the company's 100 drones takes off with a delivery, the delivery's ID is added to a list,
delivery_id_confirmations. When the drone comes back and lands, the ID is again added to the same list.
After breakfast this morning there were only 99 drones on the tarmac. One of the drones never made it back from a delivery.
We suspect a secret agent from Amazon placed an order and stole one of our patented drones.
To track them down, we need to find their delivery ID.
Given the list of IDs, which contains many duplicate integers and one unique integer, find the unique integer.
Verifying that +kevlar is my openname (Bitcoin username). https://onename.com/kevlar
My initial understanding of this challenge is that the words needed to be found
in a sequential order, but after reading the rules for Boggle, I realized that
you were allowed to move in any direction at any time, so long as you didn't
reuse a letter.
Once I saw this, the first solution I thought of was to put all the words from a
dictionary file into a tree, and then try to use the board to walk the tree, noting
any leaves we encountered, but I quickly realized that this would be very memory
intensive and potentially wasteful as there were bound to be a lot of words that
wouldn't get used. So instead, I went for the inverse approach: