Skip to content

Instantly share code, notes, and snippets.

View HuzaifaSaifuddin's full-sized avatar

Huzaifa Saifuddin HuzaifaSaifuddin

  • Bengaluru, Karnataka
View GitHub Profile
# 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'
@HuzaifaSaifuddin
HuzaifaSaifuddin / integer_reverse.rb
Created June 22, 2021 06:36
Reverse an Integer in Ruby using Mathematics
# Monkey-Patching the Integer Class
class Integer
def reverse
x = self.abs
y = 0
while x != 0
y *= 10
y += (x % 10)
x /= 10