All Questions

Filter by
Sorted by
Tagged with
8
votes
8answers
2k views

Ascending Pea Pattern generator

For those who are not familiarized with the Pea Pattern, it is a simple mathematical pattern. There are multiple variations of this pattern, but we will focus in one: Ascending Pea Pattern It ...
19
votes
9answers
5k views

Generating PBM bitmap files from ASCII text

The PBM (Portable BitMap) format is a very simple ASCII black and white bitmap format. Here's an example for the letter 'J' (copy-pasted from the wikipedia link): P1 # This is an example bitmap of ...
17
votes
31answers
2k views

Finding Not-Quite-Prime Numbers

Your challenge, should you chose to accept it, is to code-golf a function that returns true or false (or some similar meaningful representation of yes and no) if a number meets the following criteria: ...
12
votes
3answers
1k views

Convert from Infix Notation to Prefix Notation

Given an arithmetic expression, which can include parentheses (()), exponents (^), division (...
9
votes
3answers
692 views

Shortest route through a one-way system

My home town, Rhyl, has a one-way traffic system which seems to have been designed to keep people away from their destination for as long as possible. Your task, should you choose to attempt it, is to ...
10
votes
2answers
667 views

Which Numbers Would Crash this Function?

Which values of x and y will cause a crash with some C compilers? int f(int x, int y) { return (y==0) ? 0 : (x/y); }
2
votes
8answers
6k views

compute number of 1 bits in a binary representation of a number

The goal is to write a program that returns number of 1 bits in a given number. Examples 5 -> 2 1254 -> 6 56465 -> 8 Winner The winning ...
6
votes
5answers
1k views

Show Ulam's spiral

Similar to this but in this one you need to write spiral starting from the center where: space means composite number .(dot) means prime number. Size of the ...
47
votes
15answers
6k views

Generate the Stack Overflow logo [closed]

The challenge is to generate an image similar to the StackOverflow logo: The output must contain: Image size 64*64 or greater A gray |__| shaped base A curved segmented stack coming up from the base....
4
votes
21answers
3k views

determine longest group of consecutive numbers

INPUT: 10 random numbers each number is greater than 0 and less than 100 list of numbers is presorted, lowest to highest the list will not contain any duplicate numbers CHALLENGE: Write a function ...
11
votes
13answers
2k views

Hello World Rainbow

Dealing with colors in non-markup languages often complicates things. I would like to see some variations of how color is used in different languages. The object of this competition is to output '...
5
votes
22answers
10k views

Convert number to comma separated number [closed]

Given a number, say, -2982342342363.23425785 convert it to -2,982,342,342,363.23425785. Extra points for not using look-behind ...
116
votes
42answers
16k views

Write a program that always outputs “2012” - even if it's modified!

This idea is not mine, though I don't know where it originated. I once met it in a programming contest very long ago (1998, if I remember correctly). The task is to write a program in your favorite ...
29
votes
2answers
4k views

What code compiles in the most number of languages? [closed]

Excluding trivial programs, what code compiles in the most number of languages? (By "trivial" I mean to exclude answers such as the empty program or text that will be echoed directly.) The following ...
25
votes
9answers
9k views

Recreate a 'Snake' game in a console/terminal

Games are fun this codegolf here was so fun I had to make a version for other classic games similar in complexity. Shortest Way of creating a basic Space Invaders Game in Python This time, however, ...
4
votes
3answers
7k views

List of paths to nested dictionary

Given a list of nested menu items, ...
2
votes
17answers
675 views

The group of sequential positive numbers with the highest sum?

Given the following list of numbers, find the group of sequential positive numbers with the highest sum. Example input: 12 2 35 -1 20 9 76 5 4 -3 4 -5 19 80 32 -1 ...
15
votes
10answers
2k views

Convert from binary to negabinary

Given a binary integer inclusively between 0 and 1111111111111111 (i.e. a 16-bit unsigned integer) as input, output the same ...
14
votes
47answers
5k views

Print the amount of ones in a binary number without using bitwise operators

Description Given a number, print the amount of 1s it has in binary representation. Input A number >= 0 in base 10 that ...
21
votes
4answers
2k views

Optimal short-hand roman numeral generator

Goal: Write a function that takes a number as input and returns a short-hand roman numeral for that number as output. Roman Numeral Symbols: ...
4
votes
14answers
957 views

Write the shortest code to match a tail-repeating string where one character falls off the head in each repetition

In this code-golf, you will attempt to match a string that is tail-repeating with one character falling off the head on each iteration. The code needs to be able to accept a string, and return to the ...
6
votes
3answers
1k views

Write a base X to base Y function [duplicate]

Create a function 'baseXtoY' which: converts an integer or string n, which is a base x number (hexadecimal, binary, etc) into a ...
7
votes
3answers
805 views

Acrostic polyglot programming [closed]

The challenge is to write an acrostic piece of code. When read normally (horizontally), the code should take an input string and remove all but the first character on each line. For example, the ...
7
votes
9answers
4k views

ASCII Tux (Linux Penguin) [closed]

I once hacked upstart on my Ubuntu box so that a colored, themeable ASCII Tux displayed on the screen with the boot messages scrolling beneath him. I'm curious to ...
5
votes
1answer
3k views

Shortest Way of creating a basic Space Invaders Game in Python

Your challenge is to create a basic version of Space Invaders in Python Rules Program must be not written in Py3K All levels must be randomly generated There must be a HUD showing the players score ...
74
votes
52answers
23k views

Shortest code that raises a SIGSEGV

Write the shortest code that raises a Segmentation Fault (SIGSEGV) in any programming language.
7
votes
7answers
2k views

Shortest code that return SIGSEGV among the given languages [duplicate]

I come across a question in a coding competion "write a code that returns SIGSEGV(Segmentation fault ) " . Points were given on the basis of length of code. The prgramming languages available ...
4
votes
5answers
471 views

Celsius - Fahrenheit anagram

Task Make a complete program or a function which calculates sum of all temperatures which, when written in Celsius and Fahrenheit scale, are anagram of each other. Description For example, ...
11
votes
3answers
481 views

The Sleigh Packing problem

Santa's elves need help in determining if their current batch of presents will fit into santa's sleigh. Write the shortest program possible in the language of your choice to help them out. ...
0
votes
0answers
223 views

Python - Reverse Polish Notation [duplicate]

Possible Duplicate: Reverse Polish notation Create a function named rpn in python to evaluate a string written in Reverse Polish notation Numbers must be ...
14
votes
5answers
1k views

Simulate any 1D cellular automaton

The Challenge You are to write a complete program that takes seven numbers from STDIN, and prints the two dimensional history of the cellular automaton (CA) to STDOUT. This is code golf. Input ...
18
votes
1answer
960 views

Lose at tic-tac-toe

Write a program that a will play a game of Misère tic-tac-toe. That is, the goal is to force your opponent to take three in a row. Accept on standard input either an 'X' or an 'O'(the letter, not ...
14
votes
19answers
6k views

Say “Hello” to the world in ASCII art

Challenge: Produce the following output using as few chars as possible: ...
18
votes
1answer
1k views

I used to solve code golf puzzles like you, but then I took an arrow in the knee

Getting hit in the knee with arrows seems to be the injury of choice right now. As such, I propose the following golf challenge. You have an adventurer that looks like this: ...
1
vote
2answers
641 views

A small puzzle. Why does this code work the way it does? [closed]

This was given to me by a friend of mine, it prints out 0 through 9. We have been quite puzzled over this. Does anyone know why this works? ...
22
votes
4answers
3k views

ASCII animated snow scene

Write the shortest program to turn any piece of ASCII art into an animated snow scene that begins to form from the falling snow (non-golfed JavaScript example last updated 2011-12-19). Input ...
-7
votes
6answers
869 views

Code Golf: simple way to get min & max

You will take a set of input numbers, and output the minimum and maximum of the set. You can either write two programs, with 1 program doing each function, or one combined program. Here's an example ...
9
votes
2answers
418 views

Justify a text by adding spaces

Given this text Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ...
5
votes
4answers
544 views

Polynomial extrapolation

Task Given a list of integers a1, a2, …, ak (k ≥ 2) and a positive integer m, write a function or a complete program that calculates the next m numbers of the list. Assume that ai = P(i) ...
22
votes
11answers
2k views

Good rational approximations of pi

Write a program that prints out all the good rational approximations of pi with denominator < 1000000, in increasing denominator order. a/b is a "good rational ...
5
votes
1answer
548 views

Build a working chessboard

The challenge Create a program that mimics a chessboard. The datails The chessboard must be surrounded by the labels of each row and column, being the columns labeled from 'a' to 'h' and the rows ...
17
votes
24answers
9k views

12 Days of Christmas Lyrics

I thought this would be a fun challenge for everyone and I'm curious to see the solutions people come up with. Print the "12 Days Of Christmas" lyrics ...
17
votes
3answers
942 views

Write a third order quine

This challenge is an extension of 'Golf a mutual quine'. Using three languages of your choice, create a third order Ouroboros program. That is, in language A, write a program pA which outputs ...
8
votes
2answers
215 views

BWInf 2011, question 5: Twin towns

This is a challenge that was originally a tas for the German Bundeswettbewerb Informatik (federal competition of computer science [?]), a competition for highschool students. As opposed to the ...
26
votes
74answers
12k views

Print a Christmas Tree

The Challenge Print a nice Christmas tree with it's own star at the top using the shortest code possible. The tree star is an asterisk (*) and the tree body is ...
32
votes
36answers
4k views

Is it Christmas?

Challenge Given that Christmas is: December Month 12 Day 25 Every year, determine today's date, and whether or not today is Christmas. If it is Christmas, you must print ...
21
votes
11answers
2k views

Interpret your lang, but not yourself?

There are many challenges that say "interpret X", where X is a simple language. In my opinion, that is way too boring. To give all the procrastinating people on the internet something interesting to ...
-7
votes
3answers
1k views

write a code the find n-th number of Gray Code list [closed]

Write a function that, given N >= 0, finds the Nth number in a standard Gray code. Example input: 1 2 3 4 Example output: ...
2
votes
13answers
1k views

position of the only 1 in a number in binary format [closed]

Every number of the form 2i (where i is a non-negative integer) has a single 1 in its binary representation. Given such a number, output the 1-based position of the ...
7
votes
2answers
509 views

Write a better BCS computer ranking

Input A CSV file, read from standard input, containing the 2011 college football scores with the 4 columns: Winner, Winner Score, Loser, Loser Score. For example, ...

15 30 50 per page