Back To Normal

Subscribe To Our E-Mail Newsletter

Showing posts with label RUBY. Show all posts
Showing posts with label RUBY. Show all posts

Wednesday, May 13, 2015

Code searching tools: ag

ag is a code-searching tool, similar to awk and grep and its mainly used to searching large trees of source code. it requires perl to run and portable with any platform. 
     Other tools : https://github.com/petdance/ack2
Read More


Friday, June 20, 2014

Need to find three integers which can equal Pythagoras' Theorem (a^2+ b^2= C^2) and a+b+c=1000

Have tried with some math logics to solve this problem .
 a^2+ b^2= C^2
 a+b+c=1000

Finally with help of computer solved this problem..

for a in 1..500
  for b in 1..500
    for c in 1..500
      if (a+b+c) == 1000
        if (a*a) +(b*b) == (c*c)
          p a,b,c
          exit
        end
      end
    end
  end
end

Results : 200 ,375 ,425
Read More


Thursday, June 19, 2014

Ruby : How to list all methods of element or object?

 A way to list methods of list in ruby

> list=[1,2,3,4,5]      # define one list
 => [1, 2, 3, 4, 5]
 > list.sort
 => [1, 2, 3, 4, 5]
 > list.methods.sort   -1.methods      # -1 exclude other object methods.
 => [:[]=, :all?, :any?, :assoc, :at, :bsearch, :chunk, :clear, :collect, :collect!, :collect_concat, :combination, :compact, :compact!, :concat, :count, :cycle, :delete, :delete_at, :delete_if, :detect, :drop, :drop_while, :each, :each_cons, :each_entry, :each_index, :each_slice, :each_with_index, :each_with_object, :empty?, :entries, :fetch, :fill, :find, :find_all, :find_index, :first, :flat_map, :flatten, :flatten!, :grep, :group_by, :include?, :index, :inject, :insert, :join, :keep_if, :last, :lazy, :length, :map, :map!, :max, :max_by, :member?, :min, :min_by, :minmax, :minmax_by, :none?, :one?, :pack, :partition, :permutation, :pop, :product, :push, :rassoc, :reduce, :reject, :reject!, :repeated_combination, :repeated_permutation, :replace, :reverse, :reverse!, :reverse_each, :rindex, :rotate, :rotate!, :sample, :select, :select!, :shift, :shuffle, :shuffle!, :slice, :slice!, :slice_before, :sort, :sort!, :sort_by, :sort_by!, :take, :take_while, :to_a, :to_ary, :transpose, :uniq, :uniq!, :unshift, :values_at, :zip] 
Read More


560 Free Online Courses

Top 200 universities launched 500 free online courses.  Please find the list here .