Skip to content

Instantly share code, notes, and snippets.

View samanthadoran's full-sized avatar

Samantha Doran samanthadoran

  • Seattle, Wa
  • 09:02 (UTC -07:00)
View GitHub Profile
//
// Created by Doran on 5/25/2015.
//
#include "cas.h"
vector<string> cas::tokenize(std::string toTokenize) {
std::regex pattern("([-+*^/()]|[^-+*^/()\\s]+)");
std::sregex_token_iterator first{toTokenize.begin(), toTokenize.end(), pattern}, last;
return {first, last};
}
import sys
def interpret(code):
dataTape = [ord('\x00')] * 30000
dataIndex = 0
PC = 0
#BF programs end when PC is past data range
while PC < len(code) and PC >= 0 and dataIndex >= 0:
#Increment the current position on the tape
if numTargets == 0 then
for luaTransIndex = 0, I:GetLuaTransceiverCount() - 1 do
for missIndex = 0, I:GetLuaControlledMissileCount(luaTransIndex) - 1 do
if I:GetLuaControlledMissileInfo(luaTransIndex, missIndex).TimeSinceLaunch > 2 then
I:DetonateLuaControlledMissile(luaTransIndex, missIndex)
end
end
end
end
C:\Users\saman\Desktop>a input.txt
Project Euler .net Problem 1
Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples of 3 or 5,
we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
...
#include <stack>
#include <map>
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <string>
#include <vector>
std::map<int, int> bracemap(std::string instructions) {
//Don't keep looking for braces, make a map.
std::map<int, int> bmap;
#include <stdio.h>
void someFunc(int * array, int size) {
int i;
int * originalPosition = array;
for(i = 0; i < size; ++i)
(*(array++))++;
for(i = 0; i < size; ++i)
import strutils
import sequtils
type
BinaryTreeObj[T] = object
left, right: BinaryTree[T]
data: T
BinaryTree*[T] = ref BinaryTreeObj[T]
proc newNode*[T](data: T): BinaryTree[T] =
new(result)
import math
print(math.floor( math.log(8)/math.log(2) ) + 1)
//メロさん
#include <iostream>
#include <vector>
#include <math.h>
#include <cstdlib>
using namespace std;
//A "full-adder" of sorts, currently using a while loop rather than multiple circuits
vector<bool> adder(vector<bool>::iterator a, vector<bool>::iterator b)
@samanthadoran
samanthadoran / gist:7059396
Last active December 25, 2015 23:49
Text variant of Solitaire (Klondike)
#include <iostream>
#include <random>
#include <stack>
#include <vector>
#include <unordered_set>
#include <string>
#include <iterator>
#include "../headers/card.h"
using std::vector;