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
[ | |
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} }, | |
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} }, | |
{ "keys": ["shift+end"], "command": "move_to", "args": {"to": "eol", "extend": true} }, | |
{ "keys": ["shift+home"], "command": "move_to", "args": {"to": "bol", "extend": true } }, | |
{ "keys": ["ctrl+home"], "command": "move_to", "args": {"to": "bof"} }, | |
{ "keys": ["ctrl+end"], "command": "move_to", "args": {"to": "eof"} }, | |
{ "keys": ["ctrl+shift+home"], "command": "move_to", "args": {"to": "bof", "extend": true} }, | |
{ "keys": ["ctrl+shift+end"], "command": "move_to", "args": {"to": "eof", "extend": true} }, | |
] |
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
public static <T> Stream<T> concatenate(Stream<T>... streams) { | |
return Stream.of(streams).reduce(Stream.empty(), Stream::concat); | |
} | |
public static void main(String[] args) { | |
Stream<? extends CharSequence> res = concatenate( | |
Stream.of("One"), | |
Stream.of(new StringBuffer("Two")), | |
Stream.of(new StringBuilder("Three")) |
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
datatype 'a stream = Empty | Cons of 'a * (unit -> 'a stream) | |
fun from n = Cons(n, fn () => from(n +1)) | |
val naturals = from(1) | |
fun filter f xs = | |
case xs of | |
Empty => Empty | |
| Cons(h,t) => if f(h) | |
then Cons(h, fn () => filter f (t())) |
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
def sumDivisible(m,n): | |
""" | |
Given a maximum integer m and a factor n, calculates the sum | |
of all divisors of n up to m. | |
""" | |
p = m // n | |
return n * (p * (p + 1)) // 2 | |
def solve(): |
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
module Euler.Problem1 where | |
-- | Given a maximum integer m and a factor n calculates the sum | |
-- of all divisors of the given factor up to m. | |
sumDivisible :: Int -> Int -> Int | |
sumDivisible m n = n * (p * (p + 1)) `div` 2 where p = m `div` n | |
result = (sumDivisible 999 3) + (sumDivisible 999 5) - (sumDivisible 999 15) | |
solve::String |
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
/** | |
* Given a maximum integer m and a factor n calculates the sum | |
* of all divisors of the given factor up to m. | |
* | |
* @param m maximum integer | |
* @param n given factor (i.e. 3 or 5) | |
* @return the sum of all divisors. | |
*/ | |
def sumDivisible(m: Int, n:Int): Int = { |
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
# Given a maximum integer m and a factor n, calculates the sum | |
# of all divisors of n up to m. | |
def sumDivisible(m,n) | |
p = m / n | |
n * (p * (p + 1)) / 2 | |
end | |
def solve | |
result = sumDivisible(999,3) + sumDivisible(999,5) - sumDivisible(999, 15) |
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
def is_palindrome(n): | |
text = str(n) | |
return text == text[::-1] | |
def palindromes(): | |
for j in range(100,1000): | |
for k in range(100,1000): | |
product = j * k |
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
import StringIO | |
def get_big_numbers(): | |
number = """ | |
37107287533902102798797998220837590246510135740250 | |
46376937677490009712648124896970078050417018260538 | |
74324986199524741059474233309513058123726617309629 | |
91942213363574161572522430563301811072406154908250 | |
23067588207539346171171980310421047513778063246676 | |
89261670696623633820136378418383684178734361726757 |
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
def next_number(stop=1000): | |
n = 1 | |
while n <= stop: | |
yield n ** n | |
n += 1 | |
if __name__ == '__main__': | |
result = str(sum(next_number()))[-10:] | |
print "The last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000 is: %s" % result |
OlderNewer