Programming challenges are off-site challenges meant to offer programmers educational experiences while testing their abilities.

learn more… | top users | synonyms (1)

3
votes
2answers
38 views

Finding the count of all repeats in an array of integers

The problem is about finding the sum of all repeating groups from an integer array as explained below and here Problem statement: Say that a "clump" in an array is a series of 2 or more adjacent ...
0
votes
1answer
24 views

Skiena's Programming Challenges: The Trip problem

I have the following solution for the Trip problem from Skiena's and Revilla's Programming Challenges (full problem description here). ...
5
votes
1answer
158 views

Finding the largest mirror image of a subset/set of integers present in an array of integers

The problem I am talking about is this. Problem statment: We'll say that a "mirror" section in an array is a group of contiguous elements such that somewhere in the array, the same group ...
7
votes
2answers
78 views

Largest Prime Factor redux

There have been a number of questions asking for comments on code for the Project Euler problem to compute the largest prime factor of a number. A primary intent of this task is to find the factor as ...
2
votes
0answers
39 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 ...
9
votes
1answer
278 views

x64 Assembly - checking for largest prime factor

Using x64 assembly, I solved the Largest Prime Factor problem on Project Euler. The problem is as follows: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of ...
2
votes
1answer
36 views

Performance of Codility MaxCounter challenge solution

I'm doing some of the Codility challenges using Ruby. The current challenge is "The MaxCounter," which is described as: Calculate the values of counters after applying all alternating operations: ...
4
votes
0answers
27 views

Project Euler Problem 18 (Haskell) - Maximum path sum I

I've implemented the solution to Project Euler Problem 18 in Haskell and I'd like to get some thoughts on my implementation. Its the dynamic programming solution, working from the bottom up. ...
3
votes
0answers
28 views

Implementing a data structure that is a collection of sets

I'm trying to optimize my code (time optimization) based on this problem: Let S be a set of strings. Each string in S is ...
10
votes
1answer
125 views

Tweets per second, using linked list

This is a TalentBuddy Challenge Your task is to write a function that prints to the standard output (stdout) the highest number of tweets recorded between each second in the array and the past ...
3
votes
1answer
40 views

Adding reversed numbers

This is my solution to the competitive coding question on SPOJ here. It gives a runtime of 0.24 but the best solutions posted have a 0.0 runtime. How could I possibly achieve better results than ...
4
votes
3answers
133 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 ...
0
votes
0answers
32 views

Missing Term in an AP (Programming) [closed]

An Arithmetic Progression is defined as one in which there is a constant difference between the consecutive terms of a given series of numbers. You are provided with consecutive elements of an ...
4
votes
2answers
89 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 ...
4
votes
3answers
64 views

String self-similarity

It's a string problem I have been making on Hackerrank. It is executing fine on all test cases except the last two. These last two test case are declaring it "Terminated due to time out". C programs ...
5
votes
3answers
73 views

Calculating the ranks of classmates' exam grades

The questions from hackerearth: Geeko is in worry now because an exam is coming up and he has to know what rank he can get on exams. So he goes back into the the school records and finds 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
512 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? ...
4
votes
1answer
66 views

Dynamic programming with Project Euler #18

I just wanted to get an opinion on my dynamic-programming Haskell implementation of the solution to Project Euler problem 18. The Problem: By starting at the top of the triangle below and moving ...
7
votes
4answers
401 views

Checking if a number is a perfect square by recursive sum of its digits [closed]

I was solving this question on an online judge. The problem boils down to the following: Given a number \$n\$, where \$1 \le n \le 10^{18}\$, we need to check if it contains odd number of ...
11
votes
7answers
2k views

Is my solution to return kth row of the Pascal's triangle suitable for a job interview?

Question: Given an index \$k\$, return the \$k\$th row of the Pascal's triangle. For example, given \$k = 3\$, return \$[1,3,3,1]\$. Bonus points for using \$O(k)\$ space. Can it be ...
2
votes
1answer
37 views

Two squares or not two squares - constant time optimization

I have been trying to solve this problem, and after a bit of googling, I realised a \$O(\sqrt{n})\$ time complexity works fine (though the algorithm suggested is different from that I have used). My ...
3
votes
1answer
126 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
3answers
151 views

Penney Game - mapping macros to strings

The SPOJ problem: Given a 40 character string representing outcomes of 40 coin tosses, find the frequency destribution of all the possible outcome triplets. So, for string like : HHHH....40 Hs ...
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. ...
10
votes
6answers
2k views

Beehive numbers - using goto in C++

I understand that using goto in C++ code is strictly unadvised, but sometimes, it really reduces the number of lines of code like in the following case. This is my ...
3
votes
2answers
261 views

Project Euler problems 18/67: maximum path sum

I recently solved problems 18/67 in Project Euler. My code is long and I think it could be more effective. I solved the problem with dynamic programming and am new to it, so I want to improve my ...
2
votes
3answers
46 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
555 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 ...
3
votes
3answers
68 views

Speed up counting sort algorithm in Ruby

I'm attempting this simple HackerRank counting sort problem but testcase #3, which has 100,000 test cases, is timing out. Is there something particularly inefficient about this code? ...
2
votes
1answer
42 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. ...
4
votes
1answer
106 views

Google Code Jam 2014: Full Binary Tree

Here is my entry for the Code Jam problem Full Binary Tree (I didn't compete but tackled the problem afterwards). It does solve the provided inputs, so I suppose it is correct. I am looking for any ...
3
votes
0answers
55 views

Programming Puzzle - N Teams K Wins each

I found a problem here. I am sharing the problem and my attempt at solution. I would like to find out if this is the best approach possible. One day, at the "Russian Code Cup" event it was decided ...
9
votes
3answers
282 views

Optimizing “Herd Sums” problem using dynamic programming

I'm trying to solve a practice problem and all is well except for the last 2 inputs my solution is too slow. Just one loop is slowing it down I think. Herd Sums Execution Time Limit: 2 ...
1
vote
3answers
80 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 ...
3
votes
1answer
65 views

Project Euler Problem 14 in Clojure

I recently began learning Clojure. In order to get better acquainted with it, I've been tackling Project Euler challenges. Problem 14 is not really a difficult one. It asks for the number that ...
1
vote
1answer
43 views

Project Euler #20 solution in Clojure

Problem: \$n!\$ means \$n × (n − 1) × ... × 3 × 2 × 1\$ For example, \$10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800\$, and the sum of the digits in the number \$10!\$ is \$3 + 6 + 2 + 8 + 8 + 0 + ...
3
votes
3answers
87 views

More succinct / ideal solution to Project Euler #22

"Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical ...
4
votes
2answers
115 views

Rotating the string optimization

Below is the code for the problem at Codechef. I have made use of the String method .equals in my solution which is working fine ...
3
votes
2answers
56 views

Curious fractions in functional Ruby

Problem 33 in Project Euler asks: The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is ...
5
votes
1answer
82 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
84 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}) = ...
6
votes
3answers
207 views

Project Euler 23: Non Abundant Sums

Here is my solution to Project Euler 23: Non Abundant Sums. I know I'm doing the Divisors function brute force, but I can't seem to get it to work any other way. ...
3
votes
2answers
124 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
55 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? ...