Skip to content

Instantly share code, notes, and snippets.

View istepura's full-sized avatar

Igor Stepura istepura

  • Kanata, Ontario
View GitHub Profile
@istepura
istepura / hw5tests.rkt
Created February 28, 2013 01:54
Tests for homework 5, Programming Languages/Coursera
#lang racket
(require rackunit "hw5.rkt")
(require rackunit/text-ui)
(define hw5-tests
(test-suite
"Tests for HW 5"
(test-equal? "MUPL list -> Racket list #1"
(list (int 3) (int 4) (int 9))
@istepura
istepura / minheap.py
Created September 13, 2013 05:28
Min-heap-based priority queue. Made as an utility class for Dijkstra algorithm
class minheap(object):
""" lst - is list of tuples (vertex id, path lenth)"""
def __init__(self, lst):
self.vlist = {}
self.q = [x for x in lst]
self.size = len(self.q)
for idx, val in enumerate(self.q):
self.vlist[val[0]] = idx
self.__buildheap()
@istepura
istepura / solarized.ini
Created September 13, 2013 07:06
Solarized colorscheme for PyScripter
[PyScripter]
Version=2.5.3.0
[Highlighters\Python]
Name=SynPythonSyn
Tag=0
DefaultFilter=Python Files (*.py;*.pyw)|*.py;*.pyw
Enabled=TRUE
[Highlighters\Python\CommentAttri]
@istepura
istepura / 330D.go
Last active December 23, 2015 17:19
package main
import (
"fmt"
)
type Node struct{
val interface{}
next *Node
}
@istepura
istepura / CMakeLists.txt
Last active December 25, 2015 18:38
Lab3
cmake_minimum_required(VERSION 2.8)
project (lab3 CXX)
set(CMAKE_C_FLAGS "-fpermissive")
set(CMAKE_CXX_FLAGS "-fpermissive -g")
add_executable(task1 task1.cpp thirdparty.h testtables.h)
@istepura
istepura / CMakeLists.txt
Last active December 25, 2015 20:29
Lab4
cmake_minimum_required(VERSION 2.8)
project (lab4 CXX)
set(CMAKE_C_FLAGS "-fpermissive")
set(CMAKE_CXX_FLAGS "-fpermissive -g")
add_executable(task1 task1.cpp thirdparty.h)
@istepura
istepura / 2-3.py
Last active December 27, 2015 08:29
Udacity CS 262
# JavaScript: Comments & Keywords
#
# In this exercise you will write token definition rules for all of the
# tokens in our subset of JavaScript *except* IDENTIFIER, NUMBER and
# STRING. In addition, you will handle // end of line comments
# as well as /* delimited comments */.
#
# We will assume that JavaScript is case sensitive and that keywords like
# 'if' and 'true' must be written in lowercase. There are 26 possible
# tokens that you must handle. The 'tokens' variable below has been
@istepura
istepura / lock.cpp
Created November 11, 2013 03:47
Lock
#ifdef _WIN32_
#include <Windows.h>
volatile LONG g_heap_mutex = 0;
#define LOCK(mtx) { \
while(InterlockedCompareExchange(&mtx,1,0)==1){\
Sleep(0);\
}}
#define UNLOCK(mtx) {InterlockedExchange(&mtx,0);}
@istepura
istepura / gist:9222616
Last active July 14, 2017 17:59
Generating permutations of arr in lexicographic order in C#
public IEnumerable<int[]> Permut(int[] arr){
while (true){
yield return arr;
var j = arr.Length - 2;
while (j >= 0 && arr[j] >= arr[j+1]) j--;
if (j < 0) break;
var l = arr.Length -1;
while (arr[j] >= arr[l]) l--;
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
char line[256] = {0};
int n;
char names[10][16];
char* tmp;