3
votes
1answer
110 views

Minimum number of letters removed, to make a string Peragram

Here is the link to the problem Peragrams. Peragrams: If a word is an anagram of at least one palindrome, we call it a Peragram. Problem: Given a string, find the minimum number of letters ...
2
votes
1answer
59 views

Typeahead Talent Buddy

Problem is Talent Buddy. Your task is to write a function that prints to the standard output (stdout) for each query the user name that matches the query if there are multiple user names ...
4
votes
3answers
136 views

Tweets per second

This challenge is from Talent Buddy: Tweets per second Japan Castle in the Sky airing broke a Twitter record on August 3, 2013. At one point during the classic anime movie showing, people ...
4
votes
2answers
93 views

Typeahead autocomplete functionality challenge

I'm working on a Talent Buddy challenge . In this challenge you have to design the autocomplete functionality of Twitter. You are given a list of queries and possible usernames. You have to return the ...
14
votes
6answers
2k views

Sherlock and The Beast

This is my solution to this question from Hackerrank. Given N (<= 100000), find the largest N-digit number such that: The number has only 3 and 5 as its digits. Number of times 3 ...
6
votes
5answers
519 views

Improving efficiency of Project Euler 185 (16-place Mastermind)

This a solution for Project Euler Problem 185. It works fine for the example but slow for the problem statement. How can I improve its speed and efficiency? ...
3
votes
1answer
163 views

Hackerrank Gem Stones

I am working on some problems on Hackerrank. John has discovered various rocks. Each rock is composed of various elements, and each element is represented by a lowercase Latin letter from 'a' to ...
4
votes
2answers
49 views

Efficient use of regular expression and string manipulation

The following is my solution to Java vs C++. I think the way I have used the re library is inefficient, and possible erroneous as I am getting tle. ...
2
votes
3answers
48 views

Speeding up Project Euler 43 - sub-string divisibility

The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property. ...
7
votes
6answers
558 views

Python address index +1 with list comprehension

Task from CodingBat: Return the sum of the numbers in the array, returning 0 for an empty array. Except the number 13 is very unlucky, so it does not count and numbers that come immediately after ...
2
votes
1answer
44 views

Project Euler 40: Champernownes's Constant

I just finished Project Euler 40 with a brute force method. As usual, any optimizations would be helpful. (I feel like I'm getting better at this scripting thing) ...
2
votes
1answer
53 views

Project Euler 39: Integer right triangles

I just finished Project Euler 39: If p is the perimeter of a right angle triangle with integral length sides, {a, b, c} … For which value of p ≤ 1000, is the number of solutions maximised? I'm ...
1
vote
1answer
39 views

Project Euler 38: Pandigital Multiples

I just solved Project Euler 38 and was wondering if you guys could provide some suggestions on how to speed it up. I've tried adding extra conditions but they increase the time. Any ideas on how to ...
3
votes
1answer
52 views

Truncatable Primes — Project Euler 37?

I just finished Project Euler 37 after a bit of debugging and can't figure out how to make it faster. Whenever I add extra tests that I want to speed the program up, it ends up just slowing it down. ...
1
vote
3answers
81 views

Optimizing Project Euler 36 - double-base palindromes

This one was quick and simple. Any optimizations? ...
2
votes
1answer
46 views

Project Euler 35 in Python

I'm back with a Python solution for Project Euler 35. Any help would be appreciated; I generate the numbers by observing that all circular primes can only have digits 1, 3, 7, and 9. Then I use the ...
5
votes
1answer
84 views

Project Euler 34 - digit factorials

145 is a curious number, as \$1! + 4! + 5! = 1 + 24 + 120 = 145\$. Find the sum of all numbers which are equal to the sum of the factorial of their digits. Note: as \$1! = 1\$ and \$2! ...
7
votes
1answer
85 views

Project Euler Problem 33 - digit canceling fractions

Problem: The fraction \$(\dfrac{49}{98})\$ is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that \$(\dfrac{49}{98}) = ...
3
votes
2answers
127 views

How to make Project Euler 32 in Python faster?

We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 ...
1
vote
2answers
60 views

Any way to optimize this already fast Python solution to Project Euler 31 (coin sums)?

This is a Python solution for all general cases. Any suggestions at all would be appreciated; in my opinion it's already quite good! Here's a link to the problem. ...
1
vote
2answers
51 views

Project Euler 29

Here's a link to the problem. Is there any way I could optimize/speed up this code, perhaps make it more Pythonic? ...
4
votes
2answers
84 views

String pattern riddle

I've tried this problem on Codeforces. Given a set of string patterns, all of which are the same length, and which consist of literal lowercase ASCII characters and ...
6
votes
3answers
385 views

Project Euler 28 - Number Spiral Diagonals

Project Euler problem 28 I realized that the spiral was essentially an arithmetic sequence, so I based my code off of that. ...
2
votes
1answer
62 views

Project Euler 27 - Quadratic Primes

Project Euler problem 27 I decided to try simple brute force, and it worked surprisingly quickly. How can this be optimized? ...
3
votes
2answers
121 views

Recursive uniform cost search that needs to be optimized

I have this uniform cost search that I created to solve Project Euler Questions 18 and 67. It takes the numbers in the txt file, places them into a two dimensional list, and then traverses them in a ...
7
votes
3answers
149 views

Can this rendition of Project Euler 26 be better written in any way?

This is my solution for problem 26 from Project Euler : ...
9
votes
3answers
198 views

How can I make my solution for Chef and Digits run faster?

Problem Statement Given n digits and m indices x from 1 to n, calculate the difference ...
17
votes
5answers
852 views

Count distinct primes, discarding palindromes, in under 2 seconds

Problem Statement Generate as many distinct primes P such that reverse (P) is also prime and is not equal to P. Output: Print per line one integer( ≤ 1015 ). Don't print more than ...
5
votes
1answer
110 views

Increasing readability of maximum path sum algorithm

I had written a solution for Project Euler problem 18 in Python 3. It is good in its efficiency but the problem is the readability and I think reuse. The algorithm used is that at every iteration ...
7
votes
2answers
136 views

Lychrel calculator (Project Euler 55)

If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindromes so quickly. For example, ...
5
votes
2answers
525 views

Sherlock and The Beast

I have recently written the program for the Sherlock and The Beast' HackerRank challenge. That's working fine, but the problem is that it takes too much time if a big number is given as a input. I ...
2
votes
2answers
74 views

Optimizing Python code for Project Euler #5 (LCM of all numbers from 1 to 20)

This is my solution for the 5th problem of Project Euler, which asks for the least common multiples of the numbers from 1 to 20 (inclusive). Is there any way to improve the while loop conditional ...
5
votes
1answer
463 views

Optimizing my code for Project Euler Problem #23 (Non-abundant sums)

Project Euler Problem 23 asks: A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be ...
6
votes
2answers
133 views

Helper function to solve Project Euler question 26

Project Euler problem 26 asks us to: Find the value of d < 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part. I wrote this function in Python to find the ...
4
votes
2answers
171 views

More efficient solution for Project Euler #2 (sum of Fibonacci numbers under 4 million)

I would like to get some feedback on my code. I am starting to program after doing a few online Python courses. Would you be able to help me by following my track of thinking and then pinpointing ...
4
votes
1answer
711 views

Project Euler Problem 12 - Highly Divisible Triangular Number - Python Solution Optimization

Project Euler Problem 12 asks (paraphrased): Considering triangular numbers Tn = 1 + 2 + 3 + … + n, what is the first Tn with over 500 divisors? (For example, T7 = 28 has six divisors: 1, 2, 4, ...
5
votes
2answers
182 views

Performance of modular square root

Here's Project Euler problem 451: Consider the number 15. There are eight positive numbers less than 15 which are coprime to 15: 1, 2, 4, 7, 8, 11, 13, 14. The modular inverses of these ...
2
votes
1answer
206 views

Project Euler #82 - path sum: three ways

Project Euler problem 82 asks: Here's my solution: ...
6
votes
2answers
208 views

Largest product in a grid

Project Euler problem 11 says: In the 20×20 grid below, four numbers along a diagonal line have been marked in bold. [red in the original] ...
5
votes
3answers
556 views

Summation of primes takes forever

Project Euler Problem 10 asks: "What is the sum of all prime numbers below 2 million?" How do I speed up my code? It's taking forever and I have never gotten the answer. However, I am sure that my ...
6
votes
4answers
723 views

Finding the Pythagorean triplet that sums to 1000

Project Euler problem 9 says: A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There ...
3
votes
3answers
229 views

How Pythonic is my Project Euler #5? (LCM of [1, 2, …, 20])

I have implemented a solution to Project Euler problem 5: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive ...
4
votes
3answers
1k views

Project Euler Question #2: Sum of even Fibonacci numbers under 4 million

The question is: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, ...
2
votes
0answers
538 views

Ugly numbers problem

Taken from one of codeeval.com challenges: Challenge Description: Credits: This challenge has appeared in a Google competition before. Once upon a time in a strange situation, people ...
1
vote
1answer
472 views

Reverse and Add: find a palindrome

This is one of codeeval challenges Challenge Description: Credits: Programming Challenges by Steven S. Skiena and Miguel A. Revilla The problem is as follows: choose a number, reverse ...
2
votes
3answers
136 views

Does this code violate the Single Responsibility Principle?

This is my solution to Project Euler problem 2: By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. The class ...
1
vote
1answer
265 views

Pythagorean number decomposition

I have a pretty interesting problem that I'm trying to solve, and I am kind of stuck. I want to count the triplets of distinct combinations a, ...
2
votes
2answers
1k views

Project Euler #4 - Largest Palindrome Product

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two ...
4
votes
2answers
412 views

Project Euler problem 92 - square digit chains

Link to problem. A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before. For example, 44 -> 32 -> 13 ...
3
votes
2answers
108 views

Attempting to efficiently compute the largest prime factor

As per the help, here's what I'm looking for from this post: best practice and practical advice about (what I think is describable as) buffering the output of a function. So I'm working on the third ...