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 prime?(n) | |
res = true | |
limit = Math.sqrt(n) | |
(2..limit).each{ |d| res = res && (not ((n%d)==0)) } | |
return res | |
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
<a href="some_url.html"> | |
Some text | |
<div class="some_class"> | |
Something inside the div | |
</div> | |
</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
<%= link_to('some_path_to_link', 'Some text') do %> | |
<div class='some_class'> | |
Something inside the div | |
</div> | |
<% 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
<%= link_to( image_path('my_image.jpg'), class: 'my_class') do %> | |
<%= image_tag 'my_image.jpg' %> | |
<div class="some_class"> | |
Something inside the div | |
</div> | |
<% 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 LongestWord(sen) | |
sen1 = sen.split("/\W+/") | |
grt = 0 | |
sen1.each do |i| | |
if sen1[i].length > sen1[grt].length # Type conversion error | |
grt = i | |
end | |
end | |
sen1[grt] | |
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 longest_word(sen) | |
sen1 = sen.split(" ") | |
grt = 0 | |
sen1.each_index do |i| | |
if sen1[i].length > sen1[grt].length | |
grt = i | |
end | |
end | |
sen1[grt] | |
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 longest_word(str) | |
str.split(" ").max_by{ |s| s.length } | |
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 some_method | |
(1..1000).each{ |i| puts i if sum_is_ten?(i) } | |
end | |
def sum_is_ten?(par) | |
sum = 0 | |
par.to_s.each_char{ |c| sum += c.to_i } | |
sum == 10 | |
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 some_method | |
(1..1000).each{ |i| puts i if sum_is_ten?(i) } | |
end | |
def sum_is_ten?(par) | |
sum = 0 | |
par.to_s.each_char{ |c| sum += c.to_i } | |
((sum == 10) && (par%4 == 0)) | |
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 some_method | |
(1..1000).each{ |i| puts i if (sum_is_ten?(i) && (i%4 == 0)) } | |
end | |
def sum_is_ten?(par) | |
sum = 0 | |
par.to_s.each_char{ |c| sum += c.to_i } | |
sum == 10 | |
end |