All Questions
2
votes
1answer
43 views
Shortest program to split a string at non-digits without RegExps
Objective: Make the shortest function that splits a string at non-digits and returns an array consisting of only digits in each string, without the use of any regular expressions. Leading zeroes are ...
9
votes
11answers
602 views
Most creative way to display 42
Douglas Adams was born on March 11, 1952, and died when he was just 49. In honor of this wonderful writer, I challenge you to display 42 in the most creative way possible. Now this can be printed in ...
3
votes
4answers
144 views
Program that creates larger versions of itself (quine-variant)
You are to write a program that will output source code that is
Larger than the original program (character wise)
Itself an acceptable answer
Any obviously useless code doesn't count towards the ...
-2
votes
8answers
148 views
Make a reliable calculator capable of calculation 1+1
So, i forgot what 1+1 was.
I checked on the calculator and it said 3, and I got it wrong.
Can you please make a reliable calculator than can calculate only 1+1?
Remember, this is code-trolling.
...
2
votes
4answers
84 views
Calculate all the squares up to x using only addition and subtraction [duplicate]
The goal is to calculate all the squares up to x with addition and subtraction.
Rules:
The code must be a function which takes the total number of squares to generate, and returns an array ...
2
votes
3answers
107 views
Create a flaky test
Create a piece of code and a genuinely-looking test for it. However, the test must be flaky: when run multiple times, it must sometimes fail, sometimes succeed.
Be creative and try to hide the ...
6
votes
9answers
360 views
Print n weird numbers
A weird number is a number that the sum of proper divisors is greater than the number itself and no subset of proper divisors sum to that number.
Examples:
70 is a weird number because its proper ...
-3
votes
8answers
114 views
Code to display a string without calling any methods or functions
Write a code to display "I Love You".
Without using any built-in tools or functions like echo, System.out.println, printf, ...
Note: You are not allowed to call any function throughout the program ...
6
votes
13answers
704 views
Calculate the cube root of a number
The goal of this code golf is to create a program or function that calculates and outputs the cube root of a number.
The rules:
No external resources
No use of built-in cube root functions.
No use ...
4
votes
9answers
208 views
Shortest code to post a string to WebServer
In bash, the below posts the string to a web server:
curl -d "String to post" "http://www.example.com/target"
I think all other languages that I have knowledge in need a lot more than this. I'm not ...
0
votes
7answers
181 views
Strange ways to keep an endless high CPU usage
There are some ways which cause an endless high CPU usage such as catching recursion exception. e.g. the following script in Python causes that problem:
def main():
try:
main()
...
1
vote
1answer
68 views
Align a horizontally-aligned, right-angled ASCII shape along a diagonal
Your program will receive an ascii shape consisting of only underscores _, pipes |, spaces and newlines \n, which, together, represent a horizontally-aligned, right-angled shape. Together with this ...
3
votes
4answers
126 views
Kind of meta: get the longest of the shortest answers
Your task - if you accept it - is to write a program which helps understanding my proposal on meta by calculating the winner of a code-golf-reversed competition. Of course, answers to this question ...
2
votes
1answer
116 views
Hidden easter egg [on hold]
Here's a fun idea:
Write a simple game (tic-tac-toe, guess the number, etc) that has an easter egg in it, that can be triggered by a specific, special input from the user and does something cool, but ...
1
vote
0answers
80 views
Visual Studio settings for C# code golfing
Which setting in Visual Studio do you recommend to get the best experience for code-golf? Advanced: how to best apply these settings only temporarily (because I should also do some work with Visual ...
26
votes
22answers
5k views
A program that ends but never ends
Write a program that starts itself again when finishes.
There should be no more than one instance of the program running at same time. Not even for a slightest moment of time.
You can ignore any ...
0
votes
1answer
125 views
Songify a string [on hold]
Task:
Your job is to take an input string that is at least 20 words, and turn it into a song by rearranging the words in a lyrical manner. When reading the output of you program, it should sound like ...
0
votes
0answers
79 views
Shortest BF program to output uppercase 'A' [duplicate]
[moved from Stackoverflow]
The following brainfuck program outputs the letter 'A' and it is the shortest such program known to me. That is why I am asking the BF experts here: Do you think there is a ...
6
votes
18answers
466 views
Print a string with vertical words
Your task is to take an input string of ascii characters and output the string as a series of vertical words separated by spaces. An example is shown below:
Given the string:
Hello, World! My name ...
2
votes
6answers
1k views
Draw a trololologram
Your challenge here is to draw a trololologram.
You can choose any language.
The answer with more upvotes and the one that exploits more holes wins.
Rules for valid answers:
You can't use any ...
28
votes
26answers
4k views
Generate an understandable sentence
Problem:
Generate a sentence that can be read and understood. It must contain a subject, verb, and object, and tenses and plurals must match. The program must also be able to generate several ...
3
votes
1answer
191 views
Array Shuffling
Write a program that takes a sorted integer array, shuffles all the elements in such a way that for every i there must exist a j such that, one of the following is satisfied:
a[i] < a[j] < ...
7
votes
17answers
847 views
Fun with Matching Braces
The contest is to make a program or function that takes an arbitrary string
resembling source code and checks to see if the "braces" follow the basic rules for
brace matching. That is, the number of ...
12
votes
12answers
2k views
Brainf*ckish directions
Your task – should you choose to accept it – is to build a program that parses and evaluates a string (from left to right and of arbitrary length) of tokens that give directions – either left or ...
10
votes
7answers
384 views
Solve a reverse arrow maze
This is an "arrow maze":
v <
> v
> ^
> v
^ < *
The * marks the spot where you will finish. Your goal is to find where the maze starts (hence, ...
2
votes
6answers
312 views
Print Leonardo DiCaprio without using any of the letters in his name [duplicate]
The Oscars are coming up soon and we all know who's going to win Best Actor in a Leading Role this year right? The great Leonardo DiCaprio of course! Despite his superb performances in all of his ...
6
votes
12answers
263 views
Count characters, turn them into a cipher
Problem:
You must make a program that does the following:
takes a large string of lowercase text, and counts all the occurrences of each letter.
then you put the letters in order from greatest to ...
5
votes
8answers
332 views
Loophole for other challenge [on hold]
You are to post an answer you posted that exploited a loophole in the challengers question. Bonus points if it caused them to rewrite the question.
For example, one challenge was to write a program ...
7
votes
3answers
179 views
Find the overall period from a list of frequencies
Inspired by http://xkcd.com/1331/
In this xkcd comic, there are several gifs that all blink with different frequency. I want to know what the period would be if was all a single GIF. Given a list of ...
3
votes
4answers
241 views
Shortest Program to Solve a Quartic Equation
Write the shortest program to solve a Quartic equation.
A quartic equation is a polynomial equation of the form:
ax⁴ +bx³+cx²+dx+e=0
A solution for x is a number such that the above evaluates to 0.
...
-1
votes
0answers
44 views
Tick - Cross puzzle [duplicate]
You have to implement a small game to complete this puzzle. The below is a visual
I think all of us know the game, Anyway the game rules are
Each will have to choose a sign either tick or ...
4
votes
10answers
1k views
Print E=mc² or E=mc^2, by using the right side of this equation
Your task – if you choose to accept it – is to have your program print, literally, either one of the following:
E=mc² (if your language supports Unicode (so no HTML trickery, for instance))
E=mc^2 ...
-3
votes
0answers
44 views
I need help on how to correct the error : java.lang.NoSuchMethodError: main Exception in thread “main” [on hold]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class LinkNode {
private int data;
private LinkNode next; //* reference next in LinkNode
...
-7
votes
13answers
222 views
Output with 1 on stdout using a 0-byte source code
The output of the program must have 1 as the first line. The rest of the output can be anything.
Bonus Points: (the main target.. everything else is participation prize)
-500 if code length = 0
...
19
votes
29answers
3k views
Letters in phone numbers
Problem:
You are making a new phone where people can type in specialized phone numbers, for example, 1-800-program, and they would be converted automatically to a usable phone number, like ...
17
votes
42answers
2k views
Sort numbers by binary 1's count
Goal
Write a function or program sort an array of integers by the number of 1's present in their binary representation. No secondary sort condition is necessary.
Example sorted list
(using 16-bit ...
16
votes
6answers
731 views
Detect what programming language a snippet is
Your challenge is to take some source code as input, and output which programming language it is written in.
For example, you could have the input
class A{public static void ...
4
votes
2answers
258 views
Analysing the most common words in a text, and replacing them with a single byte
This is a very crude text encoding algorithm I came up with the other day. It won't work if the text has more than 256 different characters in it – but it does support Unicode, at least in my Python ...
18
votes
21answers
4k views
Happy Birthday to Me!
Happy birthday to Me!
Write a program that prints Happy birthday to me! on its birthday.
The program's birthday is the creation, last modification or compilation time of the program (you choose), ...
7
votes
3answers
473 views
Reflective evolutionary algorithm
You have to write a program, implementing a function digitsum(int i). The program has to modify its own code (for languages, where this is not possible with f.e. reflection, please be creative) to get ...
-3
votes
1answer
218 views
Printing on screen [closed]
I'm a newbie can you help me print text on screen?
P.S.1 I like drawing.
P.S.2 I like that Mona Lisa where she's painted with letters...
P.S.3 Generally, I like modern ways of art... show me ...
15
votes
25answers
3k views
The shifting dot
Your program has to print out a number of spaces, followed by a dot and a newline.
The number of spaces is the x position of your dot defined with 0 < x < 30
Every new line is a turn. Your ...
18
votes
24answers
2k views
Minimal code CPU stress-tester…
Introduction
There are lots of utilities out there capable of creating a high CPU load to stress-test your processor(s). On Microsoft Windows, you can even use the on-board calculator.exe, enter a ...
6
votes
5answers
259 views
Run the Monty Hall Problem
There’s already been a question about simulating the Monty Hall Problem. This one is different. The user will play the Monty Hall Problem. Your program will play the role of the host. Montybot, if you ...
19
votes
6answers
520 views
+100
Animated drawing of a Bézier curve
Your job is to draw a Bézier curve given it's control points. The only criteria is that you actually have to show how to draw the curve from the initial control point to the last one.
Criterias
The ...
0
votes
1answer
188 views
The next Flag of the USA with 51 stars. Code the star pattern [closed]
This is task is simple. Imagine the 51st state just joined the USA and you need to write a program or script that outputs the next flag of the United States. Of course this is not as simple because ...
96
votes
97answers
24k views
Weirdest way to produce a stack overflow
As a programmer you certainly know the error of a stack overflow due to an obvious recursion.
But there are certainly many weird and unusual ways to get your favourite language to spit that error out. ...
46
votes
30answers
7k views
Factorial in haiku!
Problem:
Create a program that calculates the factorial of a number (using no built-in factorial functions). Easy? The catch is that you must write your entire program (including testing it) in haiku ...
1
vote
2answers
201 views
Violate all stylistic requirements of PEP8
In Python, the style guide PEP 8 defines the coding style for all Python code. Your task is, in as few characters as possible, to write a program that violates all those requirements and can still be ...
0
votes
0answers
99 views
Convert Code to Code-Golf version - Objective-c
The script should take an input string of Objective-C Code and convert it to the shortest possible "golf" version.
All variables should be found and replaced with 1 character versions.
i.e. var ...