Skip to content

Instantly share code, notes, and snippets.

View imouaddine's full-sized avatar

Imad Mouaddine imouaddine

  • Measured
  • Casablanca
View GitHub Profile
@imouaddine
imouaddine / gist:8284d641984307280363
Created November 6, 2014 19:49
Minimum distance between two words in a string
def distance(a,b)
words = "I am a good girl".split(/\W+/)
a_found = false
b_found = false
prev = nil
words.each_with_index do |word, index|
if word == a
def product_max(a)
max_so_far = 1
min_so_far = 1
max = 1
a.each do |i|
def isomorphic(a,b)
if a.length == 0 && b.length == 0
true
elsif a.length != b.length
false
else
a_stru = b_stru = Hash.new{|hash, key| hash[key] =[] }
b_stru = Hash.new{|hash, key| hash[key] =[] }
@imouaddine
imouaddine / Largest Sum Contiguous Subarray
Last active August 29, 2015 14:08
Largest Sum Contiguous Subarray
def max_subarray(a)
max = - Float::INFINITY
max_at = []
sum = 0
sum_at = []
a.each_with_index do |e, i|
@imouaddine
imouaddine / gist:9104270
Created February 20, 2014 00:06
Fixed template.php of current
<?php
$style = theme_get_setting('style');
switch ($style) {
case 1:
drupal_add_css(drupal_get_path('theme', 'current') . '/css/style1.css', array('group' => CSS_THEME, 'weight' => 100, 'type' => 'file'));
break;
case 2:
drupal_add_css(drupal_get_path('theme', 'current') . '/css/style2.css', array('group' => CSS_THEME, 'weight' => 100, 'type' => 'file'));