Created
January 31, 2014 12:41
-
-
Save leonmaia/8731445 to your computer and use it in GitHub Desktop.
teste
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
merchants_guide_to_the_galaxy | |
============================= | |
##Instructions: | |
The program input must be at the input.txt file | |
The output will be printed at the output.txt file | |
1. go to the folder and run the console.rb file | |
$ ruby console.rb | |
or run the tests.. | |
$ rspec spec | |
and the output will be generated. | |
gems i used: rspec | |
ruby version: 2.0.0-p353 | |
###Brief Explanation | |
roman_converter && resolution_rules: | |
All starts with the roman to decimal conversion, i made it getting the last symbol and comparing with the previous one, | |
if the previous one was bigger than the present one they would be elegible to a subtraction, after this i check if this elegible subtraction would be valid. | |
After this we have 2 more validations, the one which do the counting i decided to try resolve it with regular expressions. | |
input_processor && variables: | |
Here i basically used regular expressions to separate the data from the input.txt an put the organized data at the Variables object. | |
output_processor: | |
When i got to create this one i started to thing about the problem and found this possible solution: | |
-------------------------------------------------------------------------------------------- | |
glob is I | |
prok is V | |
pish is X | |
tegj is L | |
glob glob Silver is 34 Credits -> II Silver = 34 | |
2 * Silver = 34 => Silver = 17 | |
glob prok Gold is 57800 Credits -> IV Gold = 57800 | |
4 * Gold = 57800 => Gold = 14450 | |
pish pish Iron is 3910 Credits -> XX Iron = 3910 | |
20 * Iron = 3910 => Iron = 195.5 | |
-------------------------------------------------------------------------------------------- | |
This class basically implements this idea. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment