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 getStyles = window.getComputedStyle | |
? function (node) { return window.getComputedStyle(node, null) }; | |
: function (node) { return node.currentStyle }; |
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
function hmss(ms) { | |
var result = []; | |
result[0] = ((ms % 216e6) / 36e5) | 0; | |
result[1] = ((ms % 36e5) / 6e4) | 0; | |
result[2] = ((ms % 6e4) / 1e3) | 0; | |
result[3] = (ms % 1e3) | 0; | |
return 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
(* Explode string *) | |
let explode str = | |
let rec exp i acc = | |
if i < 0 then acc | |
else exp (i - 1) (str.[i] :: acc) in | |
exp (String.length str - 1) [] | |
(* # explode "foo bar baz ";; | |
* - : char list = ['f'; 'o'; 'o'; ' '; 'b'; 'a'; 'r'; ' '; 'b'; 'a'; 'z'; ' '] |
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
// https://github.com/tmpvar/jsdom/issues/1728 | |
// npm i | |
// node jsdom-issue-1728.js | |
var jsdom = require("jsdom").jsdom; | |
var window = jsdom().defaultView; | |
var elementA = window.document.createElement("div"); | |
var elementB = window.document.createElement("div"); |
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
function rotate(array, n) { | |
while(n--) { | |
var index = -1; | |
var length = array.length; | |
var temp = array.slice(); | |
while (++index < length) { | |
array[(index + 1) % length] = temp[index]; | |
} | |
} |
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
(* | |
Task | |
Given the starter code, complete the Fibonacci function to return the term. | |
We start counting from Fibonacci(1) = 0. This might differ from some other notations that treats Fibonacci(0) = 0. | |
*) | |
open Scanf;; | |
let n = bscanf Scanning.stdin " %d" (fun x -> x);; |
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
(* | |
Task | |
Given the starter code, you need to complete a function body that returns the GCD of two given integers and . | |
The task of reading in input and printing the output will be handled by us. | |
Programming Language Support | |
At this point of time, we have a template for Scala. This means that we provide the code required to accept | |
the input and display the output. | |
*) |
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 <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
int n1; |
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
/** | |
* Check whether string `s2` is a rotated version of `s1`. | |
* http://stackoverflow.com/questions/2553522/interview-question-check-if-one-string-is-a-rotation-of-other-string | |
* | |
* Example: | |
* | |
* is_rotated("tackoverflows", "ackoverflowst"); | |
* // => true | |
*/ |
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 N = parseInt(readline()); | |
var T = {}; | |
for (var i = 0; i < N; i++) { | |
var t = readline(); | |
T[parseInt(t.replace(/:/g, ''), 10)] = t; | |
} | |
print(T[Object.keys(T).sort((a, b) => a - b)[0]]); |