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

learn more… | top users | synonyms (2)

6
votes
1answer
33 views

Prime factorization in F#

In the pursuit of learning F#, I have been working through some Project Euler problems. This is my solution for problem 3: ...
5
votes
1answer
33 views

Haskell CodeEval Beautiful Strings

Problem Definition : When John was a little kid he didn't have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could... he evaluated the ...
3
votes
1answer
36 views

Euler Project 14 - Longest Collatz Sequence in PHP

This is my solution to Project Euler 14: The following iterative sequence is defined for the set of positive integers: ...
4
votes
4answers
67 views

Finding the max sequence finder

Problem Statement Find the max sequence finder. findMaxSequence([3, 2, 3, 4, 2, 2, 4]); ...
4
votes
2answers
65 views

Gretchen and the Play solution from Indeed Contest on hackerrank.com

This was one of the tougher challenges on hackerrank.com because the solution had to run under 4s time limit. I had to do a lot of optimization for this one. I had to switch from using Java 8 to Java ...
10
votes
2answers
42 views

What a crooked way to compute the next straight string (advent of code 11)

This year I have been participating in the Advent of Code series of challenges, and it just so happened that I'd be doing them in Javascript. Not my usual weapon of choice, but I do have some ...
3
votes
2answers
44 views

Very slow Project Euler Q3 (largest prime factor of a large number)

My code returns the correct answer for the example (highest prime of 13195 is 29), but when I test against the number in the question my code basically is too slow for my liking. The prime ...
4
votes
1answer
39 views

Finding the largest prime factor

As many people will undoubtedly recognise, this is a question in a well known series of problems that I won't name ;) It's been a long time since I've written any F# and I'm not sure I've ever come ...
6
votes
1answer
104 views

“Changing Bits” challenge

Problem Statement: Let A and B be two N bit numbers (MSB to the left). You are given initial values for A and B, and you have to write a program which processes three kinds of queries: ...
10
votes
2answers
589 views

Programming challenges: australian voting

I'm trying to solve the following problem: Australian ballots require that voters rank all the candidates in order of choice. Initially only the first choices are counted, and if one candidate ...
14
votes
4answers
690 views

Project Euler 6: Difference between sum of squares and square of sum

I've created a (very) simple solution for Project Euler problem 6: Project Euler Problem 6: Sum square difference The sum of the squares of the first ten natural numbers is, $$ 1^2 + 2^2 ...
4
votes
1answer
167 views

Project Euler Problems #1-#5

Since I've been playing with F#, I decided to try my hand at implementing some of the Project Euler problems, and I've been having a blast doing it. (f#-is-fun) So, I'm going to list all the Project ...
4
votes
2answers
96 views

Project Euler #1-3 in VBA

Self explanatory, and all the functions contain descriptions of their specific problem statements. Since this is project Euler, I would be particularly interested in any analysis of the ...
4
votes
1answer
62 views

Count solutions of a equation with a constraint

How to count the solutions of the equation \$x \cdot y + x \cdot z + y \cdot z = n, (0 \leq n \leq 10^4)\$ with the constraint that \$x \geq y \geq z \geq 0\$ ? To solve this i've isolated the z ...
2
votes
1answer
90 views

Triangle-numbers with lots of divisors (Project-Euler Problem 12)

The following is my python solution of project euler 12. The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be ...
8
votes
1answer
50 views

Haskell CodeEval FizzBuzz

CodeEval FizzBuzz Quick Description: Take 1 command line argument of a file-path. This file will contain test cases formatted as such 3 space separated numbers per line. For numbers ...
3
votes
1answer
34 views

Finding the largest not-necessarily contiguous alternating binary string after inverting any sub-string from a given string

I'm having problems solving this problem within the time limit. Alternative Thinking http://codeforces.com/contest/603/problem/A Kevin has just recevied his disappointing results on the USA ...
8
votes
6answers
1k views

Find if the string contains ALL the vowels

Problem: You are given a randoms string containing only lowercase letters and you need to find if the string contains ALL the vowels. Input: First line contains N , the size of the ...
2
votes
2answers
54 views

Project Euler 22: Names scores alternative

Can someone tell me how to improve my following python code. Code: ...
5
votes
1answer
87 views

Find the first unique character in a string

Implementation for a relatively basic programming challenge: Find the first unique character in a string So evaluating the string ABCA would return ...
10
votes
3answers
279 views

Optimization on Sieve of Eratosthenes using vector<bool>

I am solving this prime generator problem from SPOJ: Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given ...
7
votes
3answers
200 views

Reverse the character order of the words in a string

I've been trying to learn Java and one way I've been teaching myself is by tackling "programming challenge questions". One such question is "reverse the character order of words in a string". For ...
6
votes
3answers
316 views

Project Euler 18/67: Maximum Path Sum

The complete problem definition can be summarized as "find the largest sum of for paths from the top to the bottom of a triangle of integers". I decided to read the triangle in from a file which can ...
20
votes
8answers
1k views

Writing nested for loops to produce certain output

My task: Write nested for loops to produce the following output with each line 48 characters wide: ...
6
votes
1answer
90 views

Next Palindrome

I've written a function which, given a number string, returns the next largest palindrome in string form. For example, if the input string is "4738", the output ...
8
votes
1answer
162 views

Programming Challenge from Kattis: Apparatus

I am trying to solve apparatus problem, paraphrased below. There is an apparatus with n on/off switches with a one-to-one correspondence to n lights (but with an unknown permutation). We have ...
1
vote
2answers
36 views

Tape Equilibrium O(n)

Problem (Tape Equilibrium): A non-empty zero-indexed array A consisting of N integers is given. Array A represents numbers on a tape. Any integer P, such that ...
4
votes
2answers
478 views

Code Golf Challenge: Calculate Phi (not Pi)

I'm a newbie to C++ (coming from C#) and I decided to complete this Code Golf challenge for fun (though I definitely wouldn't say it's short). Essentially, the challenge was to calculate the ...
6
votes
5answers
331 views

Project Euler #35 - Circular primes solution is slow

This is my code for project euler #35 (in Python): The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen ...
5
votes
1answer
61 views

Project Euler Problem 54 in Haskell

I wrote an implementation in Haskell for Project Euler Problem 54: The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated ...
2
votes
1answer
75 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
383 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 ...
6
votes
2answers
96 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. ...
9
votes
5answers
526 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 ...
4
votes
1answer
44 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 ...
4
votes
3answers
73 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
56 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
131 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
65 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
2answers
103 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
64 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
75 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
451 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
683 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
51 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
63 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
150 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
55 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
3answers
128 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
116 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 ...