This file contains 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 Change | |
def change(amount) | |
coins = [] | |
remaining_amount = amount | |
while remaining_amount != 0 | |
coin = get_highest_coin(remaining_amount) | |
coins << coin | |
remaining_amount = remaining_amount - coin | |
end | |
coins |
This file contains 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 Change | |
def change(amount) | |
available_coins = [100,50,25,10,5,1] # http://en.wikipedia.org/wiki/Coins_of_the_United_States_dollar | |
coins = [] | |
index = 0 | |
coin = available_coins[index] | |
remaining_amount = amount | |
until remaining_amount == 0 | |
until remaining_amount >= coin | |
index = index + 1 |
This file contains 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 Change | |
def change(amount) | |
available_coins, coins, remaining_amount = [100,50,25,10,5,1], [], amount | |
available_coins.each { | coin | | |
if remaining_amount - coin >= 0 | |
remaining_amount / coin != 0 ? (remaining_amount / coin).to_int.times { coins << coin } : coins << coin | |
puts "Remaining Amount: #{remaining_amount} | Coin: #{coin}" # console feedback :-) | |
remaining_amount = amount - coins.inject(:+) # see: http://stackoverflow.com/a/1538801/1148249 | |
end | |
} |
This file contains 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 Change | |
def change(amount) | |
available_coins, coins, remaining_amount = [100,50,25,10,5,1], [], amount; available_coins.each { |coin| if ((remaining_amount/coin).to_int > 0) then (remaining_amount/coin).to_int.times { coins << coin }; remaining_amount = amount-coins.inject(:+) end }; return coins | |
end | |
end | |
describe Change do | |
it "returns [1] for 1" do | |
expect(subject.change(1)).to eq [1] | |
end |
This file contains 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
<html> | |
<head> | |
<title> Disco Squares</title> | |
</head> | |
<body> | |
<style type="text/css"> | |
html, body, #game { | |
width: 100%; | |
height: 100%; | |
margin: 1px; |
This file contains 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
{ | |
"attributes" : { | |
"type" : "Application__c", | |
"url" : "/services/data/v27.0/sobjects/Application__c/a07b0000004bXrFAAU" | |
}, | |
"Mandatory__c" : false, | |
"LastModifiedById" : "005b0000000MGa7AAG", | |
"Featured_End_Date__c" : "2013-04-26T16:16:00.000+0000", | |
"OwnerId" : "005b0000000MGa7AAG", | |
"LastModifiedDate" : "2013-04-11T14:43:15.000+0000", |
This file contains 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
<html> | |
<h1>Sort</h1> | |
<!-- enable the Chrome Developer Console to see Results --> | |
<script> | |
str = 'X,a,A,C,D,F,1,c,4,3' | |
data = str.split(',') | |
console.dir(data) | |
counter = 0; | |
limit = data.length; | |
end = limit-1; |
This file contains 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
/** | |
* @author Nimil Christopher | |
* @date 12 April 2013 | |
* @description This class has the Rest Callouts to publish an application to | |
* the CDN | |
*/ | |
public with sharing class HTTPHelper { | |
public static Http http; | |
This file contains 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
http = require 'http' # Require the HTTP Core NodeJS Module (notice the lack of brackets) | |
port = process.env.PORT or 4000 # The TCP port you want to "listen" on (see line #6) allows the system (e.g. Heroku to set it or uses 4000 on local machine) | |
http.createServer (req, res) -> # Creates a basic Web Server and gives you the REQuest and RESponse objects to the function | |
res.writeHead 200 # Write the HTTP Status Code "200" ("All OK") in the RESponse to the client (browser) | |
res.end 'Hello World!' # End the RESponse with the message 'Hello World' | |
.listen port # the dot before the word listen means "Chain" to the createServer and listen on the port | |
console.log "Visit: http://localhost:#{port}" # console.log allows you to write a "Note-to-self" on the command line. | |
### if any of the above is unclear, Google it! (or msg me for a personal Tutorial: https://twitter.com/nelsonic) ### |
This file contains 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
<apex:page standardController="Opportunity" extensions="jquery_minihack"> | |
<style> | |
#myTitle { | |
font-size:20px; | |
text-align: center; | |
} | |
.element { | |
width:50%; |
OlderNewer