Skip to content

Instantly share code, notes, and snippets.

View grantfree035's full-sized avatar

Grant Freeman grantfree035

  • Raytheon
  • Dallas, TX
View GitHub Profile
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) {
@grantfree035
grantfree035 / solution.js
Created December 5, 2018 21:13
circ rotate array
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);
@grantfree035
grantfree035 / magic.py
Created November 28, 2018 07:17
Magic Matrix in Python 3
"""
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:
'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()
'use strict';
const assert = require('assert');
const Simple = require(__filename.replace('test', 'js'));
describe('Simple', function () {
let simple = new Simple();
describe('set#name()', function () {
@grantfree035
grantfree035 / simple.js
Created April 13, 2016 19:16
js getter and setter within a class
'use strict';
class Simple {
set name(name) {
this._name = name;
}
get name() {
return this._name;
@grantfree035
grantfree035 / snippets.cson
Last active February 22, 2016 16:28
personal collection of Atom snippets
# 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 ####################################################################