Skip to content

Instantly share code, notes, and snippets.

View dbhalling's full-sized avatar

Dale B Halling dbhalling

View GitHub Profile
@dbhalling
dbhalling / gist:a6da1e3553c4a3f7f5011ed2969894bb
Created August 26, 2018 05:57
#codality35 CommonPrimeDivisors
#codality35 CommonPrimeDivisors
require 'prime'
a = [15, 10, 3, 2]
b = [75, 30, 5, 8]
def solution(a, b)
@dbhalling
dbhalling / gist:15a04d589a5ecc848cd75a4ca83fb941
Created August 25, 2018 08:02
Codility34 ChocolatesByNumbers
#Codility34 ChocolatesByNumbers
n = 10
m = 4
def solution(n, m)
step= 0
stepArray = [0]
@dbhalling
dbhalling / gist:6fc826f12865e8edd162f51bbbd5f47e
Last active August 24, 2018 09:26
Semiprimes within range Codility33
#codility33 CountSemiprimes
# 4, 6, 9, 10, 14, 15, 21, 22, 25, 26 semiprimes
require 'prime'
p = [1, 4, 16]
q = [26, 10, 20]
@dbhalling
dbhalling / gist:8670b4d5ce19b8270ed1495cb98cd140
Last active August 24, 2018 09:25
Codility CountNonDivisible 32
#Codility CountNonDivisible 32
a = [3, 1, 2, 3, 6]
def solution(a)
# length = a.count
count = 0
@dbhalling
dbhalling / Citrusbyte
Created August 20, 2018 05:48
Flatten array
#Citrus
a = [[1,2,[3]],4]
aflat = []
def flatten(a)
astring = a.to_s
test = astring.delete "["
@dbhalling
dbhalling / gist:82820813c9687655f307b18b13e00c96
Created December 12, 2017 21:32
#Time Conversion Technical Exam 2
#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)
#CamelCase
s = "saveChangesInTheEditor"
def solution(s)
sa = s.chars
sa.keep_if {|v| v =~ /[ABCDEFGHIJKLMNOPQRSTUWXYZ]/}
count = sa.count + 1
#ThePowerSum
x = 100
n = 3.0
def solution(x, n)
answer = 0
power = 1/n
#codility30 Flags
a = [1, 5, 3, 4, 3, 4, 1, 2, 3, 4, 6, 2]
def solution(a)
count = a.count
peaks = []
i = 0
#codility30 Flags
a = [1, 5, 3, 4, 3, 4, 1, 2, 3, 4, 6, 2]
def solution(a)
count = a.count
peaks = []
i = 0