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
<?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')); |
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
def max_subarray(a) | |
max = - Float::INFINITY | |
max_at = [] | |
sum = 0 | |
sum_at = [] | |
a.each_with_index do |e, i| |
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
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] =[] } |
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
def product_max(a) | |
max_so_far = 1 | |
min_so_far = 1 | |
max = 1 | |
a.each do |i| |
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
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 |
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
class LinkedList | |
attr_accessor :head, :tail | |
class Node | |
attr_accessor :previous, :next, :value | |
def initialize(value) | |
@value = value | |
end | |
end |
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
def compress_length(a) | |
if a.length < 3 | |
return a | |
end | |
result = "" | |
count = 1 | |
a.chars.each_with_index do |c, index| | |
if c == a[index+1] |
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
def rotate_matrix(a, length) | |
(0).upto(length -1) do |i| | |
(i+1).upto(length -1) do |j| | |
a[i][j], a[j][i] = a[j][i], a[i][j] | |
end | |
end | |
a | |
end |
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
def remove_duplicates | |
unless head && head.next | |
return self | |
end | |
current = head | |
while(current) | |
runner = current.next | |
_previous = current | |
while(runner) | |
if runner.value == current.value |
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
class LinkedList | |
attr_accessor :head, :tail | |
class Node | |
attr_accessor :previous, :next, :value | |
def initialize(value) | |
@value = value | |
end | |
end |
OlderNewer