Skip to content

Instantly share code, notes, and snippets.

View dev-nyc's full-sized avatar
🤹‍♂️
pushing

khaled dev-nyc

🤹‍♂️
pushing
View GitHub Profile
var inventory;
$(function(){
(function() {
inventory = {
init: function() {
console.log('Initialized');
},
setDate: function() {
var date = '1234'
$('#test').text(date);
var inventory;
(function() {
inventory = {
init: function() {
console.log('Initialized');
},
setDate: function() {
var date = '1234'
$('#test').text(date);
}
@dev-nyc
dev-nyc / flattenAndUnique.js
Last active November 30, 2018 17:35
flattenUnique
// Write a function that takes a two dimensional array as the argument, turn it into a flat array and
// with all the duplicated elements removed. Treat numbers and number strings, for example, 1 and '1'
// as duplicates, and keep the one that comes first in the flattened array.
//
// SOLUTION:
//
// input : multi dimensional array
//
// output : new flat array with no duplicate number strings or numbers
//
@dev-nyc
dev-nyc / bowling2.js
Last active November 29, 2018 18:46
bowling(2)
ts=<2>
// SOLUTION:
//
// input: number
// output: number score
//
// data structure: array of arrays
//
// Rules : 1- 10 frames
// 2- each frame has one or two balls (frame stops if strike(10 balls))
@dev-nyc
dev-nyc / bowling.js
Last active November 29, 2018 04:08
bowling
// SOLUTION:
//
// input: number ?
// output: number score
//
// data structure: array of arrays
//
// Rules : 1- 10 frames
// 2- each frame has one or two balls (frame stops if strike(10 balls))
// 3- each ball has 10 pins
@dev-nyc
dev-nyc / bowling.js
Created November 29, 2018 03:59
bowling
// The game consists of 10 frames. A frame is composed of one or two ball throws with 10 pins
// standing at frame initialization. There are three cases for the tabulation of a frame.
// An open frame is where a score of less than 10 is recorded for the frame. In this case the
// score for the frame is the number of pins knocked down.
// A spare is where all ten pins are knocked down after the second throw. The total value of a
// spare is 10 plus the number of pins knocked down in their next throw.
// A strike is where all ten pins are knocked down after the first throw. The total value of a
// The game consists of 10 frames. A frame is composed of one or two ball throws with 10 pins
// standing at frame initialization. There are three cases for the tabulation of a frame.
// An open frame is where a score of less than 10 is recorded for the frame. In this case the
// score for the frame is the number of pins knocked down.
// A spare is where all ten pins are knocked down after the second throw. The total value of a
// spare is 10 plus the number of pins knocked down in their next throw.
// A strike is where all ten pins are knocked down after the first throw. The total value of a
@dev-nyc
dev-nyc / skeleton.html
Created September 9, 2018 20:41
skeleton
<!DOCTYPE html>
<html lang="en">
<head>
<title>your page title goes here</title>
<meta charset="utf-8" />
</head>
<body>
</body>
</html>
@dev-nyc
dev-nyc / rps_bonus.rb
Last active August 14, 2017 03:09
rps bonus features
class Move
attr_accessor :value
VALID_CHOICES = ["rock", "paper", "scissors", "lizard", "spoke"]
def initialize(value)
@value = value
end
def to_s
@value
end
@dev-nyc
dev-nyc / sort.rb
Created October 25, 2016 19:07 — forked from aspyct/sort.rb
Sample implementation of quicksort, mergesort and binary search in ruby
# Sample implementation of quicksort and mergesort in ruby
# Both algorithm sort in O(n * lg(n)) time
# Quicksort works inplace, where mergesort works in a new array
def quicksort(array, from=0, to=nil)
if to == nil
# Sort the whole array, by default
to = array.count - 1
end