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
var assert = require("chai").assert; | |
var TennisGame = require("../src/TennisGame"); | |
describe('Tennis Score', function() { | |
var tests = [ | |
[0, 0, "Love-All"], | |
[1, 1, "Fifteen-All"], | |
[2, 2, "Thirty-All"], |
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
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Debug mocha", | |
"type": "node", | |
"request": "launch", | |
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", | |
"stopOnEntry": true, | |
"args": [], |
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 static org.junit.Assert.assertEquals; | |
import static org.mockito.Mockito.mock; | |
import static org.mockito.Mockito.when; | |
import java.util.Collection; | |
import java.util.Iterator; | |
import org.junit.Before; | |
import org.junit.Test; |
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
[1,2,3,4].intersect([2,4]) | |
//===> [2, 4] |
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
[1,2,3].subsequences() | |
//===> [[1], [1, 2, 3], [2], [2, 3], [1, 2], [3], [1, 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
letters = ['a', 'b', 'c'] | |
numbers = [1, 2, 3] | |
combos = [letters, numbers].combinations() | |
//[[a, 1], [b, 1], [c, 1], [a, 2], [b, 2], [c, 2], [a, 3], [b, 3], [c, 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
[1,2,3].permutations() | |
//[[1, 2, 3], [3, 2, 1], [2, 1, 3], [3, 1, 2], [1, 3, 2], [2, 3, 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 static org.junit.Assert.*; | |
import org.junit.Before | |
import org.junit.Test; | |
class TestScriptScrub { | |
private ScriptScrub scrub |
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 ScriptScrub { | |
def scrub(text) { | |
def regex = ~/(<script.*>)([\s\S]+)(<\/script>)/ | |
def result = text.replaceAll(regex, "") | |
result | |
} | |
} |
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 s = Array(1,2,3,4,5) | |
for ( i<-0 until s.length) yield { | |
if ( i%2 == 1) s(i-1) | |
else if(i == s.length-1) s(i) | |
else s(i+1) | |
} | |
//scala.collection.immutable.IndexedSeq[Int] = Vector(2, 1, 4, 3, 5) |
NewerOlder