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

learn more… | top users | synonyms (2)

2
votes
4answers
110 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
47 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 ...
4
votes
2answers
42 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
45 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 ...
1
vote
1answer
22 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 ...
6
votes
3answers
301 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
88 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
82 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. ...
4
votes
2answers
76 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
42 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
528 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
79 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 ...
3
votes
3answers
102 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
123 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 ...
2
votes
1answer
39 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
40 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
46 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
47 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 ...
4
votes
3answers
84 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
56 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
57 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 ...
4
votes
4answers
568 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
392 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
120 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 ...
3
votes
3answers
87 views

General solution to sum multiples of multiple numbers below a limit

sumMultiples() is a working general solution to Project Euler's first problem. Don't read it if you want to try it yourself. This question is about preserving ...
3
votes
1answer
57 views

Project Euler #10 in Swift - Summation of primes

I just finished Project Euler #10 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. I hope I learned some from ...
4
votes
3answers
314 views

Project Euler Problem 12 - triangle number with 500 divisors

I've just done Problem 12 of Project Euler: What is the value of the first triangle number to have over five hundred divisors? The \$N\$'th triangle number is the sum of all natural numbers ...
5
votes
6answers
158 views

Project Euler problem 4 in Ruby

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two ...
2
votes
1answer
39 views

Project Euler #9 in Swift - Special Pythagorean triplet

I just finished Project Euler #9 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. A Pythagorean triplet is a ...
2
votes
3answers
85 views

Project Euler #8 - Largest product in a series

I just finished Project Euler #8 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 four adjacent digits in ...
1
vote
1answer
42 views

Project Euler #4 in Haskell

Project Euler #4 asks: Find the largest palindrome made from the product of two 3-digit numbers. The code is as follows: ...
1
vote
1answer
32 views

Project Euler #3 in Haskell

Project Euler #3 asks: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? I've written a general solution for any number: ...
2
votes
2answers
65 views

Attemped Sieve of Eratosthenes

I've just done Project Euler question 10: Find the sum of all the primes below two million. I get the correct answer and it takes about 3.5-4 seconds to run. I tried to use the Sieve of ...
2
votes
3answers
43 views

Perfect number Calculation

Perfect numbers are strictly positive whole numbers of which the sum of their positive divisors equals a multiple of the number itself. An example of a 3-perfect number is 120. The sum of all divisors ...
5
votes
2answers
113 views

Project Euler #7 - 10001st prime

I just finished Project Euler #7 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. By listing the first six ...
7
votes
5answers
217 views

Project Euler #3 in Java

Project Euler #3: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Here is my solution: ...
6
votes
5answers
805 views

Project Euler #2 in Java

Project Euler #2: 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, ...
4
votes
3answers
139 views

Project Euler #1 in Java

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 ...
2
votes
1answer
70 views

Calculate possible balances in piggy-bank by weight

I have solved Piggy-Bank problem on SPOJ using dynamic programming. The question asks you to get the minimum value that is possible with given weight (\$w\$) and one or more coins (\$n\$) with given ...
10
votes
2answers
394 views

Project Euler #22 - Names Scores

I programmed Problem #22 from Project Euler in Python. It works but I want to know if it really is pythonic enough. Using names.txt (right click and 'Save Link/Target As...'), a 46K text file ...
11
votes
1answer
89 views

First four Project Euler in Scala

I was working on teaching myself some Scala and decided to tackle some Project Euler problems. The first four of these turned out to be one liners. ...
8
votes
4answers
171 views

“Restaurant” HackerRank challenge in C

I don't write C all that often, so things to look for would be memory leaks and such. I also recognize that I'm not validating the user input as well as I could - I could use some feedback on how I ...
5
votes
4answers
79 views

Summing Divisors

Definition: A proper divisor of a natural number is the divisor that is strictly less than the number. e.g. number 20 has 5 proper divisors: 1, 2, 4, 5, 10, and the divisor summation is: 1 ...
4
votes
0answers
45 views

“The Ministry Of Truth” challenge at CodeEval.com

I am working on another challenge from CodeEval.com and this is a bit harder. I would like to get some feedback on my logic of solving the challenge. Also there is probably one edge case that I ...
4
votes
1answer
59 views

UVA 10474 - “Where is the marble?”

I have been solving the problem from UVA 10474. In this problem, there will be marbles with numbers written on them. For example suppose five marbles with numbers 50 , 43, 43, 43, 2, 90, 44. There ...
5
votes
4answers
91 views

Project Euler #3 In C++

The question for reference: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? answer: 6857 I'm looking for general feedback as to ...
5
votes
1answer
46 views

Reverse Groups challenge at CodeEval.com

I am working through challenges at CodeEval.com and wanted to get your input on my code for this challenge. Given a list of numbers and a positive integer k, reverse the elements of the list, k ...
0
votes
1answer
130 views

Project Euler - Problem #11 - Ruby

As a beginning Ruby programmer I implemented a solution for Project Euler, Problem #11. (The problem is described in the comment below.) I'll be grateful for any suggestions for improvement ...
4
votes
3answers
223 views

Length of the longest sequence of repeating characters

I have been going through some CodingBat exercises and I came across this problem. "Given a string, return the length of the largest "block" in the string. A block is a run of adjacent chars that are ...
4
votes
1answer
87 views

Speed up lights-out variant solver in pure Python

I'm doing some challenges to learn new and interesting concepts, this one is about a Lights out variant, instead of toggling only the adjacent tiles, it toggles the whole row and col. It must be ...