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 inventory; | |
$(function(){ | |
(function() { | |
inventory = { | |
init: function() { | |
console.log('Initialized'); | |
}, | |
setDate: function() { | |
var date = '1234' | |
$('#test').text(date); |
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 inventory; | |
(function() { | |
inventory = { | |
init: function() { | |
console.log('Initialized'); | |
}, | |
setDate: function() { | |
var date = '1234' | |
$('#test').text(date); | |
} |
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
// 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 | |
// |
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
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)) |
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
// 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 |
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
// 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 |
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
// 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 |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>your page title goes here</title> | |
<meta charset="utf-8" /> | |
</head> | |
<body> | |
</body> | |
</html> |
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
class Move | |
attr_accessor :value | |
VALID_CHOICES = ["rock", "paper", "scissors", "lizard", "spoke"] | |
def initialize(value) | |
@value = value | |
end | |
def to_s | |
@value | |
end |
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
# 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 |
NewerOlder