All Questions

Filter by
Sorted by
Tagged with
3 votes
0 answers
321 views

Variable board size 3D Connect Four [closed]

Write a 3D version (the game logic being 3D, not the visual representation) of the popular Connect Four game ( http://en.wikipedia.org/wiki/Connect_Four ) where the user can play against the computer. ...
  • 131
11 votes
1 answer
845 views

Write an ASP/Prolog/SAT flow solver

Flow Free is an addictive android game where you have to connect pairs of elements together via non-overlapping snakes and fill the entire grid. For a description, see here: https://play.google.com/...
  • 935
-2 votes
1 answer
382 views

IPv4 "in subnet" function [closed]

Implement the following JavaScript method as short as possible: function same_subnet(ip_a,ip_b,sn_mask) { } It should get 2 IP addresses and a subnet mask. It ...
14 votes
10 answers
1k views

Create a Twitter Parser

Introduction You use Twitter (let's pretend, if not), where you are limited to 140 characters per individual tweet you care to share with the world. If you wanted to tweet to your followers Abraham ...
  • 3,539
6 votes
3 answers
2k views

The making of "Spot It!": Finding almost unique sets

Puzzle: Find a deck of c cards, each containing p pictures, such that no two pictures match on a given card, and exactly 1 picture on each card matches exactly 1 picture on each of the other cards, ...
6 votes
18 answers
7k views

Convert JSON string to Key / Value Arrays

Convert JSON (key/value pairs) to two native arrays, one array of keys and another of values, in your language. ...
  • 229
0 votes
1 answer
444 views

Matlab/Octave Eratosieve using minimal big-O iterations [closed]

I'm trying to come up with ways to write Sieve of Eratosthenes in Octave that vectorize as much as possible (ie minimizing the number of times iterating over the for-loop/while-loop/recursive call) I ...
  • 935
2 votes
11 answers
1k views

recursive power algorithm

Have a look at my (javascript) version of a O(log(n)) xn algorithm: function pow(x,n) { return n==0?1:n==1?x:n==2?x*x:pow(pow(x,(n-n%2)/2),2)*(n%2==0?1:x); } ...
27 votes
53 answers
4k views

The world ends in ed

Taken straight from the ACM Winter Programming Contest 2013. You are a person who likes to take things literally. Therefore, for you, the end of The World is ed; the last letters of "The" and "World" ...
  • 4,244
10 votes
2 answers
1k views

Calculating Resistance (Nerd Sniping)

Good Afternoon Golfers, Our challenge for today is inspired by XKCD comics 356 and 370. We're going to write a program to calculate the resistance of a group of resistors. A forewarning that this is ...
  • 3,189
6 votes
4 answers
555 views

substring conversion (in Haskell). Can you beat this?

Ok, I found myself with a nice little problem: you will get from stdin a string. In this string you will find some hex colors (like ...
  • 61
7 votes
11 answers
1k views

Generate math problems

Generate math problems (addition, subtraction, or multiplication) using numbers 0-10. Provide feedback on whether the user was right or wrong and show a score. Specifics: Must generate addition, ...
  • 70.7k
8 votes
1 answer
3k views

Build an adding machine using NAND logic gates

This is "programming" at its most fundamental. Build a diagram of (two-wire) NAND logic gates that will take the input wires A1, ...
  • 34k
20 votes
6 answers
2k views

Chess - Find all legal moves (except castling and en passant)

Write the shortest code that calculates all possible (legal) moves of current player from a given FEN string. What is FEN string? (Wikipedia) Shortest code wins, language doesn't matter. Output ...
  • 201
15 votes
4 answers
1k views

Branch differently in x86 / x86-64 using only printable visible ASCII characters in the machine code

The task is simple: write a program that branches differently in x86 (32-bit) and x86-64 (64-bit) using only printable visible ASCII characters 0x21...0x7e (space and del are not allowed) in the ...
  • 253
2 votes
2 answers
631 views

solve puzzle with a tweet? javascript (fun challenge)

the question is "complete this subtraction by replacing the asterisks with digits so the numbers 1-9 only appear once each" 9** -*4* ____ **1 my code tries ...
12 votes
1 answer
789 views

Implement an IEEE 754 64-bit binary floating point number through integer manipulation

(I've tagged the question "C" for the time being, but if you're aware of another language that supports unions, you can also use that.) Your task is to build the four standard mathematical operators <...
  • 34k
7 votes
9 answers
480 views

Group adjacent values

The task is to group adjacent values from collection and output it as a new aggregated collection. Consider we have following input: Sequence Number Value ======== ===== 1 9 2 ...
11 votes
1 answer
2k views

Generate a number by using a given list of numbers and arithmetic operators

You are given a list of numbers L = [17, 5, 9, 17, 59, 14], a bag of operators O = {+:7, -:3, *:5, /:1} and a number ...
14 votes
14 answers
1k views

Output code-sized Lorem Ipsum [closed]

Output the same length of Lorem ipsum your code is! Rules: Code can't be identical to output No compression libraries Shortest program in two weeks wins No network usage, file reading and other ...
  • 20.6k
-2 votes
3 answers
10k views

Write a program to print squares of integers up to 25 in java without using variables? [closed]

I asked this question on programmers 10 days back but wasn't able to get the answer that I wanted. Write program in java to print the squares of first 25 integers(1-25) without using any variables. ...
39 votes
3 answers
24k views

Solve Rubik's cube

Write the shortest program that solves Rubik's cube (3*3*3) within a reasonable amount of time and moves (say, max. 5 seconds on your machine and less than 1000 moves). The input is in the format: <...
24 votes
3 answers
2k views

Build a program with one simple GOTO [closed]

Your task is to build the largest program you can that uses exactly one GOTO, without which the entire program (or at least a huge chunk of it) must be completely restructured. The score is counted as ...
  • 34k
15 votes
13 answers
6k views

Build an analog clock [closed]

Write a program which displays the current system time as an analog clock, using ASCII graphics. The clock must show at least the hour and minute pointers, and must have enough resolution of at least ...
  • 8,090
1 vote
1 answer
2k views

Build a 12-hour digital clock [closed]

In my essay "Use the 24-hour clock", I claim that trying to represent the 12-hour clock directly in data is a terrible exercise in patchy, inelegant programming: "No problem, we'll just use ...
  • 34k
0 votes
2 answers
370 views

Shortest conditional to run a specific statement: C code golf

Currently I have the code (expanded for your benefit): <number> != <number> ? printf("|\\"); : <number>; The idea here, is to do this condition ...
  • 103
11 votes
12 answers
2k views

Type "Hello, World!"

Write a program which generates keyboard events which type Hello, World!. It doesn't have to be platform-independent. It can't leave any keys pressed. For ...
11 votes
2 answers
945 views

Email validation

Write a function or program to validate an e-mail address against RFC 5321 (some grammar rules found in 5322) with the relaxation that you can ignore comments and folding whitespace (...
  • 42.8k
23 votes
4 answers
2k views

Find largest prime which is still a prime after digit deletion

Over at https://math.stackexchange.com/questions/33094/deleting-any-digit-yields-a-prime-is-there-a-name-for-this the following question is asked. How many primes are there that remain prime after you ...
user avatar
5 votes
4 answers
1k views

Print ASCII histogram

The challenge is to give as short code as possible to print an ASCII histogram of a set of data. Input. The number of bins followed by a number of integers representing the data. The data are space ...
  • 155
4 votes
3 answers
2k views

Solve the CodeSprint4 Leibniz code golf challenge in Python in 66 characters

Check out this challenge: https://www.hackerrank.com/codesprint4/challenges/leibniz (The competition has already ended, so I'm just curious about the Python solution, which the organizers refused to ...
31 votes
11 answers
31k views

Pong in the shortest code

The challenge is simple. Give the shortest code possible to reproduce the classic 2-player game of pong http://en.wikipedia.org/wiki/Pong . The level of graphics and functionality should be as close ...
user avatar
8 votes
4 answers
804 views

Pretty Printing Parentheses [closed]

The worst part about long lines or code or math equations are the parentheses. Nobody wants to read through 2x(3y+4*abs(x^[2*e^x])-5{3(x+y)-5})! So, the goal of ...
  • 4,244
17 votes
3 answers
59k views

Polygon prefixes

Polygons are named after the number of sides that they have. A pentagon has 5 sides, an octagon has 8 sides. But how are they named? What's the name for a 248-sided polygon? All polygons are suffixed ...
  • 4,244
7 votes
3 answers
1k views

Bridges (Hashi) [duplicate]

Unsolved puzzle: Solved Puzzle: Rules Each circle with number must have as many lines from it as the number in the circle. It is not allowed to have more than two lines between two circles. The ...
19 votes
1 answer
2k views

Shortest 2-Player Game of Halma

In Chess, it's possible for the game to end after 4 moves (2 each) with a Fool's Mate. Your goal is to find the Fool's Mate of Halma: the 2-player game of Halma that minimises the number of turns ...
20 votes
3 answers
22k views

Fastest code to find the next prime

The problem is as follows. Input: An integer n Output: The smallest prime bigger than n. The challenge is to give the ...
user avatar
10 votes
5 answers
804 views

Swapping numbers [closed]

This is a common puzzle many of you have solved manually. Now this is the time to write an algorithm to solve the same. There are equal number match sticks lined up in two different side facing each ...
14 votes
9 answers
3k views

Build a polyglot for Hello World

Produce a text file that prints "Hello World!" in as many programming languages as possible when compiled/interpreted, while also being as short as possible. The score for your submission is ...
  • 34k
3 votes
3 answers
622 views

Build an RSA encoder

Your task is to build a function in any language that takes a message m, an encryption e, and a modulus ...
  • 34k
2 votes
10 answers
2k views

Implement String.prototype.toLowerCase()

Implement String.prototype.toLowerCase() Description The toLowerCase method returns the value of the string converted to ...
  • 775
14 votes
4 answers
5k views

Drawing 3d nets - Platonic solids

This is a basic version of the rather more difficult Drawing 3d nets - Archimedean solids . I have a weakness for 3d nets which when cut out and folded allow you to make 3d shapes out of paper or ...
user avatar
11 votes
2 answers
3k views

Drawing 3d nets - Archimedean solids

I have a weakness for 3d nets which when cut out and folded allow you to make 3d shapes out of paper or card. The task is simple, written the shortest program you can that draws nets for the 13 ...
user avatar
7 votes
4 answers
3k views

Breakout in half an hour [closed]

When I was a young teen I had a very boastful friend who claimed he could code up breakout in half an hour. Half an hour later he had done a great job but it didn't quite work. This challenge is to ...
user avatar
4 votes
6 answers
1k views

Cropping an image succintly

I am constantly frustrated by how complicated it is to write graphical programs that would have been only a few lines of code 20+ years ago. Since the invention of the mouse this has become even ...
user avatar
4 votes
1 answer
210 views

(simple) variable and scope simulator

Based on this closed question on stack overflow, what is the shortest way to stimulate scope for variables in an input. For simplicity, print is replaced with <...
  • 165
12 votes
6 answers
2k views

Working Minesweeper

Similar to generating minesweeper grids, although the challenge is to make a working minesweeper grid. This will be longer code than normal (I think). more information on minesweeper. Minesweeper ...
  • 165
13 votes
17 answers
2k views

Finding the most 'unique' word

Using you language of choice, write the shortest function/script/program you can that will identify the word with the highest number of unique letters in a text. Unique letters should include any ...
  • 3,539
6 votes
2 answers
750 views

Reducing Leibniz perl code in characters

This Perl code is supposed to calculate the Leibniz formula. The original problem is here. The input format is: T <T test cases, each on their own line> ...
  • 163
31 votes
20 answers
2k views

Convert number to a base where its representation has most "4"s

Inspired by this. There is a number, given as either integer, string or array of digits (your choice). Find the base in which the representation of the number will have most "4"s and return ...
  • 411

15 30 50 per page
1
247 248
249
250 251
267