This file contains hidden or 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
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] | |
]; |
This file contains hidden or 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
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 |
This file contains hidden or 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 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 |
This file contains hidden or 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 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 |
This file contains hidden or 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
/// <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>; |
This file contains hidden or 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 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' |
This file contains hidden or 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 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 |
This file contains hidden or 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 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 |
This file contains hidden or 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 parseopt, strutils, math | |
type | |
Options = object | |
a, b, step: float | |
report: int | |
filename: string | |
DataPoint = tuple[x: float, y: float] | |
Data = seq[DataPoint] |
This file contains hidden or 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 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"] |