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
{ | |
"id": "15815873-e1cf-49bb-a57e-b3cbf3cab4d6", | |
"bpm": 120, | |
"stepsPerBeat": 4, | |
"beatsPerMeasure": 4, | |
"name": "Test", | |
"duration": 48, | |
"patterns": { | |
"i1": { "name": "Bass", "type": "keys", "keys": "i2", "synth": "i0", "duration": 4 }, | |
"i2b": { "name": "Chords", "type": "keys", "keys": "i2a", "synth": "i28", "duration": 8 }, |
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
val input = "..." | |
val phrases = input.lines.toList.map(_.split("\\s").toList) | |
def passesCheck1(words: List[String]): Boolean = { | |
Set(words: _*).size == words.length | |
} | |
def passesCheck2(words: List[String]): Boolean = { | |
val anagrams = words.flatMap(w => w.permutations.toSet - w) |
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
def bitwiseIsDivisible(pair: Array[Int]): Boolean = { | |
var (numerator, denominator) = | |
if (pair(0) >= pair(1)) (pair(0), pair(1)) | |
else (pair(1), pair(0)) | |
var remainder = numerator | |
var quotient = 0 | |
while (remainder >= denominator) { | |
remainder = sub(remainder, denominator) | |
quotient = add(quotient, 1) |
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
import scala.annotation.tailrec | |
val input = 347991 | |
type Grid = Map[(Int, Int), Int] | |
val grid: Grid = Map( | |
(0, 0) -> 1, | |
(1, 0) -> 1 | |
).withDefaultValue(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
import math._ | |
val input = 347991 | |
def distance(n: Int) = { | |
val level = ((sqrt(n) - 1) / 2).ceil.toInt | |
val br = pow(level * 2 + 1, 2).toInt | |
val offset = br - n | |
val length = level * 2 + 1 | |
val k = length - 1 |
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
13:33:06.524 INFO o.a.ignite.internal.IgniteKernal - | |
>>> __________ ________________ | |
>>> / _/ ___/ |/ / _/_ __/ __/ | |
>>> _/ // (7 7 // / / / / _/ | |
>>> /___/\___/_/|_/___/ /_/ /___/ | |
>>> | |
>>> ver. 2.2.0#20170915-sha1:5747ce6b | |
>>> 2017 Copyright(C) Apache Software Foundation | |
>>> |
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
@ val sources = List(Source(1 :: 2 :: 3 :: Nil), Source(4 :: 5 :: 6 :: Nil), Source(7 :: 8 :: 9 :: Nil)) | |
sources: List[Source[Int, akka.NotUsed]] = List( | |
Source(SourceShape(StatefulMapConcat.out(666586581))), | |
Source(SourceShape(StatefulMapConcat.out(1638756960))), | |
Source(SourceShape(StatefulMapConcat.out(136416115))) | |
) | |
@ val futures = sources.map(_.runWith(Sink.seq)) | |
futures: List[concurrent.Future[collection.immutable.Seq[Int]]] = List( | |
Future(Success(Vector(1, 2, 3))), |
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 <stdio.h> | |
typedef struct { | |
// Required | |
const char *fq_name[3]; | |
// Optional | |
const char *display_name; | |
const char *href; | |
const char *name; |
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
val myRoute = | |
pathPrefix("rest") { | |
controller("apps", RestController(AppDao)) ~ | |
controller("clusters", RestController(ClusterDao)) ~ | |
controller("commits", RestController(CommitDao)) ~ | |
controller("deployments", RestController(DeploymentDao)) ~ | |
controller("config-keys", RestController(ConfigKeyDao)) ~ | |
controller("config-values", RestController(ConfigValueDao)) ~ | |
controller("blades", RestController(BladeDao)) ~ | |
controller("stacks", RestController(StackDao)) ~ |
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 Parent[T <: Parent[_]] { | |
def foo = this.asInstanceOf[T] | |
} | |
class Child extends Parent[Child] |