Skip to content

Instantly share code, notes, and snippets.

def is_palindrome(x):
x = str(x)
return x == x[::-1]
def find_palindromes(m, n):
for i in xrange(m, n):
for j in xrange(i, n):
x = i * j
if is_palindrome(x):
yield x
//http://projecteuler.net/problem=4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LargestPalindromeProduct
@l0gicpath
l0gicpath / problem_4.rb
Last active August 29, 2015 13:56
Project Euler problem #4 solution in Ruby
(100..999).to_a.repeated_permutation(2).collect{|x| x[0] * x[1] if "#{x[0] * x[1]}" == "#{x[0] * x[1]}".reverse }.compact.max
@l0gicpath
l0gicpath / problem_4.erl
Last active August 29, 2015 13:56
Project Euler problem #4 solution in Erlang
-module(problem_4).
-export([solve/0]).
solve() ->
List = lists:seq(100, 999),
[H | L] = [X * Y || X <- List,
Y <- List,
integer_to_list(X * Y) =:= lists:reverse(integer_to_list(X * Y))],
solve(L, H).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LargestPrimeFactor
{
class Program
{
@EslaMx7
EslaMx7 / ProjectEuler.P3.cs
Created February 7, 2014 12:14
Project Euler Problem 3 Solution with C#
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsolesTests
{
class Program
{
static void Main(string[] args)
{
using System;
using System.Collections.Generic;
using System.Text;
namespace Largest_prime_factor
{
class Program
{
static void Main(string[] args)
{
@gr33ndata
gr33ndata / gist:8848854
Created February 6, 2014 17:33
Prime numbers generator!
# Using Sieve of Eratosthenes
# https://en.wikipedia.org/wiki/Generating_primes
import sys
def main():
num = int(sys.argv[1])
num_list = [[i,True] for i in range(num)]
num_list[0][1] = False
num_list[1][1] = False
def sieve(numbers, n):
for i in range(n * 2, len(numbers), n):
numbers[i] = False
def skip_to_next_prime(numbers, n):
n += 1
while n < max and not numbers[n]:
n += 1
return n
@l0gicpath
l0gicpath / one_liner.rb
Last active August 29, 2015 13:55
One liner ruby solution for project euler problem #2 because ruby is hardcore
(l ,ss = 4000000, proc {|p, n, s| p >= l || n >= l ? s : n.even?? ss[n, n + p, s + n] : ss[n, n + p, s] })[1][1, 2, 0]