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
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) |
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
# 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 |
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
#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 |
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
<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"})) |
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
#codality22 Fish | |
a = [4, 3, 2, 1, 5] | |
b = [0, 1, 0, 0, 0] | |
def solution(a, b) | |
numberoffish = a.count | |
fishup = b.index(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
#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
#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
#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
#Codility CountNonDivisible 32 | |
a = [3, 1, 2, 3, 6] | |
def solution(a) | |
# length = a.count | |
count = 0 |
OlderNewer