Skip to content

Instantly share code, notes, and snippets.

View kisileno's full-sized avatar

Oleksandr Kisilenko kisileno

  • Cupertino, CA
View GitHub Profile
class Matrix(val n: Int, val m: Int) {
require(n > 0 && m > 0, "Matrix dimensions should be positive integers!")
val elements: Array[Array[Int]] = Array.fill(n)(Array.fill(m)(0))
override def toString: String = {
elements.map(_.mkString(",")).mkString("\n")
}
def setElement(i: Int, j: Int, newValue: Int): Unit = {
- (NSArray<NSString *> *) setToArray:(NSCharacterSet *) charset{
NSMutableArray *array = [NSMutableArray array];
for (int plane = 0; plane <= 16; plane++) {
if ([charset hasMemberInPlane:plane]) {
UTF32Char c;
for (c = plane << 16; c < (plane+1) << 16; c++) {
if ([charset longCharacterIsMember:c]) {
UTF32Char c1 = OSSwapHostToLittleInt32(c); // To make it byte-order safe
NSString *s = [[NSString alloc] initWithBytes:&c1 length:4 encoding:NSUTF32LittleEndianStringEncoding];
[array addObject:s];
@kisileno
kisileno / gist:8052188
Created December 20, 2013 08:58
lab 2
program diffusion
! 2D diffusion equation
implicit none
integer :: t, m, n
real, parameter :: D=5.0
real :: dx, dy, dt, a, b, c
real, dimension(:), allocatable :: u
real, dimension(:,:), allocatable :: u1
@kisileno
kisileno / gist:8048373
Created December 19, 2013 23:59
like orels do
#include <mpi.h>
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <sstream>
using namespace std;
void printMatrix(double* matrix, int n, int t) {
@kisileno
kisileno / gist:7994955
Created December 16, 2013 21:42
Simple straightforward implementation of Schulze method http://en.wikipedia.org/wiki/Schulze_method.
val input = Map("ACBED" -> 5, "ADECB" -> 5, "BEDAC" -> 8, "CABED" -> 3, "CAEBD" -> 7, "CBADE" -> 2, "DCEBA" -> 7, "EBADC" -> 8)
val allVotes = input.values.sum
val points = (for {
key <- input.keys
point <- key
} yield point).toSet.toList.sorted
val table1 = (for {