Skip to content

Commit

Permalink
Implemented 5 -> V
Browse files Browse the repository at this point in the history
  • Loading branch information
chendo committed Jul 22, 2011
1 parent 7fbefb9 commit 1da12f8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app/coffeescripts/roman.coffee
Expand Up @@ -5,7 +5,10 @@ window.toRoman = (number) ->
output = ''
number = number * 1
while number > 0
if number == 4
if number == 5
output += 'V'
number -= 5
else if number == 4
output += 'IV'
number -= 4
else
Expand Down
5 changes: 4 additions & 1 deletion public/javascripts/compiled/roman.js
Expand Up @@ -4,7 +4,10 @@
output = '';
number = number * 1;
while (number > 0) {
if (number === 4) {
if (number === 5) {
output += 'V';
number -= 5;
} else if (number === 4) {
output += 'IV';
number -= 4;
} else {
Expand Down
1 change: 1 addition & 0 deletions spec/coffeescripts/roman_spec.coffee
Expand Up @@ -9,6 +9,7 @@ describe 'toRoman()', ->
2: 'II'
3: 'III'
4: 'IV'
5: 'V'

for integer, roman of tests
testRoman integer, roman
3 changes: 2 additions & 1 deletion spec/javascripts/roman_spec.js
Expand Up @@ -10,7 +10,8 @@
1: 'I',
2: 'II',
3: 'III',
4: 'IV'
4: 'IV',
5: 'V'
};
_results = [];
for (integer in tests) {
Expand Down

0 comments on commit 1da12f8

Please sign in to comment.