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
# The following code solves this problem: http://rosalind.info/problems/glob/ | |
# * it takes data from the input file, in FASTA format (as the problem states). Input file name may be given as a parameter to script | |
# * it writes the result to file named 'output.txt' | |
# * Additionally, it writes to console result && backtracing log | |
# P.S. - Yeees, I know, my english is awful. Please, feel free to review it too =) | |
# | |
# ruby version: 1.9.3 | |
# version 1 - doesn't show backtracing | |
# version 2 - shows some optimal alignment | |
# version 3 - shows all possible backtracings recursively |
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
require 'rsa' # using rsa gem: http://rsa.rubyforge.org/index.html | |
# core library has some methods for modular arithmetics, but rsa gem has some additional methods. | |
# I've tried to use them to find plaintext | |
# ----------- | |
#known constants | |
# ------------- | |
E = 29 | |
M_POWER = 3 |
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
# ruby 1.9.3 | |
# ---------------- | |
# Constants | |
# ---------------- | |
ASSOCIATED_BRACKETS = {'[' => ']', '(' => ')', '{' => '}'} | |
# it's just a hash of pairs (just for convinience). | |
# little bit of ruby Hash class documentation applied to that hash object: | |
# ASSOCIATED_BRACKETS.keys - returns opening brackets as Array | |
# ASSOCIATED_BRACKETS.has_key?(obj) - checks if obj is contained between keys in hash |
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
# hw 5 problem 4 solution (Algorithms and datastructures course) | |
# Problem is stated as follows: as input we get array of n elements a[0].. a[n - 1] | |
# !!!!!!!!!!!!!! in this code elements numerated from zero index | |
# must find a way to process it and find l and r indices such that (r - l + 1)*min(a[i], i in [l, r]) is maximized | |
# | |
# ruby 1.9.3 | |
require './problem4_functions' | |
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
#!~/bin/ruby | |
require 'ostruct' | |
require "rubyvis" | |
require './plotter_utility.rb' | |
#------------ | |
# | |
#------------ |
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
# ruby 1.9.3 | |
puts "Print first array elements (divided by spaces):" | |
a = gets().split(' ').map{|x| x.to_i }.sort #presorted array N1 | |
puts "Print second array elements (divided by spaces):" | |
b = gets().split(' ').map{|x| x.to_i }.sort #presorted array N2 | |
puts "print k value u wanna get" | |
k = gets().to_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
=begin | |
xmatrix should meet the following conditions: | |
1. there must be class for 3*3 matrices. | |
2. There must be class for 3dimentional vectors | |
3. there must be ancestor of matrix class, describing matrix of rotation near z axis | |
4. Should overload operations: | |
- matrix addition | |
- multiplication by number | |
- multiplication by vector | |
- multiplication by matrix |
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
=begin | |
XFiles should meet the following conditions: | |
1. there must be class for student with his marks. with the following properties: | |
- print self with ther format shown as '<Student Full Name>: <mark1> <mark2> ... <markN>' | |
- should be able to calculate median (mean) mark. | |
- should be able to add new marks | |
- construct Student by his full name | |
2. There also should be class for simple file-based database, which should meet the following conditions: | |
- class should be initialized by filename, when gets filename - load all information from file specified, thus creating a set (array) of Student objects. | |
- should have possibility to add, remove students, to output all students to 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
=begin | |
xDictionary should meet the following conditions: | |
1. must be ancestor of Hash class (ruby analogue to Dictionary class in python) | |
2. hash values should be accessible via d["key"] and d.key, space characters in key name should be replaced by '_' symbol | |
3. while initialization, class should accept frozen array with forbidden keys. In case when user tries to add element with | |
some value from forbidden keys array, DeniedKeyException should be raised | |
4. There should also be ability to call dictionary\hash elements by their index, in order of appearance in dictionary. | |
=end | |
module XDictionaries | |
class DeniedKeyException < Exception; def initialize(str); super(str || "Denied key exception raised"); 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
require 'ruby_decorators' | |
class TimeMachine < RubyDecorator | |
def call(this, *args, &blk) | |
start_time = Process.times | |
puts "#{'%.4f' % (start_time.stime + start_time.utime)}ms #{this.name}" | |
this.call(*args, &blk) | |
end_time = Process.times | |
puts " +#{ '%.9f' % (end_time.stime + end_time.utime - start_time.utime - start_time.stime).abs }ms" | |
end |
OlderNewer