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
const names = ['pikachu', 'squirtle', 'charmander'] | |
const capitalize = function (name) { | |
const capitalizedFirst = name[0].toUpperCase() | |
const rest = name.slice(1) | |
return [capitalizedFirst].concat(rest).join('') | |
} | |
// map function with reduce | |
const map = (list, mapFunction) => { |
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
// game loop | |
while (true) { | |
var largestMontain = 0; | |
var indexToShot = 0; | |
for (var i = 0; i < 8; i++) { | |
var mountainH = parseInt(readline()); // represents the height of one mountain. | |
if(largestMontain < mountainH) { | |
largestMontain = mountainH; | |
indexToShot = i; |
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
// Multiplication and division rules... ((+)*(+)=+) ((-)*(-)=+) ((+)*(-)=-) ((-)*(+)=-) | |
const multiply = (x, y) => { | |
let r = Math.exp(Math.log(Math.abs(x)) + Math.log(Math.abs(y))).toFixed(2) | |
return Number((x < 0 && y < 0) ? r : (x < 0 || y < 0) ? -r : r) | |
} | |
const divide = (x, y) => { | |
return (x === 0) ? 0 : multiply(((multiply(x, y) < 0) ? -1.0 : 1.0), Math.exp(Math.log(Math.abs(x)) - Math.log(Math.abs(y)))) | |
} |
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
var grid = []; | |
var inputs = readline().split(' '); | |
var W = parseInt(inputs[0]); // number of columns. | |
var H = parseInt(inputs[1]); // number of rows. | |
for (var i = 0; i < H; i++) { | |
var LINE = readline(); // represents a line in the grid and contains W integers. Each integer represents one room of a given type. | |
grid[i] = LINE.split(' '); | |
} | |
var EX = parseInt(readline()); // the coordinate along the X axis of the exit (not useful for this first mission, but must be read). |
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
var n = parseInt(readline()); | |
var inputs = readline().split(' '); | |
var values = []; | |
for (var i = 0; i < n; i++) { | |
var v = parseInt(inputs[i]); | |
values.push(v); | |
} |
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
var express = require('express') | |
, app = express() | |
, sse = require('./sse') | |
var connections = [] | |
, votes = {yes: 0, no: 0} | |
app.engine('jade', require('jade').__express) | |
app.set('view engine', 'jade') |
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
/** | |
* Auto-generated code below aims at helping you parse | |
* the standard input according to the problem statement. | |
**/ | |
var graph = []; | |
var n = parseInt(readline()); // the number of adjacency relations | |
for (var i = 0; i < n; i++) { | |
var inputs = readline().split(' '); | |
var xi = parseInt(inputs[0]); // the ID of a person which is adjacent to yi |
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
var graph = []; | |
var n = parseInt(readline()); // the number of adjacency relations | |
for (var i = 0; i < n; i++) { | |
var inputs = readline().split(' '); | |
var xi = parseInt(inputs[0]); // the ID of a person which is adjacent to yi | |
var yi = parseInt(inputs[1]); // the ID of a person which is adjacent to xi | |
if (!graph[xi]) { | |
graph[xi] = { data: xi, edges: [] }; | |
} | |
graph[xi].edges.push(yi); |
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
makeSortString = (function() { | |
var translate_re = /[¹²³áàâãäåaaaÀÁÂÃÄÅAAAÆccç©CCÇÐÐèéê?ëeeeeeÈÊËÉ?EEEEE€gGiìíîïìiiiÌÍÎÏ?ÌIIIlLnnñNNÑòóôõöoooøÒÓÔÕÖOOOØŒr®Ršs?ߊS?ùúûüuuuuÙÚÛÜUUUUýÿÝŸžzzŽZZ]/g; | |
var translate = { | |
"¹":"1","²":"2","³":"3","á":"a","à":"a","â":"a","ã":"a","ä":"a","å":"a","a":"a","a":"a","a":"a","À":"a","Á":"a","Â":"a","Ã":"a","Ä":"a","Å":"a","A":"a","A":"a", | |
"A":"a","Æ":"a","c":"c","c":"c","ç":"c","©":"c","C":"c","C":"c","Ç":"c","Ð":"d","Ð":"d","è":"e","é":"e","ê":"e","?":"e","ë":"e","e":"e","e":"e","e":"e","e":"e", | |
"e":"e","È":"e","Ê":"e","Ë":"e","?":"e","E":"e","E":"e","E":"e","E":"e","E":"e","€":"e","g":"g","G":"g","i":"i","ì":"i","í":"i","î":"i","ï":"i","ì":"i","i":"i", | |
"i":"i","i":"i","Ì":"i","Í":"i","Î":"i","Ï":"i","?":"i","Ì":"i","I":"i","I":"i","I":"i","l":"l","L":"l","n":"n","n":"n","ñ":"n","N":"n","N":"n","Ñ":"n","ò":"o", | |
"ó":"o","ô":"o","õ":"o","ö":"o","o":"o","o":"o","o":"o","ø":"o","Ò":"o","Ó":"o","Ô":"o","Õ":"o","Ö":"o","O":"o","O":"o","O":"o","Ø":"o","Œ":"o","r":"r","®":"r", | |
" |
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
app.factory('authToken',['$cookieStore', '$location', function($cookieStore, $location){ | |
var token = {}; | |
token.start = null; | |
token.setAccessToken = function(accessToken) { | |
$cookieStore.put('accessToken', accessToken); | |
} | |
token.getAccessToken = function() { | |
token.authToken = $cookieStore.get('accessToken'); |