This challenge is intended to be solved by using, creating, or resolving some processing algorithm.

learn more… | top users | synonyms

2
votes
1answer
189 views

Recursive Mathematical Puzzle from a high school contest

The problem appeared on the 2013 SJCNY High School Programming Contest. It was the last question in the set of problems and no team produced a correct answer during the 2.5 hours they had to work on ...
10
votes
3answers
865 views

Syllabify English words - kind of

You're tasked with writing a program that syllabifies words in a string of text, by separating them with a hyphen. That would be a lot of work, so you want to skip some parts, mainly because you don't ...
4
votes
0answers
209 views

Write a FAST word equation solver [duplicate]

This question is similar to Write a word equation solver by David Frank but different in three important ways: (1) David asked for just the first solution found, and I am asking for all the solutions. ...
-4
votes
4answers
168 views

The Golf (re)Sort [on hold]

The Golf (re)Sort Everyone is sorting arrays these days, and so do we at our day jobs. But we like to go out golfing. When we do, we sure like to take our time. It is important to have a stress ...
-1
votes
0answers
92 views

Traverse resultant 2d array after integer partition [closed]

I have used the solution of integer partitioning using dynamic programming explained in this post and in this article. Following is the resultant matrix when N is equal to 6: 1 1 1 1 1 1 1 0 1 1 1 ...
-2
votes
0answers
59 views

Comparing two software versions [closed]

I´m working on a mod update checker for minecraft, but there is a big problem: The modders and online database that I´m using for update checks has no standard software versions e.g.: Local: ...
5
votes
2answers
286 views

Courier Ception

Courier Ception The program must accept any string as input and output an pixel image that shows the input string in Courier. All the letters that contain a 'hole' (like abdegopqABDPQR etc) that is ...
12
votes
9answers
1k views

There is water on my window

The scenario I drive along a road with my car and it begins to rain. The raindrops are falling on my window randomly and now i ask myself, where is the biggest connected wet area? The task To make ...
-3
votes
2answers
180 views

Find the unique number [closed]

I have read a question similar to this. I found it interesting, And difficlut so I rephrased the question as a code golf. (that question is closed ) In 1 million and 1 numbers, all the numbers having ...
1
vote
0answers
199 views

Generate random 7-carded poker hand for a given hand type

Represent poker cards as numbers from 0 to 51. 0 to 12 - all hearts from 2 to Ace, 13 to 25 all diamonds and so on. Your goal is to write a function for each poker hand type which generates a random ...
3
votes
0answers
200 views

Write the shortest code that bring to a solution of “The old curious knight with a lazy horse” problem [duplicate]

The Story: Once upon a time there was a curious Knight that lived on a never used chessboard in the Realm, an antique store. He spent all his career over there and when it came the moment of the ...
-1
votes
3answers
142 views

Puzzle : Find minimum resource allocation on multiple of 10 or 12 only [closed]

I have two types of notebook . 10 problems could be solved in one page, in the first notebook. 12 problems could be solved in one page, in the second notebook. For given n problems I have to use ...
1
vote
2answers
225 views

Giant Babylonian Matrices

Introduction The Babylonians had a clever method for finding square roots. To find the square root of a number N, you start with a guess, then refine it by repeatedly evaluating a line of computer ...
17
votes
9answers
1k views

Reverse order of words in a string inplace

The Task You are given a mutable string that matches [a-z]+( [a-z]+)*. You must mutate it into the string which contains the same words, but in reverse order, so that "hello there everyone" becomes ...
5
votes
1answer
141 views

Challenge: compress co-occuring columns into cartesian product

This challenge is inspired by a problem I encountered recently out in the real-world, though ultimately I cheated and found a workaround. Challenge The input is a space-separated table of characters ...
5
votes
7answers
671 views

Super speedy totient function

The goal is simple: calculate the totient function for as many numbers as you can in 10 seconds and sum the numbers. You must print your result at the end and you must actually calculate it. No ...
10
votes
7answers
1k views

Filter a large file quickly

The challenge is to filter a large file quickly. Input: Each line has three space separated positive integers. Output: All input lines A B, Tthat satisfy either of the following criterion. ...
19
votes
10answers
4k views

How high can you go? (A coding+algorithms challenge)

Now that everyone has developed their (often amazing) low level coding expertise for How slow is python really? (Or how fast is your language?) and How Slow Is Python Really (Part II)? it is time for ...
14
votes
5answers
1k views

Closest fraction

Task: Your program is given a proper, positive simple fraction in the format <numerator>/<denominator>. For this input, it must find two fractions. A fraction that is less than the ...
-2
votes
2answers
102 views

All possible permuations in lexicographical order [duplicate]

Given a string of English alphabet characters, write the shortest code to print all possible permuations in lexicographical order without using any language based library. def function('bca'): ...
16
votes
7answers
2k views

Predict where the man will go

A man lives in the north-west corner (0, 0) of a town with height h and width w . Everyday he walks from his home to the border (?, w) or (h, ?). In the following example, the man goes to (3, 3) ...
3
votes
0answers
178 views

Hack Sequence : Simplify Hi = 2014*Hi-1 + 69*Hi-2 [closed]

Can someone help me with simplifying this sequence. I write code to loop through entire n, I am getting timeout. Hack sequence of IndiaHacks-2014 if given as below Hi = 2014*Hi-1 + 69*Hi-2 for (i > ...
18
votes
6answers
1k views

Tower of Hanoi Sort

Write a function/subroutine to sort a list of integers, Tower of Hanoi style. You will be given a stack of integers. This is the main stack. You are also given two more helper stacks. These helper ...
23
votes
6answers
929 views

Circles dividing the plane

This problem idea is borrowed from a recent Croatian programming contest but please don't cheat by looking at the solution outlines :) You are given a set of circles in the plane with their centers on ...
24
votes
1answer
813 views

Minesweeper Solver

We already generated Minesweeper fields, but someone really has to sweep those generated mines before PCG blows up! Your task is to write a Minesweeper Solver that is compatible with a slightly ...
7
votes
3answers
233 views

Determine the critical path

In project management there's a method, called the critical path method, that is used for scheduling activities and for determining which activities' timings are crucial (i.e. critical) and for which ...
2
votes
2answers
154 views

Merging text files based on a prefix key

Imagine an ordered file set : file1, file2, ... fileN. Each file is a textual file that is made of lines that have the same format : A concatenation of a fixed-size key (the same among all the file ...
37
votes
1answer
967 views

Minimal keystrokes needed to type a given text

We all know that programmers tend to be lazy. In order to maximize your free time, you decide to write a program that outputs a minimal number of keystrokes for text fed into it. Input: Text that ...
13
votes
2answers
321 views

Crossword Compulsions!

Chris, a cryptic crosswords addict, has a set algorithm for the order in which he solves them. We will use the above image as a guide. Chris always starts off with the first across clue, in this ...
1
vote
0answers
289 views

Find the best path in a “match-3” game

Suppose you want to cheat in a "match-3" game. In this "match-3" game: In each turn you can move a gem along a path. For example, you can move a gem right-right-down, as in A. (The gems are ...
5
votes
6answers
282 views

Generate lists in which every sublist has a unique element

The problem is defined as follows: Create a function that takes an integer and returns a list of integers, with the following properties: Given a positive integer input, n, it produces a list ...
5
votes
10answers
661 views

Write a hash function for Morse Code

Your goal is to write a hash function, that accepts morse code character and returns a hash code that you get to define. You can be sure, passed string will be: One of the Latin characters (A-Z) ...
9
votes
1answer
253 views

Find the best immediate move in a “match-3” game

Your challenge today is to take input like this: fbcfbee ffcabbe debceec bccabbe edcfbcd daeaafc eebcbeb And output the best possible move in a Bejeweled-like game that will match three or more ...
0
votes
0answers
72 views

Last-letter-first-letter sort [duplicate]

Given a list/array of names(String) sort them such that each name is followed by a name which starts with the last character of the previous name. input [ Luis Hector Selena Emmanuel ...
-8
votes
2answers
413 views

Algorithm to find one unique number in one million and 1 numbers [closed]

I have been asked this question in an interview. In 1 million and 1 numbers, all the numbers having the duplicate except only one number. How to find that one number ? I got an idea to use EXOR gate ...
11
votes
19answers
1k views

Sort the distinct elements of a list in descending order by frequency

Write a function which takes a list or array, and returns a list of the distinct elements, sorted in descending order by frequency. Example: Given: ...
5
votes
11answers
518 views

Convert a decimal to a fraction

Write a program that converts a decimal to a mixed, simplified fraction. Sample input: 5.2 Sample output: 5 + (1/5) The code with the shortest length in bytes wins.
4
votes
12answers
1k views

Array Merge without Duplicates

I recently saw this Javascript code on StackOverflow for merging two arrays, and removing duplicates: Array.prototype.unique = function() { var a = this.concat(); for(var i=0; i<a.length; ...
58
votes
15answers
11k views

9 Hole Challenge

The 9 Hole Challenge 9 code golfing challenges of varying difficulty. Penalties for using the same language more than once. The question will be updated with pars, hole champions and trophy ...
4
votes
1answer
269 views

Decompose a range in aligned blocks of size 2^n

Given an arbitrary contiguous range of positive integers, find the decomposition in the minimum number of sub-ranges of size L = 2^n, with the constraint that each range must be aligned, that is the ...
-5
votes
2answers
107 views

Primality Number test [duplicate]

For given number, output true or false(*1* or 0 is also fine) if it's prime or not. Rules If your language have a native method isPrime() you can't use it. Winning condition: Most time-efficient ...
-11
votes
3answers
424 views

Swapping numbers, the shortest code wins [closed]

The goal is to swap 2 numbers. The shortest code wins. Temporary variables are not allowed You can manipulate only one variable at a time One of the variables may be 0
4
votes
3answers
202 views

Update All with O(1) [closed]

Create a data structure to represent an array. It must implement those function in O(1) get(index); // return the data at @index update(index, value); // update the data at @index to ...
11
votes
6answers
596 views

Convert 1 into any positive integer using only the operations *3 and /2

Any positive integer can be obtained by starting with 1 and applying a sequence of operations, each of which is either "multiply by 3" or "divide by 2, discarding any remainder". Examples (writing f ...
5
votes
0answers
464 views

Efficiently packing rectangles on a strip of paper

Algorithm for nesting submited jobs to reduce paper roll usage. Working with a 36" large format printer, with paper roll as source (150feet=45meters). With a delay loop on print server queue: ...
12
votes
14answers
2k views

Write a program which performs brute force letter combination until the word “password” is found

The program should print every letter combination (lowercase or uppercase, it doesn't matter) in alphabetic order. It must start with a and the last printed combination should be password. The output ...
0
votes
3answers
937 views

javascript: smallest code to convert seconds to time [closed]

Given seconds like 11728, write the smallest javascript function that returns a string like 3hrs. 15min. 28sec. signature textTime([int] t,[bool] z,[bool] m) t is the time like 11728 and you can ...
8
votes
4answers
841 views

No branching please

Anyone who is moderately into low level code optimization know about the perils of branching, be it implemented as if-statements, loops or select-statements the possibility of a branch misprediction ...
0
votes
0answers
94 views

reversion of string in c [duplicate]

In python reversing of string is as easy as: string[::-1] But not very same in c. This is the code I am using to reverse integers in C: #include <stdio.h> int main(int argc, char *argv[]) { ...
19
votes
10answers
2k views

Flipping pancakes

In pancake sorting the only allowed operation is to reverse the elements of some prefix of the sequence. Or, think of a stack of pancakes: We insert a spatula somewhere in the stack and flip all the ...