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
#codality35 CommonPrimeDivisors | |
require 'prime' | |
a = [15, 10, 3, 2] | |
b = [75, 30, 5, 8] | |
def solution(a, b) | |
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
#Codility34 ChocolatesByNumbers | |
n = 10 | |
m = 4 | |
def solution(n, m) | |
step= 0 | |
stepArray = [0] |
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
#codility33 CountSemiprimes | |
# 4, 6, 9, 10, 14, 15, 21, 22, 25, 26 semiprimes | |
require 'prime' | |
p = [1, 4, 16] | |
q = [26, 10, 20] |
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
#Codility CountNonDivisible 32 | |
a = [3, 1, 2, 3, 6] | |
def solution(a) | |
# length = a.count | |
count = 0 |
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
#Citrus | |
a = [[1,2,[3]],4] | |
aflat = [] | |
def flatten(a) | |
astring = a.to_s | |
test = astring.delete "[" |
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
#Time Conversion Technical Exam 2 | |
#puts "Please enter the standard time including the seconds in this format XX:XX:XXAM" | |
#st = gets.chomp.to_s | |
st = "12:00:45AM" | |
#st = "01:12:15PM" | |
#st = "12:00:00AM" | |
def solution(st) |
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
#CamelCase | |
s = "saveChangesInTheEditor" | |
def solution(s) | |
sa = s.chars | |
sa.keep_if {|v| v =~ /[ABCDEFGHIJKLMNOPQRSTUWXYZ]/} | |
count = sa.count + 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
#ThePowerSum | |
x = 100 | |
n = 3.0 | |
def solution(x, n) | |
answer = 0 | |
power = 1/n |
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
#codility30 Flags | |
a = [1, 5, 3, 4, 3, 4, 1, 2, 3, 4, 6, 2] | |
def solution(a) | |
count = a.count | |
peaks = [] | |
i = 0 |
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
#codility30 Flags | |
a = [1, 5, 3, 4, 3, 4, 1, 2, 3, 4, 6, 2] | |
def solution(a) | |
count = a.count | |
peaks = [] | |
i = 0 |
NewerOlder