Make sure you are running a Ruby version supported by Heroku to make your app easier to deploy later. At the time of writing, that is:
- 2.6.6
- 2.7.2
- 3.0.0
class MaxHeap { | |
constructor(arr = []){ | |
this.size = 0 | |
this.values = this._heapify(arr) | |
} | |
insert(value){ | |
// If no value, do nothing | |
if (value === undefined) return | |
// Insert the value, and increment the size of the heap |
class MaxHeap { | |
constructor(){ | |
this.values = [] | |
this.size = 0 | |
} | |
insert(value){ | |
// If no value, do nothing | |
if (value === undefined) return | |
// Insert the value, and increment the size of the heap |
Make sure you are running a Ruby version supported by Heroku to make your app easier to deploy later. At the time of writing, that is:
// Using Conditionals | |
const newMessage = {type: "error", message: "You still haven't squished the bugs!"} | |
const generateLog = newMessage => { | |
if (newMessage.type === "warn" { | |
Log.warn(newMessage.message) | |
} else if (newMessage.type === "error" { | |
Log.error(newMessage.message) | |
} else if (newMessage.type === "notify" { |
const greetings = { | |
english: "hello", | |
spanish: "hola" | |
} | |
const langChoice = "spanish" | |
greetings.english //=> "hello" | |
greetings[langChoice] //=> "hola" |
export class Log { | |
static error(msg){ | |
let date = new Date(); | |
let time = date.toLocaleTimeString(); | |
return {type: 'error', msg: `[${time}] ERROR: ${msg}`} | |
} | |
static warn(msg){ | |
let date = new Date(); | |
let time = date.toLocaleTimeString(); |
class Sudoku | |
attr_accessor :starting_board, :solution, :removed_values, :difficulty | |
BLANK_BOARD = [ | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], |
const BLANK_BOARD = [ | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0] |
const newSolvedBoard = _ => { | |
startTime = new Date | |
// Create an unaffiliated clone of a fresh board | |
const newBoard = BLANK_BOARD.map(row => row.slice() ) | |
// Populate the board using backtracking algorithm | |
fillPuzzle(newBoard) | |
return newBoard | |
} |