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
/*""" | |
Given a string s and a list of words w, determine if s can be split into a space-separated sequence of one or more words in w. | |
For example, given | |
s = "catdog" | |
w = ["dog", "car", "catch", "cat", "tiger", "at"] | |
==> True | |
s = "catdogtail" | |
w = ["dog", "car", "catch", "cat", "tiger", "at"] |
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
// $ SBT_OPTS="-Xmx12G" sbt run | |
object MainApp extends App { | |
def async[R](f: => R): Thread = new Thread { | |
override def run(): Unit = f | |
} | |
def parallel[A, B](f: => A, g: => B): (A, B) = { | |
var x: Option[A] = None |
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
# coding=utf-8 | |
from __future__ import unicode_literals | |
import collections | |
_default_stub = object() | |
def to_unicode(s): | |
if isinstance(s, str): | |
return unicode(s, 'utf8') |
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
// this is the lag source (decompiled code) | |
addEventScroll: function(e, t) { | |
var n = this; | |
e.attachEvent ? e.attachEvent("onscroll", function() { | |
t.call(n) | |
}) : e.addEventListener("scroll", function() { | |
t.call(n) | |
}) | |
}, |
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
(define (count-change coins amount) | |
(display coins) (newline) | |
(display amount) (newline) | |
(cond | |
((= 0 amount) 1) | |
((< amount 0) 0) | |
((null? coins) 0) | |
(else | |
(+ | |
(count-change coins (- amount (car coins))) |
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
(define (smallest-divisor n) | |
(find-divisor n 2)) | |
(define (find-divisor n test-divisor) | |
(cond ((> (square test-divisor) n) n) | |
((divides? test-divisor n) test-divisor) | |
(else (find-divisor n (+ test-divisor 1))))) | |
(define (divides? a b) | |
(= (remainder b a) 0)) | |
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
#!/usr/bin/env python | |
""" | |
Parses application/x-www-form-urlencoded string into a json. | |
Usage example: | |
~$ echo "a=1&b=2&a=3" | ./parse_qs.py | jq . | |
{ | |
"a": [ | |
"1", | |
"3" |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
struct Person { | |
let name: Optional<String> | |
let age: Optional<Int> | |
} | |
let tagir: Person = Person(name: "Tagir", age: 32) |
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 Html exposing (..) | |
import Html.Events exposing (..) | |
import Html.Attributes exposing (..) | |
-- UI part | |
main = | |
beginnerProgram { model = { creditCardNumber = "", isValid = False } , view = view, update = update } | |
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
module Demo exposing (..) | |
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (..) | |
main = | |
Html.beginnerProgram | |
{ model = model |