Skip to content

Instantly share code, notes, and snippets.


Dionysis Zindros dionyziz

Block or report user

Report or block dionyziz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
def longest_increasing_subsequence(sequence):
best_length = -1
for bitmask in range(2**len(sequence)):
subsequence = []
for bit_idx in range(len(sequence)):
if bitmask & (1 << bit_idx):
if not sorted(subsequence) == subsequence:
if len(subsequence) > best_length:
View gist:5b7e134279f692cbdd56701f0f0546e4
"compilerOptions": {
/* Basic Options */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["es2016", "DOM"], /* Specify library files to be included in the compilation. */
"resolveJsonModule": true, /* Allows for importing, extracting types from and generating .json files.
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
View judge-chai.js
const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')
async judge() {
expect(tx.isSane(), 'TX not sane')
expect(tx.inputs.length, 'TX doesn\'t have 1 input')
expect(tx.outputs[0].value, `TX doesn't pay ${SATOSHI_VALUE / SATOSHIS_IN_BTC} BTC`)
View gist:623dbeb6cc28126d4908d3449a9d0e3f
23.hs:23:3: error:
• Couldn't match type ‘a’ with ‘a0’
‘a’ is a rigid type variable bound by
the type signature for:
rnd_select :: forall a. [a] -> Int -> IO [a]
at 23.hs:18:1-34
Expected type: IO [a]
Actual type: IO [a0]
• In a stmt of a 'do' block: return choice
In the expression:
View removeat.hs
module RemoveAt where
removeAt :: Int -> [a] -> (a, [a])
removeAt n xs = (item, list)
where item = xs!!(n - 1)
list = map snd (filter fst (zip characteristic xs))
characteristic = before ++ pivot ++ after
before = replicate (n - 1) True
pivot = [False]
View 23.hs
import Control.Monad.State.Lazy
import System.Random
import RemoveAt
choose = do
(gen, xs) <- get
let (idx, gen') = randomR (1, length xs) gen
let (val, xs') = removeAt idx xs
put (gen', xs')
return val
View parallel-opportunities.js
class Edge {
order: {
placed: false,
place: async function() {
this.placed = true
orderid = await cctx.placeOrder()
do {
View idmonad.hs
data Id a = Id a
deriving (Show)
instance Functor Id where
fmap f (Id a) = Id $ f a
instance Applicative Id where
pure = Id
(Id f) <*> (Id a) = Id (f a)
View await.js
axios = require('axios')
function main() {
async function writeToConsole() {
while (true) {
View 21.hs
import Control.Monad
import Data.Key
import qualified Data.Map as Map
memoizedPrimeFactors :: Int -> Map.Map Int Int
memoizedPrimeFactors = (map primeFactors [0..] !!)
where primeFactors :: Int -> Map.Map Int Int
primeFactors 1 = Map.empty
primeFactors n = Map.insertWith (+) p 1 ps
You can’t perform that action at this time.