From 0ff4d2997ffb0dac766e6944a5bd026e2f512b08 Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Thu, 27 Oct 2016 12:39:42 -0700 Subject: [PATCH 01/15] completed 00_hello --- .DS_Store | Bin 0 -> 8196 bytes 00_hello/hello.rb | 6 ++++++ 02_calculator/calculator.rb | 31 +++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 .DS_Store create mode 100644 00_hello/hello.rb create mode 100644 02_calculator/calculator.rb diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..df10b46e608a7b6d16e2eb04c9972580946d93a1 GIT binary patch literal 8196 zcmeHM-A>d%6g~qeMZiT-A@Qacns`A7e+wF8vLeKAVPagP7iyMvyFjJeZrUy@B4%%V z2)*>e#7FT7d=MW%zcU@lw3I|{jD{J~In(xh=jWRk^#H6{C*l#dQ{ati=Cgv+vFjD3K_*h}OI!VKdu32n7{tiy<;N?%S*m zSyQr~$qY^+gOgC6h1#JA=^Z#*s*|W?()5M_!@zL{c<*k}9R3=#qwn9{AaZe!m(yJw zw|>foQHj3WOFBybo7)NeB%Pc4E(QjN&Yd5&Mn!QTM1a1Fp0N?dd8C*sK`sKB zkPojBg>vlBJ|zX@hXQg8K9``~0dgBM^XOAp!2KxTD!^5hNB+RGkFg6GA@1FxS6MD! zv~sxy^s@BI{A_WCh}%KjO)%C_IrwF{6SJn<;z(A2IVx3*w_wkQrI5Tr9?YDM=J~n} zgo_v=M9wqEegmM(xYMz`NbV>^n`gS&oc;*(*Xcg3(Id!NS#Y j{lgGr8>)<{DcR2?uAu$>4*}-=U-)fe-v6=^&sO&fDhy60 literal 0 HcmV?d00001 diff --git a/00_hello/hello.rb b/00_hello/hello.rb new file mode 100644 index 000000000..97176ed02 --- /dev/null +++ b/00_hello/hello.rb @@ -0,0 +1,6 @@ +def hello + "Hello!" +end +def greet(who) + "Hello, #{who}!" +end \ No newline at end of file diff --git a/02_calculator/calculator.rb b/02_calculator/calculator.rb new file mode 100644 index 000000000..d5957ab4f --- /dev/null +++ b/02_calculator/calculator.rb @@ -0,0 +1,31 @@ +def add(x, y) + x + y +end + +def subtract(x, y) + x - y +end + +def sum(array) + if array.length == 0 + 0 + else + array.inject{|result, n| result + n} + end +end + +def multiply(array) + array.inject{|result, n| result * n} +end + +def power(x, y) + x ** y +end + +def factorial(number) + if number == 0 + return 1 + else + (1..number).inject{|result, n| result * n} + end +end \ No newline at end of file From 8d79e3ab9aba14bcffbabaf378ba08f0f18fed6b Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Thu, 27 Oct 2016 12:41:52 -0700 Subject: [PATCH 02/15] completed 01_temperature --- .DS_Store | Bin 8196 -> 10244 bytes 01_temperature/temperature.rb | 15 +++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 01_temperature/temperature.rb diff --git a/.DS_Store b/.DS_Store index df10b46e608a7b6d16e2eb04c9972580946d93a1..3bf6892c42565fd401690d986e994de4ba23f006 100644 GIT binary patch delta 167 zcmZp1XbF&DU|?W$DortDU{C-uIe-{M3-C-V6q~50$SA)tU^hRb{AM133dYGEg0hnX z1a5$6p0ePgyqx^Jbf99!$&G@JlRE^(!ICY4(kPOfcMJNkZEQHiD##2}3j_+>K*AMd j$Hv0%%#-w}Eq$eK` tQr;xu$|lGRR0RYQ+(5z=q+w&>cjn3bDuEn~5Mvl7$Ma0vY$MLb3;^xO6G{L8 diff --git a/01_temperature/temperature.rb b/01_temperature/temperature.rb new file mode 100644 index 000000000..a083e4356 --- /dev/null +++ b/01_temperature/temperature.rb @@ -0,0 +1,15 @@ +def ftoc(temp) + temp = temp.to_f + temp -= 32 + temp *= 5 + temp /= 9 + temp +end + +def ctof (temp) + temp = temp.to_f + temp *= 9 + temp /= 5 + temp += 32 + temp +end From bd69f6fa2fc2dcfa0a9b306d9bc6e2ed2c65f4b7 Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Thu, 27 Oct 2016 12:45:00 -0700 Subject: [PATCH 03/15] completed 02_calculator --- 02_calculator/calculator_spec.rb | 37 +++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/02_calculator/calculator_spec.rb b/02_calculator/calculator_spec.rb index fef7e9d00..a2dd1a8e2 100644 --- a/02_calculator/calculator_spec.rb +++ b/02_calculator/calculator_spec.rb @@ -79,21 +79,38 @@ describe "#multiply" do - it "multiplies two numbers" - - it "multiplies several numbers" - + it "multiplies two numbers" do + expect(multiply([3,7])).to eq(21) + end + it "multiplies several numbers" do + expect(multiply([3,7,2])).to eq(42) + end end describe "#power" do - it "raises one number to the power of another number" + it "raises one number to the power of another number" do + expect(power(2,3)).to eq(8) + end + it "returns 1 if exponent is 0" do + expect(power(1,0)).to eq(1) + end end # http://en.wikipedia.org/wiki/Factorial describe "#factorial" do - it "computes the factorial of 0" - it "computes the factorial of 1" - it "computes the factorial of 2" - it "computes the factorial of 5" - it "computes the factorial of 10" + it "computes the factorial of 0" do + expect(factorial(0)).to eq(1) + end + it "computes the factorial of 1" do + expect(factorial(1)).to eq(1) + end + it "computes the factorial of 2" do + expect(factorial(2)).to eq(2) + end + it "computes the factorial of 5" do + expect(factorial(5)).to eq(120) + end + it "computes the factorial of 10" do + expect(factorial(10)).to eq(3628800) + end end From 2f02d6f66a28c1da9c6ed85bf7b834cdf6b837a7 Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Thu, 27 Oct 2016 13:19:45 -0700 Subject: [PATCH 04/15] completed 03_simon_says --- 03_simon_says/simon_says.rb | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 03_simon_says/simon_says.rb diff --git a/03_simon_says/simon_says.rb b/03_simon_says/simon_says.rb new file mode 100644 index 000000000..83e25ab0f --- /dev/null +++ b/03_simon_says/simon_says.rb @@ -0,0 +1,38 @@ +def echo(string) + string +end + +def shout(string) + string.upcase +end + +def repeat(string, n = 2) + new_string = (string + " ") * n + new_string.strip! +end + +def start_of_word(string, n) + letters = string.split '' + letters[0..(n-1)].join '' +end + +def first_word(string) + words = string.split ' ' + words[0] +end + +def titleize(string) + words = string.split ' ' + little_words = ["and", "the", "over"] + if little_words.include? words[0] + words[0][0] = words[0][0].upcase + end + words.each do |word| + if little_words.include? word + next + else + word[0] = word[0].upcase + end + end + words.join ' ' +end \ No newline at end of file From 340e17718cf0c4af9202f6e9b8a1fd5bc69309a7 Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Thu, 27 Oct 2016 14:45:24 -0700 Subject: [PATCH 05/15] completed 04_pig_latin --- .DS_Store | Bin 10244 -> 10244 bytes 04_pig_latin/pig_latin.rb | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 04_pig_latin/pig_latin.rb diff --git a/.DS_Store b/.DS_Store index 3bf6892c42565fd401690d986e994de4ba23f006..ac3034e71bd51407f2b742e85f216772a0465069 100644 GIT binary patch delta 122 zcmZn(XbG6$UDU^hRb;$|L!B$ml$B9fCA3f@rVVK87YVTflaV8~=h2huqVi3}w` lc3xR`{!A5s7S delta 38 ucmZn(XbG6$&nUk!U^hRb{AM13B$mzXq77Ud8zdPwvn%{!*(@c-%nShb5DTpU diff --git a/04_pig_latin/pig_latin.rb b/04_pig_latin/pig_latin.rb new file mode 100644 index 000000000..81024ebbd --- /dev/null +++ b/04_pig_latin/pig_latin.rb @@ -0,0 +1,21 @@ +def translate(string) + translation = '' + vowels = ["a", "e", "i", "o", "u"] + words = string.split ' ' + words.each do |word| + letters = word.split '' + until vowels.include? letters[0] + letter = letters.shift + letters.push letter + end + #if next letter is q, checks end of word for u and shifts it if necessary + if letters[0] == "u" && letters[-1] == "q" + letter = letters.shift + letters.push letter + end + letters.push "ay" + translation += (letters.join '') + ' ' + end + translation.strip! +end +translate("quiet") \ No newline at end of file From 376a093629690ebe9ad5899ed60aa0665543bc58 Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Thu, 27 Oct 2016 15:39:55 -0700 Subject: [PATCH 06/15] completed 05_silly_blocks --- .DS_Store | Bin 10244 -> 10244 bytes 05_silly_blocks/silly_blocks.rb | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 05_silly_blocks/silly_blocks.rb diff --git a/.DS_Store b/.DS_Store index ac3034e71bd51407f2b742e85f216772a0465069..758369b032322672cb193e5b8c9d4345689daec9 100644 GIT binary patch delta 169 zcmZn(XbG6$XEU^hRb=4Kv&ovf4FMdc?i6ubeVdCG!|@^bR?(is>S7$+YR^`CrH zR2M7>q){dL#J*47Ev5~Y1k$LIOyc#E?ZuTR{}Q?Zrr!$lZ*COd#=MzbVINTzE(8Ff C;X7vl delta 69 zcmZn(XbG6$UDU^hRb;$|L!ovf41#C0c&i_1?gm-sSyg;dSvK$&gK8yhaLY-U&3 Lhao#TP^K9GN;VkE diff --git a/05_silly_blocks/silly_blocks.rb b/05_silly_blocks/silly_blocks.rb new file mode 100644 index 000000000..1b9997337 --- /dev/null +++ b/05_silly_blocks/silly_blocks.rb @@ -0,0 +1,16 @@ +def reverser + words = yield.split ' ' + words.each do |word| + word.reverse! + end + words.join ' ' +end + +def adder(add=1) + yield + add +end + +def repeater(repeat=1) + repeat.times do yield + end +end \ No newline at end of file From d65a9e410f4558ea4cfd204f811e003339062c2a Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Thu, 27 Oct 2016 15:57:40 -0700 Subject: [PATCH 07/15] completed 06_performance_monitor --- 06_performance_monitor/performance_monitor.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 06_performance_monitor/performance_monitor.rb diff --git a/06_performance_monitor/performance_monitor.rb b/06_performance_monitor/performance_monitor.rb new file mode 100644 index 000000000..c0d753eca --- /dev/null +++ b/06_performance_monitor/performance_monitor.rb @@ -0,0 +1,7 @@ +def measure(n=1) + start = Time.now + n.times do + yield + end + (Time.now - start) / n +end \ No newline at end of file From 7b95b15cc16d9092fe2e334b253ad2420c12eeb6 Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Thu, 27 Oct 2016 16:07:08 -0700 Subject: [PATCH 08/15] completed 07_hello_friend --- .DS_Store | Bin 10244 -> 12292 bytes 07_hello_friend/friend.rb | 9 +++++++++ 2 files changed, 9 insertions(+) create mode 100644 07_hello_friend/friend.rb diff --git a/.DS_Store b/.DS_Store index 758369b032322672cb193e5b8c9d4345689daec9..652d64698e55775c7689a721f6a2ac5f374a717d 100644 GIT binary patch delta 219 zcmZn(Xh~3DU|?W$DortDV2}VZIe-{M3vdI8b_NCoo{0+TvdlmZBM@r?F_105z!1++ zz>vyN#E{02Ke14GvVjTln(rGpIKyh&mPn+lHayZSKx;TA iXQ<4aoFkmJIbL)r6UfORAhelBK%Zk{$z=A44Q2q Date: Thu, 27 Oct 2016 16:33:21 -0700 Subject: [PATCH 09/15] completed 08_book_titles --- .DS_Store | Bin 12292 -> 12292 bytes 08_book_titles/.DS_Store | Bin 0 -> 6148 bytes 08_book_titles/book.rb | 19 +++++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 08_book_titles/.DS_Store create mode 100644 08_book_titles/book.rb diff --git a/.DS_Store b/.DS_Store index 652d64698e55775c7689a721f6a2ac5f374a717d..46325791306e0feba0bc98a5dbcc2675411343a4 100644 GIT binary patch delta 218 zcmZokXh~3DU|?W$DortDV9)?EIe-{M3-ADmb_NCo?uiQejQSG;3MPxo%S;v!(b&ww z$j;9wGjW2!WEPPd6DM0ub`n(FtS8XGIJrnrcJe~SJCn-P|c$Gg(m3V6u(C!p$rSMl6%NRV6p)sLp0WmAtW8gz+=mWCg}+07S(p AKmY&$ diff --git a/08_book_titles/.DS_Store b/08_book_titles/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..070ec759756617eda72355618cb5ea178747ae57 GIT binary patch literal 6148 zcmeHKJxc>Y5PhQoLu>*zmRnj0);33og|$B*a*3ei^nxE?d5u5DU#V|C5=^{K5RsWM z^Cr79v$qd!_XdDWUKVG-7{HLKDC+cx4);#&MesgRti~xGQC~Lgyl#35{ly`D_5;*t z`CH=4^S3o;NQ=A?Pd-d+14oEWU<^vXte`WkFtK6e; z=GH6YeJ973Pm>HJ1Ia)#kPQ5g0p8gv!$Zfk$v`rY3~U(C^Px}`tH93Djt&}Y0f++* zo6y%@LUT%B71%j)h9aIy^i+u!Lp+`1CE}{U&e78$(R@g(yl!5^R%iWU;gHHPZ8DGy zY%`#}FJ-Lv{{>%}-X`Bd(j)`Pz<*^x2GgtQgu9Eo_1ix6t}WDSs*1*S>QLx!eFX52 ho+HOL>GMT>##MoxqgK&zODE=sfDw`=8TbVTJ^>F+IhFtb literal 0 HcmV?d00001 diff --git a/08_book_titles/book.rb b/08_book_titles/book.rb new file mode 100644 index 000000000..ff6bcd6e8 --- /dev/null +++ b/08_book_titles/book.rb @@ -0,0 +1,19 @@ +class Book + attr_accessor :title + + def title + words = @title.split ' ' + articles = ["the", "a", "an", "and", "in", "of"] + if articles.include? words[0] + words[0][0] = words[0][0].upcase + end + words.each do |word| + if articles.include? word + next + else + word[0] = word[0].upcase + end + end + words.join ' ' + end +end \ No newline at end of file From 2a2d1b4a302c738852e94a5bb82997dc66ccaa86 Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Thu, 27 Oct 2016 18:14:00 -0700 Subject: [PATCH 10/15] completed 09_timer --- .DS_Store | Bin 12292 -> 12292 bytes 09_timer/timer.rb | 35 +++++++++++++++++++++++++++++++++++ 09_timer/timer_spec.rb | 23 ++++++++++++----------- 3 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 09_timer/timer.rb diff --git a/.DS_Store b/.DS_Store index 46325791306e0feba0bc98a5dbcc2675411343a4..8f04ea6db8c50c870a7c803a8a0c79de5e787da5 100644 GIT binary patch delta 85 zcmZokXi1ph&uF+YU^hRb++;yPgUvPqEG&W?3 Date: Fri, 28 Oct 2016 11:01:05 -0700 Subject: [PATCH 11/15] completed 10_temperature_object --- .DS_Store | Bin 12292 -> 12292 bytes 10_temperature_object/.DS_Store | Bin 0 -> 6148 bytes 10_temperature_object/temperature.rb | 42 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 10_temperature_object/.DS_Store create mode 100644 10_temperature_object/temperature.rb diff --git a/.DS_Store b/.DS_Store index 8f04ea6db8c50c870a7c803a8a0c79de5e787da5..467a8f84b1771199172a303f8e25c9581b01105b 100644 GIT binary patch delta 96 zcmZokXi1ph&uF|cU^hRb!el`~gUvPqf@~b-mX-d^7zhS}fnXpQ_z45NvsK3X8AAsH!9XzZ!GN9*iA}L^>@wQX zL1iTXal~#D+WK79nB-VEb{RQBksM0Qq2eWm temperature) + end + #Factory method for inputs from F° + def self.from_fahrenheit(temperature) + Temperature.new(:f => temperature) + end +end +#Temperature subclass to convert input to C° +class Celsius < Temperature + def initialize(temperature) + @degreesc = temperature + @degreesf = (temperature * 9.0 / 5.0) + 32 + end +end +#Temperature subclass to convert input to F° +class Fahrenheit < Temperature + def initialize(temperature) + @degreesf = temperature + @degreesc = (temperature - 32) * 5.0 / 9.0 + end +end \ No newline at end of file From d294edb54d477de82b9e846a05e20f8dc0953aa4 Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Fri, 28 Oct 2016 11:57:32 -0700 Subject: [PATCH 12/15] complete 11_dictionary --- 11_dictionary/dictionary.rb | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 11_dictionary/dictionary.rb diff --git a/11_dictionary/dictionary.rb b/11_dictionary/dictionary.rb new file mode 100644 index 000000000..0da3d60a7 --- /dev/null +++ b/11_dictionary/dictionary.rb @@ -0,0 +1,51 @@ +class Dictionary + attr_accessor :entries + + #creates empty hash for entries + def initialize + @entries = {} + end + + #adds entries with key and value(if given) + def add(input) + if input.class == String + @entries[input] = nil + else + @entries.merge!(input) + end + end + + #returns keys alphabetically + def keywords + @entries.keys.sort + end + + #checks whether or not a given key is in @entries + def include?(word) + if @entries.keys.include?(word) + true + else + false + end + end + + #finds keys and parts of keys and returns all relevant entries + def find(search) + results = {} + @entries.each do |key, value| + if key.start_with? search + results[key] = value + end + end + results + end + + #sorts and prints @entries in [key] "value" format + def printable + printed = @entries.sort.map do |key,value| + "[#{key}] \"#{value}\"" + end + printed.join "\n" + end + +end \ No newline at end of file From f0ee3f35712923e2b7582fd996e611547b4ff8d4 Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Fri, 28 Oct 2016 12:40:02 -0700 Subject: [PATCH 13/15] completed 12_rpn_calculator --- .DS_Store | Bin 12292 -> 12292 bytes 12_rpn_calculator/rpn_calculator.rb | 88 ++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 12_rpn_calculator/rpn_calculator.rb diff --git a/.DS_Store b/.DS_Store index 467a8f84b1771199172a303f8e25c9581b01105b..efe573ea222cc0fa3b70de1ec2d0a909ca0e906b 100644 GIT binary patch delta 25 dcmZokXi3= 2 + @operands.push (@operands.pop + @operands.pop) + else + raise "calculator is empty" + end + end + #subtracts operands when possible, otherwise raises error + def minus + if @operands.size>= 2 + new_n = (@operands[-2] - @operands[-1]) + @operands.pop(2) + @operands.push new_n + else + raise "calculator is empty" + end + end + #divides operands when possible, otherwise raises error + def divide + if @operands.size>= 2 + new_n = (@operands[-2].to_f / @operands[-1].to_f) + @operands.pop(2) + @operands.push new_n + else + raise "calculator is empty" + end + end + #multiplies operands when possible, otherwise raises error + def times + if @operands.size>= 2 + new_n = (@operands[-2] * @operands[-1]) + @operands.pop(2) + @operands.push new_n + else + raise "calculator is empty" + end + end + #evaluates a string and turns components into operators or operands + def tokens(string) + operators = ["+", "-", "*", "/"] + inputs = string.split ' ' + tokenized = inputs.collect do |input| + if operators.include? input + input.to_sym + else + input.to_i + end + end + tokenized + end + #evaluats tokenized string + def evaluate(string) + tokens(string).each do |input| + if input == :+ + self.plus + elsif input == :- + self.minus + elsif input == :/ + self.divide + elsif input == :* + self.times + else + self.push input + end + end + self.value + end + +end + + + + From e3aa22c9baf8656683d444a6001bdef9fc146ed7 Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Fri, 28 Oct 2016 12:53:52 -0700 Subject: [PATCH 14/15] completed 14_array_extensions --- 14_array_extensions/array_extensions.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 14_array_extensions/array_extensions.rb diff --git a/14_array_extensions/array_extensions.rb b/14_array_extensions/array_extensions.rb new file mode 100644 index 000000000..f0b1711d2 --- /dev/null +++ b/14_array_extensions/array_extensions.rb @@ -0,0 +1,13 @@ +class Array + def sum + self.inject(0){|sum,x| sum + x} + end + + def square + self.map {|x| x * x} + end + + def square! + self.map! {|x| x * x} + end +end \ No newline at end of file From 3beba21d1eeafe016c81e0b835ea9d4edadd558e Mon Sep 17 00:00:00 2001 From: Jonathan Popenuck Date: Fri, 28 Oct 2016 15:44:05 -0700 Subject: [PATCH 15/15] completed 15_in_words --- 15_in_words/in_words.rb | 81 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 15_in_words/in_words.rb diff --git a/15_in_words/in_words.rb b/15_in_words/in_words.rb new file mode 100644 index 000000000..ef5560e2f --- /dev/null +++ b/15_in_words/in_words.rb @@ -0,0 +1,81 @@ +class Fixnum + def in_words(number = 0) + number = self + if number == 0 + return 'zero' + end + + number_phrase = '' + ones = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'] + tens = ['ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'] + teens = ['eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'] + left_over = number + + calculating = left_over / 1000000000000 + left_over = left_over - calculating * 1000000000000 + if calculating > 0 + trillions = calculating.in_words + number_phrase = number_phrase + trillions + ' trillion' + if left_over > 0 + number_phrase = number_phrase + ' ' + end + end + calculating = left_over / 1000000000 + left_over = left_over - calculating * 1000000000 + if calculating > 0 + billions = calculating.in_words + number_phrase = number_phrase + billions + ' billion' + if left_over > 0 + number_phrase = number_phrase + ' ' + end + end + calculating = left_over / 1000000 + left_over = left_over - calculating * 1000000 + if calculating > 0 + millions = calculating.in_words + number_phrase = number_phrase + millions + ' million' + if left_over > 0 + number_phrase = number_phrase + ' ' + end + end + calculating = left_over / 1000 + left_over = left_over - calculating * 1000 + if calculating > 0 + thousands = calculating.in_words + number_phrase = number_phrase + thousands + ' thousand' + if left_over > 0 + number_phrase = number_phrase + ' ' + end + end + calculating = left_over / 100 + left_over = left_over - calculating * 100 + if calculating > 0 + hundreds = calculating.in_words + number_phrase = number_phrase + hundreds + ' hundred' + if left_over > 0 + number_phrase = number_phrase + ' ' + end + end + calculating = left_over / 10 + left_over = left_over - calculating * 10 + if calculating > 0 + if ((calculating == 1) and (left_over > 0)) + number_phrase = number_phrase + teens[left_over-1] + left_over = 0 + else + number_phrase = number_phrase + tens[calculating-1] + end + + if left_over > 0 + number_phrase = number_phrase + ' ' + end + end + calculating = left_over + left_over = 0 + + if calculating > 0 + number_phrase = number_phrase + ones[calculating-1] + end + number_phrase + end +end \ No newline at end of file