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
from calendar import Calendar | |
counter = 0 | |
iterator = Calendar() | |
for y in xrange(1901,2001): | |
for m in xrange(1,13): | |
for d in iterator.itermonthdays2(y,m): | |
if d == (1,6): | |
counter += 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
# | |
# Euler Problem 17 | |
# http://projecteuler.net/index.php?section=problems&id=17 | |
# | |
units = map(len, ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']) #[0, 3, 3, 5, 4, 4, 3, 5, 5, 4] | |
tens = map(len, ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']) #[0, 0, 6, 6, 5, 5, 5, 7, 7, 6] | |
teens = map(len, ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']) | |
def how_long(num): |
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(euler36). | |
-export([is_palindrome/1, solve/0]). | |
is_palindrome(X) -> | |
integer_to_list(X) =:= lists:reverse(integer_to_list(X)). | |
solve() -> | |
% need to check only odd integers since the even ones will never be palindromes in binary base | |
solve(lists:seq(1, 999999, 2), 0). |
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(euler35). | |
-export([is_circular_pr/1, solve/0]). | |
is_circular_pr(Number) -> % takes a prime number as input, does not check the number if it itself is prime | |
Check = lists:any(fun(X) -> (X - 48) rem 2 =:= 0 orelse (X - 48) == 5 end, integer_to_list(Number)), | |
Length = length(integer_to_list(Number)), | |
if | |
Length =:= 1 -> is_prime(Number); | |
Length > 1 -> | |
case Check of |