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

learn more… | top users | synonyms (2)

0
votes
0answers
31 views

Can this averager be minified below 140 bytes? [on hold]

I'm trying to implement my favorite averager in JavaScript, and then minify it down below 140 bytes. Here's what I have so far: ...
5
votes
3answers
76 views

Project Euler #9 - Pythagorean triplets

This code works, and I'm trying to figure out if there's a better way to optimize it. As you can see, I've cut down drastically on time just by using numbers that work for ...
9
votes
2answers
557 views

Clean code attempt at ATM problem on codechef.com

The problem asks you to take an integer (debit amount) and a double (credit or initial balance amount) and process the requested debit verifying that 1 it's a multiple of the minimum denomimation ...
-2
votes
1answer
44 views

Faster implementation of Project Euler #35 (circular primes) [on hold]

Problem #35 on Project Euler is: The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes below ...
4
votes
1answer
76 views

Project Euler #12 very long runtime

Project Euler Problem 12 asks to find the value of the first triangular number to have over 500 divisors, where the \$n\$th triangular number is \$\sum_{i=1}^{n} i\$. The sequence of triangle ...
0
votes
0answers
28 views

Solving Subset problem in a recursive way [on hold]

I have tried to solve the following problem but I still get wrong answer, however the two test cases in the problem are correct answer for me. Problem Statement: Subsets Sum, or "SS" (double S) for ...
4
votes
2answers
104 views

Reverse Game HackerRank Ruby Solution

Problem Statement Akash and Akhil are playing a game. They have N balls numbered from 0 to N−1. Akhil asks Akash to reverse the position of the balls, i.e., to change the order ...
3
votes
4answers
111 views

Code Kata - Berlin Clock

To improve my programming style, I have been writing solutions for popular code katas. I have written a partial solution for the [Berlin Clock kata][1]. Can anyone critique the code and suggest ...
5
votes
2answers
105 views

Reducing the execution time of Online Community-Even Groups challenge

I have a coding problem for which I have attempted to solve with the below coding. However, my program is assessed as too slow in its execution and thus needs to be optimized to reduce the execution ...
-1
votes
1answer
2k views

Stone Game One Four [closed]

Alice and Bob are playing a game called "Stone Game". Stone game is a two-player game. Let N be the total number of stones. In each turn, a player can remove either one stone or four stones. The ...
8
votes
2answers
411 views

Clean code attempt on codechef.com FCTRL

I have been reading Clean Code and decided to start working problems on Codechef.com attempting to apply some of what I have learned. Do I seem to be on the right track or am I way off? The ...
8
votes
1answer
332 views

Project Euler #2

Problem: 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, 55, 89, ...
19
votes
4answers
2k views

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 of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. My ...
2
votes
3answers
99 views

“Remove Friends” problem time efficiency too slow

I'm doing this problem: After getting her PhD, Christie has become a celebrity at her university, and her Facebook profile is full of friend requests. Being the nice girl she is, Christie ...
19
votes
5answers
2k views

Aliens at the train

I solved this problem on SPOJ: The aliens have arrived to Earth and everything is in harmony, the two races can live together. However, one specific Female Alien does not want to see humans ...
6
votes
2answers
294 views

Project Euler #8: Maximum product of 13 consecutive digits

I've solved problem #8 in Project Euler, which asks to find the 13 consecutive digits with the greatest product from a particular 1000-digit number. I would like to hear any suggestions regarding my ...
3
votes
4answers
981 views

Given only a pointer to a node to be deleted in a singly linked list, how do you delete it?

Example: If a linkedlist list contains 10->20->30->40, and 2nd node has to be deleted then the output should be 10->30->40 This question is attributed to Geeksforgeeks. Looking for code-review, ...
4
votes
3answers
281 views

Google Code Jam - Store Credit

Below is my answer to the Google Code Jam's answer to the Store Credit. As usual the code run's perfectly well, however, my credit_pos function gives a warning when ...
5
votes
4answers
1k views

Google Code Jam - reverse words

As a sequel from my previous question, I decided to solve the next problem statement from the GCJ dash board. Any thorough critique, this time, with much attention to skill and technicalities would ...
4
votes
1answer
66 views

Log file processor - Programming Contest

Problem Description A profiler is a tool which provides information about run-time performance of an application. Lets say. you are given output file format of a profiler called Jensor. Jensor ...
11
votes
6answers
1k views

Google Code Jam - T9 Spelling with C++

I am trying to improve my coding skills. As a result, I solved the T9 Spelling question from the Google Code Jam dashboard. I will appreciate it if anyone could critique the code, and provide ...
3
votes
3answers
82 views

List primes within an interval

I'm trying to solve the SPOJ primes problem: Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers! ...
1
vote
2answers
60 views

Calculating the Nth number in the supertable of two numbers

Below is the problem: Little Timmy is exceptionally good at math tables, so his teacher decided to make things a bit more interesting. His teacher gave him two numbers, A and B, and told him to ...
3
votes
3answers
451 views

Programming Challenge: Drawing Tool

Introduction to the problem You are free to implement any mechanism for feeding input into your solution. You should provide sufficient evidence with unit tests that your solution is ...
2
votes
3answers
400 views

Efficiency of Project Euler problem 35

The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, ...
2
votes
3answers
132 views

Finding Pythagorean Triple that sums to 1000

I am doing this Project Euler Question #9: A Pythagorean triplet is a set of three natural numbers, \$a < b < c\$, for which, $$a^2 + b^2 = c^2$$ For example, \$3^2 + 4^2 = 9 + 16 ...
2
votes
1answer
57 views

Efficiency on Project Euler Problem #8

I am doing Project Euler problem #8: The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. ...
4
votes
3answers
154 views

Sum of Squares/Square of Sum Difference

I am doing Project Euler problem #6. This is the question it asks: The sum of the squares of the first ten natural numbers is, $$1^2 + 2^2 + \ldots + 10^2 = 385$$ The square of the sum ...
10
votes
2answers
228 views

ISBN missing number solver

This is a programming contest question. Question as follows Problem Definition An ISBN (International Standard Book Number) is a ten digit code that uniquely identifies a book. The first 9 ...
2
votes
2answers
55 views

Efficiency of Project Euler 28 - number spiral diagonals

I have written a solution for Problem 28. Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: $$\begin{array}{rrrrr} ...
4
votes
4answers
518 views

Temperature conversion table

This is another solution for this challenge. Problem statement: In this challenge, write a program that takes in three arguments, a start temperature (in Celsius), an end temperature (in ...
10
votes
3answers
1k views

Wow that's a big integer! What's its largest prime factor?

I see that there are a few other people who have tackled Project Euler Problem #3. I hope you're not all sick of that question yet. I've not taken a look at those yet (purposely), but am about to now. ...
4
votes
1answer
55 views

Computation for finding the largest prime factor of 600851475143 is slow

I implemented the following for Project 3 in Project Euler: ...
9
votes
2answers
73 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
147 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 ...
9
votes
3answers
367 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
80 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. ...
3
votes
2answers
94 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
60 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
78 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
92 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
90 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
106 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
98 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
144 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 ...
6
votes
1answer
118 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. ...
21
votes
5answers
445 views

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
59 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
83 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 ...