Skip to content

Instantly share code, notes, and snippets.

View SPY's full-sized avatar

Ilya Rezvov SPY

  • Google
  • Denver, USA
View GitHub Profile
var good = [
[1,2,3,4,5,6,7,8],
[1,2,8,4,5,6,7,3],
[1,5,8,4,2,6,7,3]
];
var bad = [
[1,2,3,6,5,6,7,6],
[1,2,3,4,5,6,8],
[1,2,3,4,5,6,7,8,10]
];
var React = require('react');
var {Chart, Line, Axis, Layout} = require('react-chart');
var LineChart = React.createClass({
propTypes: {
data: React.propTypes.arrayOf(React.propTypes.shape({
x: React.propTypes.number.isRequired,
y: React.propTypes.number.isRequired
})).isRequired,
color: React.propTypes.string.isRequired
import Control.Applicative ((<$>))
import Text.Printf (printf)
type Solution = Maybe [Double]
solve :: [[Double]] -> Solution
solve [[a, b]] = return [b / a]
solve (h@(x : xs) : t) = do
let minor = transform h t
if any isNull minor
import Control.Applicative ((<$>))
import Text.Printf (printf)
type Solution = Maybe [Double]
gauss :: [[Double]] -> Solution
gauss [[a, b]] = return [b / a]
gauss (h@(x : xs) : t) = do
let minor = transform h t
if any isNull minor
/// <reference path="../../defs/_references.d.ts" />
import {createFactory} from 'react';
import Rx from 'rx';
import RxComponent = require('src/utils/RxComponent');
const div = createFactory('div');
interface CounterProps {
signal: Rx.Observable<number>;
import Control.Applicative ((<$>))
import Data.List (partition)
readNumList :: String -> [Int]
readNumList = map read . words
segmentsCount :: [Int] -> [[Int]] -> Int
segmentsCount [] _ = 0
segmentsCount (v:vs) edges = let (vs', es') = mark v vs edges in 1 + segmentsCount vs' es'
import Control.Applicative ((<$>))
import Data.List (partition)
type Edge = [Int]
findCycle :: [Int] -> [Edge] -> Maybe [Int]
findCycle vs es =
if (not $ all (even . length . adjacent es) vs) || (segmentsCount vs es > 1)
then Nothing
else Just $ let (cycle, rest) = buildCycle (head vs) es in builder cycle rest
import Control.Applicative ((<$>))
import Data.List (partition)
import Data.Map (Map)
import qualified Data.Map as M
type Edge = [Int]
data Color = Red | Black deriving (Show, Eq)
type Paint = Map Int Color
import parseopt, strutils, math
type
Options = object
a, b, step: float
report: int
filename: string
DataPoint = tuple[x: float, y: float]
Data = seq[DataPoint]
@SPY
SPY / netdef.nim
Last active August 29, 2015 14:23
import macros, strutils
from sockets import ntohl, ntohs, htons, htonl
import endians
export sockets.ntohl
export sockets.ntohs
export sockets.htonl
export sockets.htons
const bigInts = ["int16", "uint16", "int32", "uint32", "int", "uint", "int64", "uint64"]