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
import math
print(math.floor( math.log(8)/math.log(2) ) + 1)
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)
#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)
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.
...
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
#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;
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
//
// 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 tables
import sets
import strutils
import sequtils
type
GraphObj = object
matrix: Table[string, seq[string]]
root: string
Graph* = ref GraphObj
import tables, sets, queues
import strutils, sequtils
type
GraphObj = object
matrix: Table[string, seq[string]]
root: string
Graph* = ref GraphObj
discard """