Skip to content

Instantly share code, notes, and snippets.

View vijithmv499's full-sized avatar

Vijith M V vijithmv499

  • MavenHive Technologies Private Limited
  • HSR Layout Bangalore
View GitHub Profile
@vijithmv499
vijithmv499 / roman_numerals.rb
Created April 24, 2016 13:19
Exercism assignment 8 - Number to Roman nemerals conversion (http://exercism.io/exercises/ruby/roman-numerals/readme)
class Fixnum
VERSION = 1
NUMERALS = {
1000 => 'M',
900 => 'CM',
500 => 'D',
400 => 'CD',
100 => 'C',
90 => 'XC',
50 => 'L',
class Complement
H = {
'G' => 'C',
'C' => 'G',
'T' => 'A',
'A' => 'U'
}
VERSION = 3
def self.of_dna(dna)
a = dna.split('')
class Raindrops
VERSION = 1
def self.convert(num)
dup = num
a = []
while num > 1
for i in (2..num)
if num%i == 0
num = num / i
a << i
@vijithmv499
vijithmv499 / pangram.rb
Last active April 24, 2016 13:08
Exercism assignment 7 - Pangram sentences (http://exercism.io/exercises/ruby/pangram/readme)
class Pangram
VERSION = 1
def self.is_pangram?(str)
ref = ('a'..'z').to_a
str.downcase.split('').select{|i| ref.include?(i)}.uniq.sort == ref
end
end
@vijithmv499
vijithmv499 / hamming.rb
Created April 24, 2016 13:05
Exercism assignment 2 - Hamming differnce between two DNA strands (http://exercism.io/exercises/ruby/hamming/readme)
class Hamming
VERSION = 1
def self.compute(x,y)
distance = 0
if x.length == y.length
x.split('').each_with_index do |elem,i|
distance = distance + 1 unless y[i] == elem
end
return distance
else
class Gigasecond
GS = 10**9
VERSION = 1
def self.from(date)
return date + GS
end
end
class Squares
attr_accessor :number
VERSION = 2
def initialize(num)
self.number = num
end
def square_of_sum
self.number > 0 ? ((1..self.number).to_a.inject(:+))**2 : 0
end