This file contains hidden or 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
package scala.euler | |
/* | |
* Task: http://projecteuler.net/problem=1 | |
* Description: Find the sum of all the multiples of 3 or 5 below 1000. | |
*/ | |
class ArrayFilter(n: Int) { | |
val preparedArray = Array.range(1, n) |
This file contains hidden or 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 Array | |
def selection_sort | |
(0...length).each do |i| | |
min = i | |
(i+1...length).each do |j| | |
min = j if self[j] < self[i] | |
end | |
self[i], self[min] = self[min], self[i] | |
end |
This file contains hidden or 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 isAnagramOfPalindrome (s) | |
return 0 if s.length < 2 # no need to check 1 or 0 character words | |
# # returns letters in hash | |
# f.e. "aabcba" ===> {"c"=>["c"], "b"=>["b", "b"], "a"=>["a", "a", "a"]} | |
letters = s.split("").group_by{|x| x} | |
# selects these arrays where size is odd and checks if it's empty | |
return 1 if letters.select{|key,value| value.length % 2 != 0 }.empty? | |
return 0 # return for clarity |
This file contains hidden or 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 Queue | |
def initialize(val) | |
@head = Container.new(val) | |
end | |
def add(val) | |
temp = Container.new(val) | |
head = @head | |
loop do | |
break unless head.next |
This file contains hidden or 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 Complex | |
def initialize(_re = 0.0, _im = 0.0) | |
self.re = _re | |
self.im = _im | |
end | |
def +(val) | |
Complex.new(self.re + val.re, self.im + val.im) | |
end | |
This file contains hidden or 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
module Models | |
module DateScope | |
extend ActiveSupport::Concern | |
included do | |
default_scope order('date_start ASC') | |
end | |
module ClassMethods | |
#== Some more methods |
This file contains hidden or 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
function Test() { | |
this.nazwa = "test"; | |
} | |
Test.prototype.a = function() { | |
console.log(this.nazwa); | |
return "lol"; | |
} | |
Test.prototype.b = function() { |
This file contains hidden or 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 Fraction | |
@numerator, @denominator = 0,0 | |
def initialize(n = 0,d = 0) | |
@numerator, @denominator = n, d | |
end | |
def read | |
@numerator, @denominator = gets.chomp, gets.chomp | |
end | |
def write | |
puts "#{@numerator} / #{@denominator}" |
This file contains hidden or 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
.btn-warning { | |
background-color: #faa732; | |
background-image: -moz-linear-gradient(top, #fbb450, #f89406); | |
background-image: -ms-linear-gradient(top, #fbb450, #f89406); | |
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406)); | |
background-image: -webkit-linear-gradient(top, #fbb450, #f89406); | |
background-image: -o-linear-gradient(top, #fbb450, #f89406); | |
background-image: linear-gradient(top, #fbb450, #f89406); | |
background-repeat: repeat-x; | |
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fbb450', endColorstr='#f89406', GradientType=0); |
NewerOlder