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

learn more… | top users | synonyms (2)

2
votes
0answers
17 views

Computation for finding the largest prime factor of 600851475143 is slow

I implemented the following for Project 3 in Project Euler: ...
8
votes
2answers
52 views

Contest code for a maze problem

I would like to ask your comments on my contest code for the following problem: We're going to have a slightly more logical puzzle today. We're going to write a program that will find a path through ...
4
votes
2answers
68 views

“Sherlock and queries” challenge

I'm writing some Java code for some pretty large datasets, in a puzzle I'm trying to solve. The output is correct, but the program doesn't run within the time limit for all the test cases. I've ...
8
votes
3answers
347 views

Finding the largest of a series of numbers being XORed

I'm working on solving a problem involving finding the largest of a series of numbers being XORed. This is the actual problem: Xorq has invented an encryption algorithm which uses bitwise XOR ...
3
votes
1answer
63 views

Determining maximum profit to be made from selling shares

Question Your algorithms have become so good at predicting the market that you now know what the share price of Wooden Orange Toothpicks Inc. (WOT) will be for the next \$N\$ days. ...
0
votes
1answer
32 views

Project Euler problem 31 - tail recursive algorithm [closed]

In Scala, a recursive algorithm for project Euler problem 31 is the following: ...
3
votes
2answers
55 views

Codility Frog Jump solutions

Problem details from Codility: A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The ...
2
votes
2answers
40 views

Calculating the number of prime numbers to solve the puzzle

How can the following program execution time improved? I have used dynamic programming in both "recursive" as well as "prime" function, but I'm not getting the efficient execution time. There is ...
9
votes
1answer
61 views

Ugly Numbers: A Rags-to-Riches Story

I stumbled upon an unaswered question, which looked like a good fit for a functional programming language. Here is the problem statement from codeeval: UGLY NUMBERS CHALLENGE DESCRIPTION: ...
3
votes
2answers
81 views

Timing Project Euler Problem 1

Is there a better way to time the functions and print the result and function name dynamically? ...
2
votes
1answer
80 views

Painting Fences - optimize for faster performance

I am attempting this problem at Codeforces. I'm stuck as it gives a time limit exceeded error for large inputs though the logic I followed is similar to that of the editorial. I'd be grateful for any ...
7
votes
2answers
92 views

TapeEquilibrium implementation does not satisfy all requirements

The Codility's TapeEquilibrium problem asks: Given an array \$A\$ with length \$N\$, indexed starting from 0, find an equilibrium index \$P\$, such that $$\left| \sum_{i=0}^{P-1} a_i - ...
5
votes
5answers
97 views

Improving efficiency for two sum

I am trying to solve this problem: Given an array of integers, find two numbers such that they add up to a specific target number. and this is my strategy: For each ...
4
votes
3answers
136 views

Modified Sieve of Eratosthenes has very long runtime

I am slowly moving through Project Euler, and have reached problem #10: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. I did a naive ...
-1
votes
0answers
79 views

Game of hog in Python

Below is the problem statement for Hog: In Hog, two players alternate turns trying to reach 100 points first. On each turn, the current player chooses some number of dice to roll, up to 10. She ...
6
votes
1answer
109 views

Finding common strings among 2 arrays of strings of length 1, sorted alphabetically in O(n) time complexity

The problem: Start with two arrays of strings, a and b, each in alphabetical order, possibly with duplicates. Return the count of the number of strings which appear in both arrays. ...
13
votes
3answers
153 views
+100

100 gunmen in circle kill next person

The question is here. 100 people are standing in a circle with gun in their hands. 1 kills 2, 3 kills 4, 5 kills 6 and so on till we are left with only one person. Who will be the last person ...
1
vote
1answer
48 views

Application of higher-order function in Python

If \$f\$ is a numerical function and \$n\$ is a positive integer, then we can form the \$n\$th repeated application of \$f\$, which is defined to be the function whose value at \$x\$ is ...
3
votes
1answer
71 views

Finding if there is a subset that sums to a target value from an array of integers

I came across this problem. Problem Statement: Given an array of ints, is it possible to choose a group of some of the ...
22
votes
8answers
2k views

The FizzBuzz challenge in Java 8 written in a short, readable and interesting way

I decided to take on the FizzBuzz challenge with as twist that I would use Java 8 concepts to make it a bit modular, yet still let it be a short, readable and understandable program. This in contrary ...
3
votes
1answer
119 views

Speeding up Codechef FROGV

This is my solution to the FROGV problem on Codechef: ...
2
votes
1answer
99 views

Sum the Multiples of 3 and 5

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below N. ...
-2
votes
1answer
51 views

hailstone sequence using recursion in python

Douglas Hofstadter's Pulitzer-prize-winning book, Gödel, Escher, Bach, poses the following mathematical puzzle: Pick a positive integer n as the start. If n is even, divide it by 2. If n is ...
6
votes
2answers
79 views

Time Limit Exceeded with Segment Tree data structure

I am trying to solve this problem Chef Ceil has some matchsticks in his kitchen. Detail of matchsticks: There are N matchsticks in total. They are numbered from to 0 to N-1 inclusive. ...
3
votes
2answers
128 views

Building a list - why is this code inefficient?

I'm attempting this code challenge. Here's my code modified to handle one simple example test case: ...
6
votes
2answers
72 views

Project Euler code evaluation - digit fifth powers

This is for Project Euler #30: Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: \$1634 = 1^4 + 6^4 + 3^4 + 4^4\$ \$8208 = 8^4 + ...
3
votes
1answer
114 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 ...
4
votes
1answer
33 views

Basic Reverse Polish CL Parser

K and R Exercise 5-10 Write the program expr, which evaluates a reverse Polish expression from the command line, where each operator or operand is a separate argument. For example, ...
5
votes
3answers
130 views

Go Aaaaaaaaaaah

The problem is described in full here - Aaah!. Input The input consists of two lines. The first line is the “aaah” Jon Marius is able to say that day. The second line is the “aah” the ...
11
votes
3answers
895 views

The Love-Letter Mystery

Problem Statement James got hold of a love letter that his friend Harry has written for his girlfriend. Being the prankster that James is, he decides to meddle with it. He changes all the ...
6
votes
2answers
237 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 ...
1
vote
2answers
48 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). ...
6
votes
1answer
291 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
98 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
1answer
74 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 ...
10
votes
1answer
305 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
66 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
41 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. ...
6
votes
1answer
56 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 ...
6
votes
2answers
381 views

Stack challenge - improving memory consumption

I am working on this problem: Stacks Imagine, that you are employed by a software development company. You work now on the famous "D++ project", which is devoted to the creation of a new ...
7
votes
2answers
363 views

Optimizing this inefficient TicTacToe configuration parser

On a programming contest I came upon this question: Given a partially played 3 × 3 tic-tac-toe configuration, write a program to determine which player will have a better chance of winning if the ...
10
votes
1answer
148 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
45 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
151 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 ...
5
votes
2answers
103 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
70 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
91 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
524 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
79 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 ...