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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="description" content="Template strony w HTML'u 5"> | |
<meta name="keywords" content="html5, html, www"> | |
<meta name="author" content="Luaksz Wlodarczyk"> | |
<title>Wstep do HTML5</title> | |
<!--[if lt IE 9]> |
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
require 'benchmark' | |
def make_change(change, *coins) | |
coins.empty? ? coins = [200, 100, 50, 20, 10, 5, 2, 1] : coins = coins.flatten | |
denom = [] | |
c = Array.new(change) {|index| index = Float::INFINITY}.unshift(0) | |
(1..change).each do |j| | |
coins.each do |coin| | |
if j >= coin && 1+c[j-coin] < c[j] | |
c[j] = 1+c[j-coin] |
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
def make_change(number, *coin_values) | |
coin_values.empty? ? cents = [50, 20, 10, 5, 2, 1] : cents = coin_values.flatten.sort!.reverse | |
rest = [] | |
while number > 0 | |
el = cents.select {|x| (number % x) == 0} | |
number.div(el.first.to_i).times { rest << el.first } | |
number -= el.first.to_i * number.div(el.first.to_i) | |
cents.pop(el.first) | |
end | |
print rest.flatten |
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
def make_change(number, *coin_values) | |
coin_values.empty? ? cents = [50, 20, 10, 5, 2, 1] : cents = coin_values.flatten.sort!.reverse | |
rest = [] | |
while number > 0 | |
if number >= cents.first | |
number.div(cents.first).times { rest << cents.first } | |
number -= (cents.first * number.div(cents.first)) | |
cents.shift | |
else | |
cents.shift |
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
def make_change(number, *coin_values) | |
coin_values.empty? ? cents = [50, 20, 10, 5, 2, 1] : cents = coin_values.flatten | |
rest = [] | |
if number > 0 | |
cents.each do |c| | |
while c <= number | |
number -= c | |
rest << c | |
end | |
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 Converter | |
ROMANS = {'M' => 1000, 'D' => 500, 'C' => 100, 'L' => 50, 'X' => 10, 'V' => 5, 'I' => 1} | |
def is_roman?(line) | |
line = /[MDCLXVI]+/ | |
end | |
def is_arabic?(line) | |
line = /^(?:[123]\d{3}|[1-9]\d{0,2})$/ |