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
def Dollar(val) | |
Dollar.createRoundedDollar(val.kind_of?(Dollar) ? val.raw : val) | |
end | |
def getDollar | |
input = gets.chomp | |
return nil if (input.empty?) | |
Dollar.createRoundedDollar(input) | |
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
{ | |
"editor.fontFamily": "Consolas", | |
"editor.tabSize": 2, | |
"editor.fontSize": 16, | |
"editor.wordWrap": "wordWrapColumn", | |
"editor.copyWithSyntaxHighlighting": false, | |
"editor.find.autoFindInSelection": true, | |
"editor.quickSuggestions": false, | |
"files.trimTrailingWhitespace": true, | |
"files.trimFinalNewlines": true, |
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
def fact(n) | |
return n if (n < 3) | |
ans = 1 | |
n.downto(2) { |x| | |
ans *= x | |
} | |
return ans | |
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
require 'set' | |
def build_board(n, queens) | |
board = Array.new(n) { "." * n } | |
queens.each { |spot| | |
board[spot / n][spot % n] = "Q" | |
} | |
return board | |
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
require 'set' | |
def build_board(n, queens) | |
board = Array.new(n) { "." * n } | |
queens.each { |spot| | |
board[spot / n][spot % n] = "Q" | |
} | |
return board | |
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
# @param {Integer} n | |
# @return {String[][]} | |
def build_board(n, placed_queens) | |
board = Array.new | |
0.upto(n-1) { |row| | |
row_str = "" | |
0.upto(n-1) { |col| | |
if (placed_queens.include?(row*n + col)) | |
row_str += "Q" | |
else |
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
require 'test/unit' | |
def minByColumn(data, column_name, multiple = false) | |
found_rows = [] | |
data.each { |row| | |
next unless row.has_key?(column_name) | |
if (found_rows.empty? or row[column_name] < found_rows.first[column_name]) | |
found_rows = [row] | |
elsif (row[column_name] == found_rows.first[column_name]) | |
found_rows.push(row) |
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 Integer | |
BASE = 95 | |
def convert_to_string | |
num = self | |
answer = "" | |
while (num > 0) | |
num -= 1 | |
digit = num % BASE | |
num /= BASE |
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 Point | |
attr_accessor :x, :y | |
def initialize(x, y) | |
@x = x | |
@y = y | |
end | |
def ==(point) | |
return (@x == point.x and @y == point.y) | |
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
require 'json' | |
require 'PP' | |
class Player | |
attr_accessor :name, :assists, :goals, :saves, :score, :shots, :teamID | |
def initialize(stats) | |
@name = stats['Name']['value']['str'] | |
@assists = stats['Assists']['value']['int'] | |
@goals = stats['Goals']['value']['int'] | |
@saves = stats['Saves']['value']['int'] |