# Questions tagged [programming-challenge]

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

2,649 questions
Filter by
Sorted by
Tagged with
972 views

### Shuttle Puzzle solver

How can I make this piece of code better? The problem to be solved is in the topmost comment. ...
2k views

### Connect graph from 2D array

I just completed Project Euler problem 18 which is a dynamic programming question through a graph of a triangle of numbers. The goal is to find the path from top to bottom of the triangle that has the ...
216 views

### Python vs. Java Runtime on Euler 22 - Name Scores

I want to know why Java is accepted over Python when it comes to runtime. On performing the following Euler problem, Python takes up less lines and runs faster (Python ~0.05s, Java ~0.3s on my machine)...
735 views

### “Recycled numbers” challenge

I wrote this program for the Google Code Jam problem, "Recycled numbers." It took around 2 and half minutes to solve the small input set on my dual core, 1GB RAM system. But for the large input set ...
231 views

### Product of all ints in array besides that an index i

I'm looking for a better implementation of the algorithm. ...
1k views

### ByteLandian challenge from CodeChef

I am trying to go through the problems on CodeChef and came across this problem: In Byteland they have a very strange monetary system. Each Bytelandian gold coin has an integer number written on ...
2k views

### More optimal “Making Change” Problem: Knapsack challenge

The problem description is: You are given n types of coin denominations of values v(1) < v(2) < ... < v(n) (all integers). Assume v(1) = 1, so you can always make change for any ...
2k views

### Canonical Python symmetric cryptography example

Python Cryptography Example Last weekend I wrote some code to help people use PyCrypto in a canonical fashion to symmetrically encrypt and decrypt strings and files. By canonical I mean I've followed ...
198 views

### Binary numbers challenge

I don't know if this is exactly refactoring but I recently completed a programming challenge to learn more about Ruby's iterators. However, I feel that the code is extremely "un-Ruby like". Would ...
2k views

3k views

### Calculating sum of similarities of strings

Puzzle: For two strings A and B, we define the similarity of the strings to be the length of the longest prefix common to both strings. For example, the similarity of strings "abc" and "abd" ...
3k views

### Rot -n algorithm in Java

This is a rot-n (rotate n times) encrypt/decrypt algorithm, where n can be any integer (+/-). It's written to encrypt/decrypt all the alphabets (upper/lower case) and leaving behind all non-alphas. ...
601 views

### Optimizing word counter

I took the Python class at Google code today, and this is what I made for the problem about building a word counter. Please take a look and suggest any improvements that can be done. Please do point ...
1k views

### Optimizing string match algorithm

I was trying to solve this problem. I thought of any possible relation between the number of matches among subsequent substrings, but could not find one. So, the probably naive solution that I ...
2k views

### Sieve of Eratosthenes: making it quicker

I was thinking about doing problem 23 of Project Euler. It includes the difficulty where you have to factorize primes. I had already done that in problems I solved earlier, but it was only necessary ...
1k views

### Pangrams CodeEval challenge

I took a challenge on CodeEval. Although the code seems to work for the examples taken from the site, I feel it is not really pretty and must be more complicated than it should be. Description: ...
6k views

### Finding the next palindrome of a number string

Here is the problem: A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. For a given positive ...
6k views

### Time Limit Exceeds [HS11DIVS] - How to make it faster?

Here is the question. From SPOJ [HS11DIVS]. Now , the problem is that my code works perfectly for small numbers. But when it comes to Large numbers , the time limit exceeds. I am not getting any hint ...
241 views

### Project Euler problem 1 in Factor

I'm a complete beginner of Factor, but I just managed to solved Euler Problem #1 using it, and would love to have the code reviewed. Anything that can be improved? In particular I'm wondering if there ...
2k views

### Google Code Jam (Milkshakes) solution

For practice, I am working through some Google Code Jam problems. The code below is for the Milkshakes problem, which is located here. Problem You own a milkshake shop. There are N different ...
4k views

### Quadrant Queries challenge

Running the same test 10,000 times with cProfile tells me that most of the damage happens in the count() function. This is my attempt at a solution to the Quadrant Queries challenge from ...
153 views

### How can I get this R code to pass the “1 minute” test for this Project Euler question?

I am attempting to learn R programming by going through the questions in Project Euler. The code below is my solution to problem 5 which asks for the smallest number that is evenly divisible by 1 ...
362 views

### Finding the sum of the digits appearing in the leaves via in-order traversal

The following text is an in-order traversal of a binary tree with 1023 nodes. What is the sum of the digits appearing in the leaves? How can I improve this Clojure code? It looks strange to me to ...
403 views

### Searching for repeated characters in a sequence of characters

The following code solves this problem: The 3072 characters below contain a sequence of 5 characters which is repeated. However, there is a twist: one of the sequences has a typo. To be ...
363 views

### BestApproximationDiv2 problem in Haskell

The task is to write a function findFraction maxDen number to find a short but good rational approximation to a decimal representation of a number — problem ...
4k views

### Yahtzee Code Kata in Python

I tried a Yahtzee kata in Python the other day. I'm not particularly experienced in Python (C# is my main language) so I'd be interested in any feedback as to how I could have done things better. In ...
504 views

### Alien Numbers - how Scala-ish is my solution?

I'm trying to solve an old GCJ. It's a very simple puzzle, but I'm trying to sharpen my Scala-fu. Basically, you're getting a list of triple ...
224 views

### Compute e using Euler's expansion

Given the following task: Exercise 1.38. In 1737, the Swiss mathematician Leonhard Euler published a memoir De Fractionibus Continuis, which included a continued fraction expansion for e - ...
623 views

### “File Fix-it” challenge

I'm learning Python and have found this problem from Google Code Jam: How many mkdir commands does it take to construct a given directory tree: Input ...
6k views

### Hypothetical SalesTax challenge

I have a small solution to the following hypothetical problem: Basic sales tax is applicable at a rate of 10% on all goods, except books, food, and medical products that are exempt. Import duty ...
3k views

### Ruby Koans' Greed Task

Having coded in Java and C# for quite some years, I'm currently learning Ruby. I'm working my way through the Ruby Koans tutorial. At some point, you are to implement a method that calculates the game-...
2k views

### Project Euler Problem 2 in Clojure

I am in the process of learning Clojure. I am fairly new to functional programming and would like to know if my code smells or if there are any performance implications with my approach. ...