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 climbingLeaderboard(scores, alice) { | |
scores = [...new Set(scores)] // remove duplicate scores | |
let lastScore = null; | |
let lastRank = 0; | |
let aliceRanks = []; | |
let leaderIndex = 0; | |
let lowestScore = scores[scores.length - 1]; | |
let lowestRank = scores.length; | |
while (alice.length > 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
function mod(a, n) { | |
return a - (n * Math.floor(a / n)); | |
} | |
function circularArrayRotation(a, k, queries) { | |
let arraySize = a.length; | |
let querySize = queries.length; | |
let output = []; | |
let startIndex = mod(-k, arraySize); |
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
""" | |
magic square is a n x n matrix of distinct positive integers from 1 to n^2. | |
where the sum of any row, column, or diagonal of length n is always equal to | |
the same number: the magic constant. | |
The magic square has been well studied in history, so the magic constant can | |
be calculated: Magic Constant (M) = n * ((n^2 + 1) / 2). | |
In this problem n will be 3, which means we now know the magic constant: |
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' | |
// Challenge is to be able to tell a difference between a Class, Class instance, and object of Classes | |
// Class | |
class Plugin {} | |
// Class instance | |
const inst = new Plugin() |
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'; | |
const assert = require('assert'); | |
const Simple = require(__filename.replace('test', 'js')); | |
describe('Simple', function () { | |
let simple = new Simple(); | |
describe('set#name()', function () { |
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'; | |
class Simple { | |
set name(name) { | |
this._name = name; | |
} | |
get name() { | |
return this._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
# Snippets | |
# | |
# This file uses CoffeeScript Object Notation (CSON). | |
# If you are unfamiliar with CSON, you can read more about it in the | |
# Atom Flight Manual: | |
# https://atom.io/docs/latest/using-atom-basic-customization#cson | |
# MARKDOWN #################################################################### |