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

learn more… | top users | synonyms (2)

-3
votes
0answers
11 views

A code on calendar (counting the number of days between two dates) [on hold]

I've been trying to develop a simple program to count the number of days between two dates \$a\$ and \$b\$, \$b\$ is always more recent than \$a\$. The dates themselves are not accounted, just the ...
10
votes
2answers
133 views

Finding a word within a pre-defined set using a search string with wildcards

The other day I was intrigued by this question (originally from here): Write a program that answers YES/NO search queries containing * placeholders. Example: if the data you have is (hazem, ...
5
votes
2answers
48 views

Project Euler #8

I was doing Project Euler #8, which asks: The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. ...
5
votes
1answer
61 views

“Laser treatment” SPOJ challenge

I am trying to solve this problem on SPOJ Brazil. I'm trying to approach the problem with a series of logical conditions and my code looks like this and it works perfectly. ...
4
votes
2answers
48 views

Moving chips between cells

Challenge: You are given a line of N cells with positive integers written in them. Initially a chip is placed on the leftmost cell. Each time it can be moved in any direction (to the left or to ...
1
vote
4answers
46 views

Finding the second largest element of large input sets

I have a problem where I need to find the second maximum element of the user inputs. It's an online practice problem and I can't figure out why the server responds back with a Non-Zero Exit Code error ...
3
votes
2answers
297 views

Rotating an NxN matrix

I came up with the following solution for rotating an NxN matrix 90 degrees clockwise, to solve this CodeEval challenge: Input The first argument is a file that contains 2D N×N matrices ...
2
votes
1answer
52 views

Simple sum calculator

I'm looking to optimize a simple sum calculator used in Project Euler+. The premise is simple: Find the sum of all the numbers divisible by 3 or 5 under X. At first I did it like so: ...
3
votes
3answers
170 views

Find the index of the element with maximum absolute deviation

I just completed a Codility test. The question presented was pretty simple but I may have over thought it. Question: Find the element which has the highest absolute deviation from the mean. E.g. ...
5
votes
2answers
118 views

Find the Biggest Traveler

This is from one of those online test sites, so the result had to be contained in a single class. The problem was stated as follows: Your java method will be given a 2-D array ...
1
vote
1answer
28 views

Beauty and the Strings in Haskell

I decided to make a solution in Haskell to a problem that I found on another post here at CodeReview (link: The Beauty and the Strings) I would like suggestions on how to improve letterFreqs. I have ...
0
votes
1answer
45 views

Optimizing Diwali Lights problem in C

I was trying to solve the Diwali Lights challenge on HackerRank. Problem Statement On the eve of Diwali, Hari is decorating his house with a serial light bulb set. The serial light bulb set ...
1
vote
3answers
54 views

Counting the frequency of letters in a string slices

While preparing a solution for the CodeChef - magic tricks, an easy question about counting the frequency of given character from the string slice, I came up with the following solution: ...
9
votes
3answers
374 views

The Beauty and the Strings

This originally appeared in Facebook's hacker cup 2013. Solving it was fun, though I find myself looping through similar data quite often. Challenge: Print the maximum beauty of strings. ...
2
votes
1answer
56 views

Time Limit Exceeded for CodeChef Easy problem - STRQ (Chef and Strings)

I was working through a codechef easy problem here. I've got to a solution, but it only passes the Subtask #1. For the other two subtasks, it shows TLE (Time Limit Exceeded - which is 1 second). ...
0
votes
2answers
40 views

Uva Online Judge problem 100, 3n + 1

I am having a tough time submitting this code to UVa Online judge and having it pass. I keep getting the message - Your program used more CPU time than what is allowed for this problem. That means ...
5
votes
1answer
103 views

Minimum number of coins - (dynamic programming solution - topdown approach)

This is a problem from topcoder tutorials Given a list of N coins, their values (V1, V2, ... , VN), and the total sum S. Find the minimum number of coins the sum of which is S (we can use as many ...
2
votes
1answer
43 views

Binary convert to string in Ruby

This was a challenge for reddit #202 Easy /u/learnprogramming ...I wish that someone reviews my code and let me know your opinion about my way of thinking beacause I am a total beginner in Ruby: ...
1
vote
5answers
50 views

CCC Rövarspråket (Pig Latin) translator

I have a challenge: In Sweden, there is a simple child's game similar to Pig Latin called Rövarspråket (Robbers Language). In the CCC version of Rövarspråket, every consonant is replaced by ...
12
votes
1answer
114 views

Project Euler #54 - Poker Streams

This challenge posted by Durron597 intrigued me, and inspired me to answer his question, and also to determine whether a more functional approach was available for poker hand ranking. The problem ...
4
votes
1answer
66 views

Project Euler #54 Solution Follow-up

This is my second solution to Project Euler #54.. You can find the original post here. Brief problem summary: The file, poker.txt, contains one-thousand random hands dealt to two players. Each ...
0
votes
1answer
20 views

Bridge Transport - contest practice

I'm practicing for a contest by doing some of the older problems, and I was wondering if there are more efficient ways of doing this or if I'm not following any coding conventions. Most importantly, I ...
10
votes
2answers
769 views

Project Euler #54 Solution

This is not the latest question in iterative code review of this program. You can find the latest answer here. Here's my solution to Project Euler #54. Click the link for the full project ...
6
votes
3answers
98 views

Sieve of Sundaram for Project Euler 7

This is a sequel to my previous question: Sieve of Sundaram for Project Euler 7: Python implementation slower than C++ and R I am trying to implement the Sieve of Sundaram in various languages to ...
8
votes
3answers
324 views

Two sets came to an intersection

Challenge: Print set intersections. Specifications: Your program should accept as its first argument a path to a filename. Each line in the file is a test case. Each test case contain ...
2
votes
1answer
43 views

HackerEarth Crazy kangaroo challenge

I want to find the lowest hop count from source to destination. The challenge, in summary: The first line contains the number of test cases T, 1 ≤ T ≤ 100000. The next T lines each contains ...
2
votes
2answers
86 views

Project Euler - Smallest multiple

Here's Problem 5 - Smallest multiple 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 number that is evenly ...
1
vote
1answer
39 views

Naive primality test and summation

I am starting to learn Haskell, so I coded a naive solution to the primality test and summation of primes (Project Euler Problem 10: sum of all primes under 2 million) . As I have an imperative ...
2
votes
2answers
59 views

Given a digit sequence, print the possible decodings of the given digit sequence

Examples: 12 gives: 'AB' and 'L' and 123 gives 'ABC', 'LC' and 'AW' Here is my attempt: ...
8
votes
3answers
85 views

Project Euler #8 - Largest product in a sequence

I've just finished Project Euler Problem 8, which ask for the greatest product of any sequence of 13 consecutive digits in a given string. I wonder if there's something that could be improved. ...
8
votes
3answers
88 views

Sending duplicate to heaven with Java 8

Follow up to Duplicate like a weapon, arrays like heaven. @rolfl suggested in chat that I try to complete this challenge again in a Java 8 friendly way. I took the opportunity to also employ the ...
4
votes
1answer
70 views

Project Euler problem 12 in Ruby

I've been trying to optimize this while making it readable. Thoughts? The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 ...
3
votes
1answer
35 views

Project Euler #10 in Cython

I'm trying to teach myself some Cython. To do so, I use Project Euler #10: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. 2 Find the sum of all the primes below two million. My Cython ...
15
votes
4answers
1k views

Duplicate like a weapon, arrays like heaven

Challenge: Find the duplicated entry. Specifications: Your program should accept as its first argument a path to a filename. Each line in this file is one test case. Each line ...
3
votes
2answers
67 views

Premium palindromic primes

Challenge: Write a program which determines the largest prime palindrome less than 1000. The answer is 929, and my program correctly finds and prints this, but actually ended up being more complex ...
2
votes
1answer
128 views

“Team formation” challenge

I'm trying to solve this problem but am getting a timeout. Can someone help me to improve? ...
1
vote
2answers
114 views

100 doors exercise code using C#

Can you please check my code if it is correct for the problem 100 doors? This is the problem: You have 100 doors in a row that are all initially closed. You make 100 passes by the doors. ...
7
votes
1answer
495 views

An Army of Ones

I've been practicing using recursion lately and thought this was a case where it would prove really useful, is this good use or is there some superior non-recursive way to go about it? Challenge: ...
5
votes
4answers
410 views

Digital root recursive function

Haven't any experience writing recursive functions.(Generally tend to avoid them - not sure if that's a negative). What do you think about the following? This is also my first time using JUnit, I'd ...
11
votes
2answers
267 views

LOL'ing-Up Project Euler One

It's been a while since I last wrote some lolcode, so I felt like tackling Project Euler #1. 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 ...
0
votes
1answer
61 views

Join 2 arrays together

There are 2 arrays. One that consists of Categories and one of Products. Each product pertains to its specific category. I want ...
10
votes
2answers
161 views

The finest integers are palindromes

Challenge: Reverse the digits of a number and add it to the original until the number is a palindrome Specifications: Your program should accept as its first argument a path to a filename. ...
3
votes
2answers
78 views

Project Euler Retreat

Now I am doing Project Euler number 1: 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 ...
3
votes
2answers
381 views

Hacker Rank - Lonely Integer

This is the problem statement for Lonely Integer. There are N integers in an array A. All but one integer occur in pairs. Your task is to find out the number that occurs only once. Input Format ...
4
votes
1answer
56 views

Multiplying Lists

Challenge: Given 2 lists of positive integers. Write a program which multiplies corresponding elements in these lists Specifications: Your program should accept as its first argument a ...
4
votes
4answers
135 views

Finding Lottery odds - Topcoder #268

I have implemented the question #268 from Topcoder. The question is that there are 4 conditions for a lottery ticket: CHOICES - numbers available (10 ≤ CHOICES ≤ 100) BLANKS - number of numbers that ...
6
votes
1answer
112 views

HackerRank - Insertion Sort - Part 2

This is the problem statement for Insertion Sort - Part 2. In Insertion Sort Part 1, you sorted one element into an array. Using the same approach repeatedly, can you sort an entire unsorted array? ...
1
vote
2answers
35 views

Solution to Project Euler #1 - multiples of 3 and 5

I have been programming for about ~2 years, and mostly wrote OOP and structural code. Recently, I have decided to pick up a functional programming language, and Haskell being too alien for me, looked ...
5
votes
1answer
64 views

Project Euler #10 in Java

Project Euler #10: The sum of the primes below 10 is \$2 + 3 + 5 + 7 = 17\$. Find the sum of all the primes below two million. My solution: ...
3
votes
3answers
119 views

Project Euler 35: Circular primes below 1 million

I'm doing another Project Euler problem, number 35, and I need help improving my code speed: The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, ...