Skip to content

Instantly share code, notes, and snippets.

View cuttlebit's full-sized avatar

Tony Wu cuttlebit

  • Flooffle Labs
  • Sydney
View GitHub Profile
@cuttlebit
cuttlebit / 001-TwoSum.cpp
Last active August 29, 2015 14:14
Solution for TwoSum from leetcode
class Solution {
public:
vector<int> twoSum(vector<int> &numbers, int target) {
vector<int> ans(2);
// Remember indexes
vector<int> sorted(numbers);
// Merge Sort [O(nlog(n))]
mergeSort(sorted);
for (int i = 0; i < numbers.size(); i++) {
@cuttlebit
cuttlebit / cd.lua
Created January 10, 2015 10:26
Modification of cd.lua behaviour in Open Computers. Calling cd with no arguments defaults to root "/".
local shell = require("shell")
local args = shell.parse(...)
local result, reason
if #args == 0 then
result, reason = shell.setWorkingDirectory("/")
else
result, reason = shell.setWorkingDirectory(shell.resolve(args[1]))
end
@cuttlebit
cuttlebit / throbber.cpp
Last active August 29, 2015 14:11 — forked from carneeki/throbber.cpp
Windows version of carneeki's throb...
#include <iostream>
#include <windows.h>
#define SLEEP 100 // 100 millis
using namespace std;
void throb(char in)
{
cout << "\b" << in;