This file contains hidden or 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 max_slice(arr) | |
arr.size.times do |x| | |
if sum(arr[x..-1]) >= sum(arr) | |
arr.shift | |
end | |
if sum(arr[x..-2]) > sum(arr) | |
arr.pop | |
end | |
end | |
p arr |
This file contains hidden or 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
arr = [20,30,50,40,100,10,45,95,30,10] | |
def low_high(stock_prices) | |
max = 0 | |
stock_prices.each_with_index do |x, index| | |
current_max = 0 | |
stock_prices[index..-1].each do |y| | |
current_max = y - x | |
if current_max > max | |
max = current_max |
This file contains hidden or 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
require 'time' | |
SHIFTS = [ | |
{id: 1, shiftStart: "2014-07-08 09:00:42 -0700", shiftEnd: "2014-07-08 18:00:42 -0700"}, | |
{id: 1, shiftStart: "2014-07-08 06:57:42 -0700", shiftEnd: "2014-07-08 08:57:42 -0700"}, | |
{id: 1, shiftStart: "2014-07-08 01:57:42 -0700", shiftEnd: "2014-07-08 05:57:42 -0700"}, | |
{id: 1, shiftStart: "2014-07-07 06:57:42 -0700", shiftEnd: "2014-07-07 12:57:42 -0700"}, | |
{id: 1, shiftStart: "2014-07-06 05:57:42 -0700", shiftEnd: "2014-07-06 11:57:42 -0700"} | |
] |
This file contains hidden or 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
$.post(form.prop("action"), parms, function(res) { | |
if (res.success) { | |
$(".overlay.hidden").fadeIn().delay(5000).fadeOut(); | |
form.get(0).reset(); | |
} | |
}, "json"); | |
// Change to this --->> | |
$.post(form.prop("action"), parms, function() { |
This file contains hidden or 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
/* this rotates a string: "lohel".rotate(3) is "hello" */ | |
String.prototype.rotate = function(n) { // n is an integer | |
n %= this.length; // if n too large: modulo | |
var cut = n < 0 ? -n : this.length - n; // cutting point | |
return this.substr(cut) + this.substr(0,cut); | |
}; | |
function rot13_creator() { | |
// compose the dictionary | |
var alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
This file contains hidden or 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
myList = [] | |
with open('file.txt') as file: | |
for line in file: | |
myList += line.split(' ') | |
for word in myList: | |
if '@' in word: | |
print word |
NewerOlder