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 <fstream> | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
const char* A = "A.txt"; | |
const char* B = "B.txt"; | |
vector<int> fillVector(const char*); |
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 <fstream> | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
const char* A = "A.txt"; | |
const char* B = "B.txt"; | |
vector<int> fillVector(const char*); |
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
require 'mathn' | |
size = gets.chomp.to_i | |
$array = Array.new(size) { |iarray| iarray = Array.new(size) { |j| j = gets.chomp.to_i } } | |
m = Matrix.rows($array) | |
puts m.det |
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
;; scheme code: | |
(define (partial-tree elts n) | |
(if (= n 0) | |
(cons '() elts) | |
(let ((left-size (quotient (- n 1) 2))) | |
(let ((left-result (partial-tree elts left-size))) | |
(let ((left-tree (car left-result)) | |
(non-left-elts (cdr left-result)) | |
(right-size (- n (+ left-size 1)))) | |
(let ((this-entry (car non-left-elts)) |
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
require 'net/http' | |
require 'nokogiri' | |
require 'Qt' | |
APPID = "QV4WQY-RYGTU7UPH2" | |
WADDR = 'http://api.wolframalpha.com/v2/query' | |
def queryWA(qry) | |
uri = URI(WADDR) | |
res = Net::HTTP.post_form(uri, 'input' => qry, 'appid' => APPID) |
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 "stl_queue.hpp" | |
STLQueue::STLQueue() { | |
queue = new deque<double>; | |
} | |
void STLQueue::push(const double n) { | |
queue->push_back(n); | |
} |
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
/* | |
* Licensed to the Apache Software Foundation (ASF) under one or more | |
* contributor license agreements. See the NOTICE file distributed with | |
* this work for additional information regarding copyright ownership. | |
* The ASF licenses this file to You under the Apache License, Version 2.0 | |
* (the "License"); you may not use this file except in compliance with | |
* the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
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
package spark.api.java | |
import java.util.{Map => JMap} | |
import scala.collection.JavaConversions | |
import scala.collection.JavaConversions._ | |
import scala.reflect.ClassTag | |
import org.apache.hadoop.conf.Configuration | |
import org.apache.hadoop.mapred.InputFormat |
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
[error] /home/cdshines/devel/scala/spark/core/src/main/scala/spark/api/java/JavaSparkContext.scala:245: type mismatch; | |
[error] found : Seq[spark.api.java.JavaRDD[(some other)T(in method union)]] | |
[error] required: Seq[spark.api.java.JavaRDD[T(in method union)]] | |
[error] def union[T](va: JavaRDD[T]*): JavaRDD[T] = { | |
[error] ^ | |
[warn] two warnings found | |
[error] one error found | |
[error] (core/compile:compile) Compilation failed |
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
class Level(val field: Vector[Vector[Cell]]) { | |
def positions = Vector.tabulate(field.size, field(0).size)((x, y) => Pos(x, y)) | |
def cellAtPos(p: Pos): Cell = field(p.x)(p.y) | |
def nextGeneration = | |
new Level(Vector(positions.map(r => Vector(r.map(p => cellAtPos(p).newWithRespectToNeighbours(field)(p) ): _*) ): _*)) | |
override def toString = field map { r => r.mkString("") } mkString "\n" | |
} | |
case class Cell(isAlive: Boolean) { | |
override def toString = if (isAlive) "*" else "-" |
OlderNewer