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

learn more… | top users | synonyms (2)

2
votes
1answer
45 views

Find the number of quadraples (a,b,c,d) from 4 respective arrays such that a+b+c+d=0

Given four lists of numbers, calculate how many ways there are to choose one element from each to get a sum of zero. The input is given on stdin, first ...
5
votes
2answers
309 views

Project Euler #13: Large Sum

Description: Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. ... Of course I didn't include the numbers in the description... I am sure there is a ...
-2
votes
0answers
37 views

Standard Dieviation code, how to do this using generics? [on hold]

I have been reading around a lot about generics and I find it useful when dealing with the repository pattern and patterns in general. But to date most of my code using generics has only been working ...
6
votes
2answers
74 views

Project Euler 22: Names scores

Description of challenge: Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. ...
-4
votes
0answers
21 views

Failing test cases Euler 116 [on hold]

I am trying to solve problem on euler. My code is passing only one test case. The problem statement is at https://projecteuler.net/problem=116 I am posting my code here and it is in java ...
-4
votes
0answers
24 views

Euler Project Fibonacci numbers. Why can't I use a for loop? [on hold]

I am having trouble understand why my code won't work to solve this Euler project problem. I thought of using a for loop to go through all number between 0 and 4000000, but it gives me the wrong ...
9
votes
5answers
462 views

Camp challenges in one program

My counselor in a camp I went to over the summer gave me a code challenge. To take 6 challenges (listed below) and have all of them in one program, and have the user choose which one to use. Please ...
-3
votes
0answers
21 views

Project Euler #10 code gives wrong result in Java [on hold]

I recently started to get back into Java and a friend told me to practice with Project Euler. Now I am stuck at Problem #10 and can't figure out why... Maybe you have any idea what I've done wrong. ...
-2
votes
0answers
15 views

Runtime Error RE (SIGSEGV) [closed]

Here is my code for finding the Σn/gcd(i,n) where i=1 to i=n and n have the range of 10^7. I have used totient-function for calculating the required sum. ...
4
votes
1answer
31 views

Collatz Sequence in Python

I'm trying to use Python to solve the Project Euler problem regarding the Collatz sequence. With some research online, I have come up with the code below. However, it still takes a long time to find ...
-1
votes
0answers
14 views

Project Euler Project 5 [closed]

I have a problem which says : 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 ...
4
votes
3answers
62 views

The Odd-Even Challenge

After posting my first question on here, I got a lot of great feedback. I've decided to try another challenge and write it as cleanly as possible. The rules of Odd-Even consists of the following ...
5
votes
1answer
49 views

Grooving Project Euler # 8

I recently watched a video course on groovy and started working on some of the Project euler problems to flex my groovy* muscle. (This is problem #8) The four adjacent digits in the 1000-digit ...
3
votes
1answer
119 views

Highest floor of a building from which to drop an egg without breaking it

Problem description: You have two eggs, and need to find the maximum floor of a 100-floor building from which you can drop the eggs without them breaking. Do this with as few attempts as possible. ...
2
votes
2answers
49 views

Sum of proper divisors

Given a natural number \$n\$ (\$1 \le n \le 500000\$), please output the summation of all its proper divisors. Definition: A proper divisor of a natural number is the divisor that is ...
7
votes
1answer
89 views

“Dungeon Game” solution

I was tackling this problem and I ended up with code that is functional, but times out with really large input (meaning it's poorly optimized). I'm a beginner in programming and working out a ...
2
votes
2answers
43 views

Block Art - IEEEXtreme 9.0

I attempted this problem from the ieeextreme, and I got timeout for just over 40% of the cases. Now that the competition is over, I was wondering what could be improved. The problem is as follows: ...
6
votes
1answer
70 views

Check sum of all primes under two million

I'm exploring ruby by writing a code that checks the sum of all prime numbers under two million. As I am still in the process of learning ruby, I'm unfamiliar with all the standards and best ...
5
votes
3answers
443 views

Project Euler 92: Square digit chains

A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before. For example, 44 → 32 → 13 → 10 → 1 → 1 85 ...
6
votes
5answers
663 views

Longest running string

I came across this problem in a career cup. Below I have the questions and the Java solution. I was wondering if anyone could scrutinize my code and tell me if there are any improvements, or better ...
-1
votes
1answer
38 views

Optimize finding GCD of all pairs of divisors

I've come up with a solution for Euler Problem 530, but my code runs too slowly to actually get the answer (solving for 10^15). What can I do to optimize it to run faster? ...
3
votes
1answer
58 views

Generating the maximum number possible from an array

I have the following code in Scala as a solution to the problem: Find the maximum number possible from the given Seq of Integers while keeping the individual numbers intact e.g. Seq(2,5,9,4) ...
4
votes
1answer
144 views

Counting ways to fit bottles in crates

I'm calculating how many possibilities there are to fit \$n\$ identical bottles inside \$k\$ crates of various capacities. n = Number of bottles k = Number of crates K = List of the number of ...
5
votes
1answer
49 views

De Casteljau's Algorithm Tool for Khan Academy Contest

So I wrote this code for a contest going on over at Khan Academy known as "Pixar in a Program". The goal of the contest is to create an entry that uses one of the skills shown in the new "Pixar in a ...
2
votes
2answers
93 views

Solving for equilibrium index in an array

I did a sample on Codility and finished the test task. The problem description is very short: The equilibrium index of a sequence is an index such that the sum of elements at lower indexes is ...
1
vote
2answers
107 views

Determining if two strings are anagrams

Two strings are said to be anagrams of each other if the letters of one string may be rearranged to make the other string. For example, the words 'elvis' and 'lives' are anagrams. In this ...
2
votes
1answer
47 views

Optimize program to test for divisibility of numbers 3.0

This is a follow up on my previous question. JS1's answer suggested that I should use a precomputed table containing all permutations of the lowest valid number for each number between 1 and MAX. It ...
3
votes
1answer
60 views

Testing for divisibility of numbers - follow-up

(Here is the follow up question) I had another go at trying to speed up my program described in my previous question. JS1's answer was particulary helpful and now my code is only about 20% slower ...
5
votes
1answer
55 views

Project Euler no. 17: Counting letters to write the numbers from 1 to 1000

I'm very new to programming and am admittedly embarrassed sharing my code for critique. This code works and produces the correct answer to the Project Euler Problem 17, which asks how many letters ...
2
votes
2answers
77 views

Program to test for divisibility of numbers

(EDIT: here is the follow up qusetion) Using this program to test for the smallest number where its permutations or itself is divisible by 10 or less numbers is twice as slow as the fastest program I ...
1
vote
1answer
37 views

Find permutation of a specified lexicographic rank

This is one result of my work on Project Euler to learn Java. I'm interested in how well this conforms to best practices as well as any recommendations on efficiency. (I'm pretty sure this code is a ...
2
votes
2answers
63 views

Waterloo Programming Contest: The Game of 31

Please review my program for the Game of 31. The game of 31 was a favourite of con artists who rode the railroads in days of yore. The game is played with a deck of 24 cards: four labelled each ...
2
votes
1answer
34 views

Project Euler Problem 2 in Java

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, ... By ...
2
votes
2answers
70 views

Project Euler #85: Find the rectangular grid with closest to 2M rectangles

For one place that I interviewed at (for a Python developer position) I worked with one of the devs on two Project Euler problems, one being problem 85. We talked through different approaches and came ...
5
votes
2answers
105 views

Project Euler problem 79: deducing a passcode

For one place that I interviewed at (for a Python developer position) I worked with one of the devs on two Project Euler problems, one being problem 79. We talked through different approaches and came ...
3
votes
2answers
258 views

Project Euler #42 - Triangle Numbers

Here is the Euler problem referenced, it says: The n\$^{th}\$ term of the sequence of triangle numbers is given by, t\$_n\$ = ½n(n+1); so the first ten triangle numbers are: 1, 3, 6, 10, ...
3
votes
2answers
48 views

Project Euler 62: cubic permutations, logic

Problem 62 of Project Euler goes The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has ...
6
votes
3answers
653 views

Find total number of phone numbers formed by the movement of Knight and Bishop on keypad

I recently gave a test on HackerRank, and submitted my answer for the following question. I passed all the test cases but company told me that the answer is not efficient, and they are not moving ...
2
votes
1answer
44 views

Summations and products in F#

I was bored, and looking to do something that involved anonymous functions, and it was suggested by @Quill, that I create a summation function. I decided to also include a product function as well to ...
2
votes
2answers
90 views

Gluing pieces of scrambled text (challenge on CodeEval)

I'm trying to solve this challenge on CodeEval. Quoting: For example, you can put pieces together and get the original text: evil pl vil pla il plan The answer is ‘evil plan’. Your ...
2
votes
3answers
81 views

Palindrome numbers - Project Euler Problem 4

Project Euler Problem #4: Largest palindrome product: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. ...
5
votes
1answer
51 views

Project Euler 40: directly calculate digits of Champernowne's constant

I implemented Project Euler problem 40 in Java. It works correctly, producing the correct answer. During the course of implementing this program, I wrote a method that directly calculates a digit of ...
5
votes
1answer
82 views

Project Euler: #36 Binary and Base 10 Palindromes

Here is the Euler problem referenced, it says: The decimal number, 585 = 1001001001\$_2\$ (binary), is palindromic in both bases. Find the sum of all numbers, less than one million, which ...
9
votes
5answers
176 views

ASCII generator

Today I stumbled upon CodinGame, a site with programming challenges. I'll describe one of them. ASCII art allows you to represent forms by using characters. To be precise, in our case, these forms ...
4
votes
2answers
77 views

Flowers Challenge on HackerRank

I worked through the Flowers challenge on hackerrank.com and would like to get feedback on solution and algorithm implementation. It was suggested by hackerrank to review greedy algorithm to solve ...
4
votes
4answers
90 views

“Tractor” Python implementation

This is the Tractor problem from the Kattis problems archive. Problem Statement Bessie the Cow has stolen Farmer John’s tractor and is running wild on the coordinate plane! She, however, is a ...
3
votes
2answers
81 views

“Cut the sticks” Python implementation

Problem Statement You are given N sticks, where the length of each stick is a positive integer. A cut operation is performed on the sticks such that all of them are reduced by the length of the ...
1
vote
1answer
43 views

Euler #25 Scala

I usually write Euler solutions in Javascript. On problems requiring very large integers I have decided to learn Scala and take advantage of BigInt. I wrote a ...
6
votes
3answers
952 views

“Angry Professor” Python implementation

Problem Statement The professor is conducting a course on Discrete Mathematics to a class of N students. He is angry at the lack of their discipline, and he decides to cancel the class if there ...
2
votes
3answers
41 views

Project Euler 30 - Digit fifth powers in Rust

I am trying to move from Python to a systems programming language so this is a bit of a challenge for me. ...