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

learn more… | top users | synonyms (2)

0
votes
1answer
51 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 ...
8
votes
1answer
100 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
62 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 ...
-1
votes
0answers
13 views

Code for finding longest substring in a given string [closed]

I know this code is probably too erroneous, but I can't debug it. Can anybody help? ...
3
votes
2answers
98 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
45 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
118 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 ...
0
votes
0answers
50 views

Hackerrank Circle City [closed]

I've been trying to solve this relatively simple challenge, but I can't figure out where the problem in my code is. Here is the reference question: https://www.hackerrank.com/challenges/circle-city ...
6
votes
1answer
86 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
30 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
54 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
85 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, ...
3
votes
2answers
53 views

Project Euler #7 in Java

Project Euler #7: By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? Here is my solution: ...
4
votes
2answers
51 views

Timus Online Judge Problem 1001 - “Reverse Root”

The problem statement can be found here. Description (short): Input The input stream contains a set of integer numbers \$A_i\$ (\$0 \le A_i \le 10^{18}\$). The numbers are separated by any number ...
4
votes
3answers
78 views

Project Euler #6 in Java

Project Euler #6: The sum of the squares of the first ten natural numbers is, \$1^2+2^2+ ... + 10^2 = 385\$ The square of the sum of the first ten natural numbers is, \$(1+2+ ... + ...
3
votes
4answers
402 views

Project Euler #5 in Java

Project Euler #5: 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 divisible by ...
4
votes
8answers
2k views

Project Euler #10 — Summation of primes takes forever

I have resolved the Problem presented in 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. But this code takes too ...
6
votes
1answer
115 views

Cash Register Challenge

Challenge: Design a cash register program Specifications: Your register currently has the following bills/coins within it: 'PENNY': .01, 'NICKEL': .05, 'DIME': .10, 'QUARTER': .25, ...
1
vote
1answer
45 views

Time limit exceeded for Sherlock and Queries Hackerrank challenge

Here is my C solution for Sherlock and Queries @ Hackerrank. Watson gives to Sherlock an array: \$A_1, A_2, ..., A_N\$. He also gives to Sherlock two other arrays: \$B_1, B_2, ..., B_M\$ and ...
3
votes
2answers
348 views

Project Euler #14 solution takes quite a long time

Can anybody give me suggestions for making it faster? (Project Euler #14) ...
3
votes
1answer
71 views

“Sharing CANDY” on SPOJ

How can I improve it and its running time efficiency? Problem (SPOJ/CANDY) Jennifer is a teacher in the first year of a primary school. She has gone for a trip with her class today. She has ...
2
votes
1answer
46 views

FizzBuzz from a file

This was found on CodeEval. Challenge: Write a program that prints out the final series of numbers where those divisible by X, Y and both are replaced by “F” for fizz, “B” for buzz and “FB” for fizz ...
2
votes
1answer
64 views

Accessing list elements when counting the number of rectilinear paths

I am trying to solve the RIVALS problem on SPOJ: Starting from (0, 0), how many paths are there to reach point (X, Y), only taking one-unit steps moving to the right or up? Constraints: 0 ≤ X ≤ 106, ...
3
votes
4answers
159 views

Java vs C++ (JAVAC)

Here's the problem for Java vs C++ (JAVAC): Java and C++ use different naming conventions. In Java a multiword identifier is constructed in the following manner: The first word is written ...
2
votes
2answers
67 views

Four fours to get any number

I decided to solve a problem from Code Golf called the four fours. Problem description: The Four fours puzzle is a popular recreational mathematical puzzle that involves using exactly four 4s ...
5
votes
2answers
105 views

Project Euler #7: 10001st prime

This is my implementation of Project Euler #7. Have I overdone it again? Is there anything else I should or should not do? It runs in 9 milliseconds on my computer. What is the 10001st prime ...
5
votes
2answers
69 views

Project Euler Attack #2

This is my implementation of Project Euler #2 in C#. It takes 0 milliseconds to run, and I believe it is correct - I have seen nothing to indicate otherwise! By considering the terms in the ...
4
votes
1answer
53 views

Converting to Roman Numeral with Recursive Algorithm

Summary I'm getting ready to dive back into a "more proper" project, so I wanted to take a moment to get my TDD hat on before doing so. I decided to tackle this Roman Numeral Kata for practice. The ...
7
votes
3answers
335 views

Project Euler #2 (Fibonacci Sequence)

Challenge: 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. Consider a ...
1
vote
4answers
109 views

Project Euler #1 - JavaScript

I'm new to JavaScript, and decided to learn the language by running through as many of the Project Euler problems as I have time to do. I just finished the first one, and am looking for some feedback, ...
1
vote
1answer
95 views

Summation of Arithmetic Progression Modulo Series

Here is the link to the problem: Aladin on Kattis.com Problem Aladin was walking down the path one day when he found the strangest thing: N empty boxes right next to a weird alien machine. ...
5
votes
2answers
89 views

Project Euler #5 (LCM 1 - 20) Follow up

I'm actually spending time on it, unlike the first time and going through, understanding and implementing the several suggestions I've landed on two different approaches. Approach 1: Employing Java 8 ...
3
votes
0answers
49 views

Evaluating Fibonacci-sequence-based recurrence relation (SPOJ Flibonakki)

I have a function fib2 which returning two values as Tuple but I want to print the product of tuples returned by function fib2. I am new to Haskell so please ...
4
votes
4answers
546 views

Project Euler #5 (LCM of 1-20)

Challenge: 2520 is the smallest number divisible by 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by 1-20? Solution: ...
5
votes
1answer
91 views

Optimizing a dynamic programming solution for “Oil Well”

I'm trying to solve the Oil Well problem on Hackerrank using dynamic programming and it works. However, it times out for some of the test cases. I wanted to know how this program can be improved so ...
4
votes
3answers
120 views

Project Euler Problem #10

I've read other solutions about solving the 10th problem for Project Euler (finding the sum of all prime numbers under 2,000,000) but I wanted to try it on my own using the Sieve of Eratosthenes ...
4
votes
1answer
138 views

Project Euler Problem #6 - sum square difference

The sum of the squares of the first ten natural numbers is: \$1^2 + 2^2 + ... + 10^2 = 385\$ The square of the sum of the first ten natural numbers is: \$(1 + 2 + ... + 10)^2 = 55^2 ...
3
votes
1answer
60 views

Project Euler #16 in Swift - Power digit sum

I just finished Project Euler #16 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it. 2^15 = 32768 and the sum ...
1
vote
2answers
43 views

Project Euler #14 in Swift - Longest Collatz sequence

I just finished Project Euler #14 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it. The following iterative ...
1
vote
2answers
56 views

Project Euler #13 in Swift - Large sum

I just finished Project Euler #13 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it. Work out the first ten ...
2
votes
1answer
51 views

Project Euler #12 in Swift - Highly divisible triangular number

I just finished Project Euler #12 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it. The sequence of triangle ...
1
vote
1answer
67 views

Determining the existence of string Intersections

Problem: Given 2 strings, consider all the substrings within them of length len. Len will be 1 or more. Returns true if there are any such substrings which appear in both strings. Compute ...
3
votes
1answer
80 views

Finding the length of the largest run

Note: A run is a series of adjacent chars that are the same. I just want to answer a few questions: Is this readable? Does it need commenting or is it self-descriptive enough? Are there any ...
4
votes
3answers
93 views

Find the last element of a list

Find the last element of a list from codewars.com Example: last( [1,2,3,4] ) # => 4 last( "xyz" ) # => z last( 1,2,3,4 ) # => 4 I completed this ...
3
votes
0answers
69 views

Project Euler #14 — longest Collatz sequence

I was reading this question and realized that I didn't know Python well enough to critique the algorithm. So I wrote a Java solution instead, which is inappropriate for that question. Since there's ...
3
votes
1answer
62 views

Project Euler #14 (Longest Collatz sequence)

A Collatz sequence for a given positive integer \$n\$ is to take half of \$n\$ if even and \$3n+1\$ if \$n\$ is odd; repeat until the value goes to \$1\$. The question is which number from 1 to ...
1
vote
2answers
169 views

String 'expanding' - reinserting repeating characters

The challenge: Given a String, for each digit in that original string, replace that digit with that many occurrences of the character following it. So a3tx2z yields ...
4
votes
4answers
581 views

Project Euler #5 - Lowest common multiple of 1 through 20

This is my code. All comments welcome. Last time run it only took 335 milliseconds: ...
5
votes
4answers
397 views

Project Euler #12 - first triangle number with more than 500 divisors

I tried to solve Project Euler 12 with a first very naive solution by myself. It took nearly 30 minutes to run until it found the solution. Then I made a change in the function ...
-1
votes
1answer
126 views

Uniquely digitized 5-digit multiples

This is a programming problem: Write a program that finds and displays all pairs of 5-digit numbers that between them use the digits 0 through 9 once each, such that the first number divided ...