This file contains 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
# frozen_string_literal: true | |
# Design a parking lot system where: | |
# - I can define set number of parking slots for the type of vehicle (say, 20 slots for Cars, 40 slots for motor bikes). | |
# - I can define hourly rate for the types of vehicle we have (say, 30Rs / hour for car, 15Rs / hour for motor bikes). | |
# - I can assign slot to a vehicle and provide ticket to the customer. | |
# - I can calculate parking price based on ticket provided by the customer and release the parking slot. | |
# - You can multiple ticket dispatchers within the facility | |
require 'time_difference' |
This file contains 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
# Monkey-Patching the Integer Class | |
class Integer | |
def reverse | |
x = self.abs | |
y = 0 | |
while x != 0 | |
y *= 10 | |
y += (x % 10) | |
x /= 10 |