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

learn more… | top users | synonyms (2)

2
votes
3answers
26 views

Check if all lotto numbers are covered in input

Each ticket for the Pick-10 lotto has 10 unique numbers ranging from 1 to 99. Suppose you buy a lot of tickets and like to have them cover all numbers from 1 to 99. Write a program that reads the ...
2
votes
1answer
27 views

Vitaly & Pie Programming challenge

I've been trying to solve this problem on Codeforces: Challenge description: After a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. ...
7
votes
4answers
1k views

Palindrome program

Given a beginning and ending point, check how many numbers are palindromic. My solution is a bit clunky. How could it be more elegant? ...
8
votes
4answers
456 views

Calculate Digital Root

Here's my solution for finding the digital root of a number. Just for purposes of completion, a digital root is: "If you take the digits of any number and add them together, and then add the ...
5
votes
2answers
121 views

Project Euler #4 Largest Palindrome Product

I'm kinda new to Java (<1 year) but have some background in C and Python. I've come up with a working solution to Project Euler Problem 4 - Largest Palindrome Product. However, I'm not confident ...
5
votes
3answers
172 views

Performing several integer division operations on an array

Program: Given an array A of size N. Given Q operations, each operation contains an integer D. In each operation you have to divide all the elements of the array by D. For example, ...
2
votes
5answers
116 views

Writing the function strend()

Due to being unable to ask a C programming language expert or advanced user in person, I'm posting this simple question about my C code. Today I was refreshing my C with exercise 5.4 of the C ...
8
votes
2answers
322 views

The 3n + 1 algorithm for a range

Essentially the Collatz Conjecture. Challenge requirements are here. And here is my implementation in Java: ...
1
vote
2answers
31 views

Univariate polynomial multiplication using Doubly Linked List

A univariate polynomial is a polynomial over a single variable, and in the following discussion when we say polynomial, we mean a polynomial in a single variable. You are given two polynomials ...
3
votes
2answers
74 views

Improving the efficiency of my FizzBuzz algorithm [closed]

I worked on an exercise from codewars, which is a variation of the popular fizzbuzz game. (If the link doesn't work, you may need to reload the page.) In this variation, I'm supposed to find the sum ...
1
vote
0answers
50 views

Payment Gateway - single payment with credit card (handling path & choosing gateway)

This was an assignment and I am new to Node.js. You can find the complete project here. The code worked fine but was rejected, and wasn't given any reason even after asked. Statement: Create a ...
3
votes
2answers
65 views

2D vertex of multiple countries

CodeChef - QPOINT Given a 2D vertex of multiple countries, find which country contains a certain point. Input format: ...
5
votes
1answer
27 views

Triangulate the divisors and divide the triangulars

Project Euler 12 - Highly divisible triangular number The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be \$1 + 2 + 3 + 4 + 5 + 6 + 7 = ...
9
votes
5answers
452 views

Count duplicates

Problem statement: Given an array of unknown size and containing only integers between 0 to 30 (inclusive), write an algorithm to find which numbers are duplicated, if any My solution in C#: ...
5
votes
1answer
44 views

Interface to a CSV dinosaur database

I have just finished with the first Ruby exercise on Level Up Rails, and wanted to get an idea on how I can refactor the code. You can find the original exercise on github - including the ...
1
vote
1answer
118 views

Project Euler 25 - 1000-digit Fibonacci Number

I have recently completed problem 25 from the project Euler site. The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 ...
5
votes
2answers
460 views

Project Euler 29 - Distinct Powers

I have just completed problem 29 from the Project Euler website: Consider all integer combinations of \$a^b\$ for \$2 \le a \le 5\$ and \$2 \le b \le 5\$: \$2^2=4\$, \$2^3=8\$, \$2^4=16\$, ...
10
votes
1answer
155 views

Series, Powers, and Benches

Project Euler problem 48 The series, \$1^1 + 2^2 + 3^3 + ... + 10^{10} = 10405071317\$. Find the last ten digits of the series, \$1^1 + 2^2 + 3^3 + ... + 1000^{1000}\$. I made two different ...
10
votes
1answer
126 views

The answer to life, the universe, and Project Euler

I've never did a real Project Euler in my life, so I figured it was about to do one. And what better Project Euler to start with than Problem 42? Project description from Project Euler: By ...
9
votes
1answer
221 views

Arranging 8 queens on an 8x8 board

Print all the ways of arranging eight queens on an 8x8 board. Rules: Queens should not share the same row, column, of any diagonal. Any comment on my solution? I didn't write unit tests but I ...
8
votes
2answers
210 views

Finding the Mth to last Element

Challenge: Write a program which determines the Mth to last element in a list. Specifications: The first argument is a path to a file. The file contains series of space delimited ...
7
votes
2answers
246 views

Implementing a stack and using it to print alternate elements in reverse

Challenge: Implement a stack interface. Specifications: The interface should have ‘push’ and ‘pop’ functions. Your task is to ‘push’ a series of integers and then ‘pop’ and print every ...
7
votes
2answers
292 views

The only thing better than being unique

is being first and unique. Challenge: Write a program which finds the first non-repeated character in a string. Specifications: The first argument is a path to a file. The file contains ...
1
vote
1answer
304 views

Number of interesting numbers between two given numbers

Please have a look into this problem: Little Dipu is a small kid and like all the other kids, he likes to play, but he plays with numbers (he is extraordinary you know). Nowadays Dipu has some ...
5
votes
1answer
96 views

Project Euler 8 - Redux

Spurred by this question: Project Euler #8 I decided to try to solve it with as clean code as possible. Here is the problem formulation: The four adjacent digits in the 1000-digit number that ...
12
votes
2answers
182 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
3answers
100 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
67 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
54 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
52 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
322 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
64 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
202 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
127 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
40 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
60 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
63 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
388 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
71 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
47 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
149 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
50 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: ...
2
votes
5answers
87 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
127 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
76 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
26 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
802 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
108 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
336 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
54 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 ...