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
# The following iterative sequence is defined for the set of positive integers: | |
# n ->n/2 (n is even) n ->3n + 1 (n is odd) | |
# Using the rule above and starting with 13, we generate the following sequence: | |
# 13 40 20 10 5 16 8 4 2 1 It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at 1. | |
# Which starting number, under one million, produces the longest chain? |
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
class Object | |
# all methods named 'local_(*)_methods' | |
# should return '(*)_methods' minus those that exist in Object | |
def method_missing(method_name, klass = Object, *args, &block) | |
if method_name.to_s[0..5] == "local_" && method_name.to_s[-7..-1] == "methods" && !method_name.to_s[6..-1].include?("local") | |
subname = method_name.to_s[6..-1] | |
self.send(subname, *args, &block) - klass.send(subname, *args, &block) | |
else | |
super(method_name, *args, &block) |
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
/* Write the JS necessary to calculate values after a number is changed inside the form field. | |
Hints: | |
1.) Learn about change event methods: http://api.jquery.com/change/ | |
2.) Learn about retrieving values from form inputs: http://api.jquery.com/val/ | |
3.) Learn how to select specific inputs using eq selectors: http://api.jquery.com/eq-selector/ | |
*/ | |
$(document).ready(function() { |
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
class Palindromes | |
def initialize(hash = {}) | |
hash[:max_factor] ||= 2 | |
hash[:min_factor] ||= 1 | |
@max_factor = hash[:max_factor] | |
@min_factor = hash[:min_factor] | |
@palins = [] | |
end |
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
Questions: | |
-what is the criteria for a "successful" PB&J Sandwich? | |
-what are other variables we want to account for? e.g.: | |
-minimize contamination of PB into Jelly jar and vice versa | |
-make containers easy to reuse | |
-assuming hands and plate are cleaner than table, prevent bread from touching table | |
-can we infer that the situation in the picture is also part of the consideration? i.e. the PB, Jelly, Bread are labeled, everything is within reach by the alien | |
-is the alien able to do actions with his hands that a normal human can (at least the ones involved in making a sandwich), especially opening a jar or the bread packaging | |
Assuming yes to all of the above: |