Search code examples
rubyalgorithmshoes

Using shoes ask() to do math?


Hi guys I am using shoes to tackle a problem for ign's code foo. The problem is

You own a license plate manufacturing company. Write a program that takes a population and determines the simplest pattern that will produce enough unique plates. Since all the plates that match the pattern will be generated, find the pattern that produces the least excess plates. Use a combination of letters (A-Z) and numbers (0-9).

I have tried to get a grip on shoes but why when I wrap a instance variable like this

@pop = ask("what is the Population?")

When I wrap it again like this:

@plates = @pop / 2

then again I want to create a simple alert

alert(@plates)

this isn't for the answer to the question this is just simpler. Just to learn. If you have any suggestions on actual coding of the project and how I can solve the problem.


Solution

  • Everything is almost right. However "@pop" is being assigned the "String" so you need to convert it to Float or whatever numerical type you wish, e.g.:

    @[email protected]_f/2