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> | |
#include <stdlib.h> | |
typedef unsigned long u64; | |
/* Start here */ | |
typedef void enc_cfg_t; | |
typedef int enc_cfg2_t; | |
typedef __int128_t dcf_t; |
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 fs = require('fs') | |
var out = fs.readFileSync('src.txt', 'utf8') | |
.trim().split('\n') | |
.reduce(function (acc, cur) { | |
var curArr = cur.split(' '); | |
if (typeof acc[curArr[0]] !== 'object') { | |
acc[curArr[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
//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
function cat() { | |
var head = _.first(arguments); | |
if (existy(head)) | |
return head.concat.apply(head, _.rest(arguments)); | |
else | |
return []; | |
} | |
function construct(head, tail) { | |
return cat([head], _.toArray(tail)); |
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 binSearch(arr, data) { | |
var upperBound = arr.length - 1; | |
var lowerBound = 0; | |
while (lowerBound <= upperBound) { | |
var mid = Math.floor((upperBound + lowerBound) / 2); | |
if (arr[mid] < data) { | |
lowerBound = mid + 1; | |
} else if (arr[mid] > data) { | |
upperBound = mid - 1; | |
} else { |
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 thunkify(fn) { | |
return function() { | |
var args = [].slice.call( arguments ), | |
ctx = this; | |
return function(cb) { | |
var called; | |
args.push(function(){ | |
if (called) return; |
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* g4() { | |
yield* [1, 2, 3]; | |
return "foo"; | |
} | |
var result; | |
function* g5() { | |
result = yield* g4(); | |
} |
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
struct Node{ | |
int data; | |
Node *left, *right; | |
}; | |
void preOrderPrint(Node *root) | |
{ | |
print(root->name); //record root | |
if (root->left != NULL) preOrderPrint(root->left); //traverse left if exists | |
if (root->right != NULL) preOrderPrint(root->right);//traverse right if exists | |
} |
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 queue = []; | |
queue.push(2); // [2] | |
queue.push(5); // [2, 5] | |
var i = queue.shift(); // [5] // i = 2 |
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
"use strict"; | |
var publisher = { | |
subscribers: { | |
any: [] // event type: subscribers | |
}, | |
subscribe: function (fn, type) { | |
type = type || 'any'; | |
if (typeof this.subscribers[type] === "undefined") { | |
this.subscribers[type] = []; | |
} |