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