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:b1d400be90340e71142d889781d2b62c
Created September 26, 2017 17:15
Split temperature sequence
t = [5, -2, 3, 8, 6]
#t = [-5, -5, -5, -42, 6, 12]
def winter(t)
length = t.count
lengthsummer = length/2
lengthwinter = length - lengthsummer
twinter = t.take(lengthwinter)
@dbhalling
dbhalling / gist:1a7c058c92cfb3586f6929d4c327ca62
Created September 26, 2017 17:54
Infinite Chessboard - Minimum number of moves by rook to final position
# chess game Rook on an infinte Cheesboard. Find the minium number of steps to the final position
finalposition = [5,-77]
def rook(finalposition)
start = [0,0]
finalposition[0] = finalposition[0].abs
finalposition[1] = finalposition[1].abs
#frog jump
#array a is a set of stones in a river and the value is when stone is above the waterline in time
#d is how many stones the frog can jump
#a = [1,-1,0,2,3,5]
a = [1, 2, 3]
#d = 3
d = 1
@dbhalling
dbhalling / gist:39b9d15c3990a2ea48f03607846d3c90
Created September 27, 2017 21:04
Bitcoin Bitfinex ticker
<html>
<div id="btc">
</div>
<script>
var ws = new WebSocket("wss://api.bitfinex.com/ws")
ws.onopen = function(){
ws.send(JSON.stringify({"event":"subscribe", "channel":"ticker", "pair":"BTCUSD"}))
#ThePowerSum
x = 100
n = 3.0
def solution(x, n)
answer = 0
power = 1/n
#CamelCase
s = "saveChangesInTheEditor"
def solution(s)
sa = s.chars
sa.keep_if {|v| v =~ /[ABCDEFGHIJKLMNOPQRSTUWXYZ]/}
count = sa.count + 1
@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)
@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: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