Questions tagged [programming-challenge]
Use this tag when the code is a solution to a programming challenge. Always include a sufficient description of the problem to be solved - while a link to the challenge is welcome, the review request needs to be complete when the challenge site is unavailable.
3,374 questions
61votes
10answers
4kviews
Using separate functions for Project Euler 1
I started programming with Java and C++, so I'm used to having a 'main' function that calls other functions that do the actual work. At university I was always told that doing actual computation in ...
59votes
9answers
14kviews
Project Euler problem 1 in Python - Multiples of 3 and 5
I'd like suggestions for optimizing this brute force solution to problem 1. The algorithm currently checks every integer between 3 and 1000. I'd like to cut as many unnecessary calls to ...
41votes
1answer
2kviews
Finding minimum scalar product using ST Monad
Inspired by a Stack Overflow question, I decided to practice my Haskell by taking a crack at the Google Code Jam's Minimum Scalar Product problem: Given two vectors \$\mathbf{v_1}=(x_1,x_2,\ldots,...
40votes
9answers
9kviews
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 ...
35votes
2answers
1kviews
LOL'ing-Up Project Euler One
It's been a while since I last wrote some lolcode, so I felt like tackling 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 ...
33votes
7answers
6kviews
Project Euler #7 10001st prime
I decided to start working on the Euler project exercises. I'm doing fine for now but the seventh problem is running quite slow and I can't think of anything to make it work faster. It takes around ...
32votes
1answer
8kviews
100 gunmen in a circle kill next person
I am very happy because I solved this problem with very little code: ...
32votes
8answers
5kviews
Project Euler Problem 45
As a self-teaching Python beginner for almost 4 months, I have mostly been doing online challenges including Project Euler problems. Problem 45 asks: Triangle, pentagonal, and hexagonal numbers are ...
32votes
7answers
8kviews
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 alive. ...
32votes
6answers
3kviews
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 on ...
30votes
6answers
72kviews
Checking for balanced brackets in Python
I'm solving HackerRank "Stacks: Balanced Brackets" in Python. A bracket is considered to be any one of the following characters: (, ...
30votes
3answers
27kviews
Perm-Missing-Elem: 100% functional score, but only 60% performance
I cannot figure out why I didn't get 100% success from the Codility's Perm-Missing-Element test even I solve with \$O(n)\$. I will appreciate any advice/answers. You can see the problem, my code, and ...
30votes
6answers
4kviews
DailyProgrammer 284: Wandering Fingers
Description Software like Swype and SwiftKey lets smartphone users enter text by dragging their finger over the on-screen keyboard, rather than tapping on each letter. You'll be given ...
29votes
4answers
6kviews
Project Euler 001 in C++
I come from a C background and have now just begun C++. This also means that I am not focussing on the algorithm, but more on C++ idioms. Description: If we list all the natural numbers below 10 ...
28votes
7answers
8kviews
Trapping Rain Water
This task is taken from Leetcode: Given n non-negative integers representing an elevation map where the width of each bar is 1, ...