How to run code
- Install Ruby on your devise
- Open a terminal or command prompt
- Navigate to the directory
- Run the Ruby code using ruby <file_name.rb> eg: ruby boxy.rb
Problem and there solution
- Problem 1: Given three numbers X, Y & Z. write a function/method that finds the greatest among the numbers.
- code: greatest_number.rb
- Problem 2: Write a program that prints the number from 1 to 100. But for multiples of three print “Fizz” instead of the number & for the multiples of five print “Buzz”. However, for numbers which are multiples of both three and five print “ FizzBuzz” instead.
- code: fizz_buzz.rb
- Problem 3: Loop over a string of arbitrary length, and count the occurrence of each character in the string.
Note: You can ignore accounting .
- code: character_count.rb
- Problem 4: Write a function/method in a generic manner such that it can convert from one number system to another; consider decimal to octal and binary. This method should take in three arguments as indicated below.
- code: number_system.rb
- Problem 5: Write a method - let's call it boxy(n) - which produces output in STDOUT as shown below
Example:
boxy(3)
Output:
- code: boxy.rb
- Problem 6: Model the following entity relation requirement. A system has many shops. A shop has many products, which can fall into one or many categories. The products can have different prices on different dates. The solution to this can be an ER diagram with crow-foot notation, or it can be a text file that lists relevant classes and has active record relation statements.