- Bernie Margolis in Java (gist)
- Florent Crivello in Objective-C (gist)
- Srismil Dutta in Javascript (gist)
- Eran Zimbler in Javascript (gist and node.js module)
- Maurin Lenglart in Javascript (gist)
- Ankit Goyal in Ruby (gist, imgur clean notes, original notes)
- Kevin Le Brun in Python (with a nice writeup and tests!) (gist), who accurately notes "I saw a typo in the second test case for the problem. You should replace '194' with '14'."
- C is for Conrad Meyer (another C solution) (gist)
- Péter Ferenczy in Ruby (utilizing laz
<html> | |
<head> | |
<title>Max Consecutive Sum</title> | |
</head> | |
<body> | |
Enter some integers: | |
<input type="text" id="txtInput" value="-1 5 6 -2 20 -50 4"></input> | |
<button onClick="btnOnClick();">Calculate</button> | |
<p> | |
Max consecutive sum is: <span id="divResult"></span> |
-
From Joshua Harris in python (gist)
-
From Denis Karpenko in Ruby (with rspec tests!) (gist)
-
From Nikki DelRosso in python (gist):
"And an explanation of the solution (since the Python is very dense): For each value, since we're doing sums consecutively, we want to calculate the maximum that we could attain if we use the current value as the last value in the sequence. The only information we need to calculate this was what the maximum value was if we ended on the value before this in the sequence. If the previous value was negative, then the max value attainable by ending on this value is just this value. Otherwise, we add the current with the value for the previous element. All we need, then, is to iterate through our sequence and keep track of the previous best option, as well as the maximu
## | |
## As a search result, atomic inc works fine on the 'taggings' hash: | |
## | |
>> Gif.create!() | |
=> #<Gif _id: 4efa9e283b44374c0b000003, _type: nil, tag_ids: [], user_ids: [], taggings: {}, views: 0, upvotes: 0, downvotes: 0> | |
>> Gif.first.inc('taggings.test', 1) | |
=> 1 | |
>> Gif.first | |
=> #<Gif _id: 4efa9e283b44374c0b000003, _type: nil, tag_ids: [], user_ids: [], taggings: {"test"=>1}, views: 0, upvotes: 0, downvotes: 0> |
// Protoype version (uses effects.js) | |
var names = $$('li.nick a').map(function(val){ return val.innerHTML }); | |
new Autocompleter.Local('chat_text_input', 'related_channels', names, {}); | |
// JQuery version | |
var script = document.createElement("script"); | |
script.src = "http://code.jquery.com/jquery-latest.js"; |
require 'rubygems' | |
require 'open-uri' | |
require 'pp' | |
require 'nokogiri' | |
PAGE_URL = "http://www.reddit.com/r/AskReddit/comments/lf38m/what_is_the_funniest_movie_you_have_ever_seen/" | |
INSTANT_WATCHER = "http://instantwatcher.com/titles?q=QUERY&search_episodes=0" | |
page_text = Nokogiri::HTML(open(PAGE_URL)) |
require 'rubygems' | |
require 'open-uri' | |
require 'pp' | |
require 'nokogiri' | |
PAGE_URL = "http://www.reddit.com/r/AskReddit/comments/lf38m/what_is_the_funniest_movie_you_have_ever_seen/" | |
page_text = Nokogiri::HTML(open(PAGE_URL)) | |
page_text.css('div.usertext-body').each do |content| |
// add the following to the end of your web.js | |
// respond to POST / | |
app.post('/', function(request, response) { | |
response.redirect('/home'); | |
}); |
# Replace this line: | |
get "/" do | |
# With these lines: | |
def get_or_post(path, opts={}, &block) | |
get(path, opts, &block) | |
post(path, opts, &block) | |
end |
[root@bjordan-dev scripts]# ruby long_task.rb | |
# Press ctrl+z to suspend the process | |
[1]+ Stopped ruby long_task.rb | |
[root@bjordan-dev scripts]# bg | |
[1]+ ruby long_task.rb & | |
[root@bjordan-dev scripts]# pidof ruby | |
29794 | |
[root@bjordan-dev scripts]# disown 29794 | |
[root@bjordan-dev scripts]# exit |