5
votes
2answers
190 views

Writing firewall rules

Congratulations, you're now a network administrator! As your first task you will need to configure a firewall to stop any traffic to some blacklisted addresses. Unfortunately, the only firewall at ...
4
votes
0answers
144 views

The centers of a triangle

Circles and squares have a single, definite center point. However, the notion of the center of a triangle has long been discussed. Four different centers were known to the Ancient Greeks - the ...
7
votes
0answers
151 views

quine-ish tic-tac-toe

Write a program in your chosen language which plays a perfect game of tic-tac-toe on a 3 * 3 board against a human player. However, every move has to be a different program, generated from the ...
0
votes
0answers
108 views

How can I print words without using numeric/string literals? [closed]

I've been part of a set of golfs recently, where on of the constraints was, the program is not allowed to use string or numeric literals. E.g. "Hello" or 14 or [123] or var a = 0. To give you an ...
8
votes
7answers
335 views

Number of holes in a polygon

The Problem: Count the number of holes in a connected polygon. Connectivity of the polygon is guaranteed by the condition that every triangle in the input triangulation shares at least 1 side with ...
12
votes
10answers
463 views

Convert to and from the factorial number system

The Factorial Number System, also called factoradic, is a mixed radix numeral system. The factorials determine the place value of a number. In this system, the right most digit can be either 0 or 1, ...
-5
votes
2answers
144 views

Beer Friday Challenge #1: Dynamic conditional puzzle [closed]

Solve, ((15, 'less_than', 30) == true) Use any language you are comfortable with. The only thing you must not do is mentally substitute the words for the symbols. Here's a link to the gist if you ...
2
votes
8answers
215 views

Evaluate the primorial of a number

The primorial of a number is the product of all the primes till that number, itself included. Input a number from STDIN and evaluate its primorial. Don't use libraries. Shortest code wins.
2
votes
4answers
231 views

Generate Pascal's Pyramid

Pascal's Pyramid is an extension of Pascal's Triangle to the third dimension. Starting with a 1 as the apex, the elements of each successive layer can be determined by summing the three numbers that ...
2
votes
3answers
144 views

Evaluate the binomial theorem!

Your mission, even if you don't accept it, is to input three numbers from STDIN or file: 5 0.5 6 What you must do is evaluate this: (5a + 0.5b)^6 This basically means that the first two ...
-2
votes
0answers
64 views

Build a reusable, customizable menu widget using angularjs [closed]

Build a reusable, customizable menu widget using angularjs that allows you to have as many levels as you like and is reusable in the vain of: Sudo code: -- ul template ul template open for each in ...
0
votes
2answers
166 views

How to shorten this J code? (Or write shorter code in another language)

I decided to learn J so that I could better take part in code golfing. Starting it off relatively simple, I tried writing a solution to this problem: Find the sum of all the multiples of 3 or 5 ...
7
votes
2answers
205 views

Find real roots of a polynomial

Write a self-contained program which when given a polynomial and a bound will find all real roots of that polynomial to an absolute error not exceeding the bound. Constraints I know that Mathematica ...
5
votes
3answers
373 views

ASCII-visualize a graph

Your mission, should you choose to accept it, is to input a series of point pairs that form a graph, like this: A,B C,A B,A A,D A,E F,G C,G You must then output an ASCII visualization of the ...
3
votes
4answers
261 views

Encode a program with the fewest distinct characters possible,

The goal is to write a program that encodes an other program (input) with the fewest character possible. Scoring The score is equal to the different number of characters needed for the output. ...
-5
votes
3answers
94 views

Write 'hello world' to standard output without using certain common words - C# only

The challenge is to write the string hello world to your processes standard output, using as few characters of code as possible. The following restrictions apply: The following words may not appear ...
-3
votes
2answers
163 views

Search for all the possible permutations of one String in another string

Suppose you are given two strings like String 1 = "ipsum" String 2 = "Lorem ipsum is simply dummy text of the printing and typesetting industry. Lorem sipum has been the industry's standard ...
-3
votes
0answers
105 views

What happens when you perform “++” operation on an integer with it's max possible value? [closed]

So, it's a classic but I can't find an answer anywhere. Suppose I've an integer 'x' and int takes 32 bits on this platform. I'm performing the "++" operation in a loop. Something like this: int ...
2
votes
7answers
428 views

Compute the number of ways how you can express a number as a sum

For a given natural number n, compute the number of ways how one can express n as a sum of positive natural numbers. For example, for n = 1 there is just one way. For n = 4 we have 5 possible ways: 1 ...
10
votes
17answers
808 views

Print an arch of ascending / descending numbers

I figured an "arch" was the best way to describe this pattern of numbers: 1234567887654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 ...
18
votes
5answers
539 views

Shortest common superstring

Given a list of strings s_0, s_1, ..., s_n find the shortest string S that contains each of s_0, s_1, ..., s_n as a substring. Examples: S('LOREM', 'DOLOR', 'SED', 'DO', 'MAGNA', 'AD', ...
16
votes
0answers
337 views

The number of possible numeric outcomes of parenthesizations of 2^2^…^2

Consider an expression 2^2^...^2 with n operators ^. Operator ^ means exponentiation ("to the power of"). Assume that it has no default assosiativity, so the expression needs to be fully parenthesized ...
6
votes
5answers
283 views

Avoid duplicate entries using a sign change

This anecdote contains the following intriguing exchange: "Fine, Fred," Avi interrupted. "Then how would you change this to avoid duplicate entries?" "Oh, just change that one there to a negative ...
0
votes
5answers
252 views

exp function to an arbitrary double precision

Write a function to find the solution of e^x given x, and a precision in the form 0.000001. sample input and output: e(4,0.00001) will return 54.5981494762146, and the precision is +/- .00001. The ...
-3
votes
0answers
139 views

Given a string, what will the next items be? [closed]

Given a string that goes on for an unknown length, predict the next three elements in the stream. There will only be two different characters in the string, A and B, and the stream will end with an ...
-1
votes
1answer
236 views

Smallest C code to Crash an Operating System? [duplicate]

A shortest C program, that can crash the Operating system, either on a Windows or a Linux PC... Rules: The code is to be developed in C language, but it may use other api, specific to linux or ...
2
votes
7answers
322 views

letter combinations to make words

Find the combination of N number of letters that make up the most words of length N. For example: n r u -> run, urn dstu -> dust, stud (these are just examples, not the best combination of ...
-4
votes
6answers
133 views

Return the number of digits in any given number

Objective Given any terminating, rational number, return the number of digits the number contains. Do not count zeros if they're the last digits. Examples 0 returns 1 -1 returns 1 6.23 returns 3 ...
-2
votes
0answers
106 views

Generate and print unique numbers that lie within a given range [closed]

Generate and print unique numbers that are withing a given range. Unique numbers are numbers in which no two digits are the same.
1
vote
0answers
196 views

Write a Polish notation interpreter, then change it to RPN in shortest number of chars

Write a program to convert Polish prefix notation to infix notation, then change it to an RPN-to-infix converter in the shortest number of chars. Your score is 100 minus the number of characters ...
0
votes
1answer
96 views

Tips for golfing in Tcl

What general tips do you have for golfing in Tcl? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Tcl (e.g. "remove comments" is not ...
2
votes
5answers
440 views

Challenge: take ciphered text and decipher, also print out if it was offset to the left or right

Problem: Take input text like this: (all input should be considered strings) Upi djpi;f ytu yu[omh pmr yp yjr ;rgy. And figure out if it was offset left or offset right (on a standard qwerty ...
4
votes
7answers
400 views

Evaluate the nth hyperoperation

I do realise that this is a bit math-y, but - here goes. In mathematics, the hyperoperation sequence is an infinite sequence of arithmetic operations (called hyperoperations) that starts with the ...
2
votes
11answers
385 views

minigolf - display anything 3d [closed]

The goal is to write the smallest program in any language which displays any three dimensional output. It might be graphics, it might be ASCII art, but any reasonable person should immediately and ...
12
votes
4answers
612 views

Mozart golf - mini “Rondo”

Output "Mozart - Alla Turca" to stdout (see the sample for "reference implementation") Try to find how to pack both synthesizer and the music into minimal size. Requirements: Format suitable for ...
51
votes
52answers
5k views

-ENDED- Do something that looks like something else

Write a snippet, a function, a programm, ... that is obfuscated in a way that it looks clear at the first sight that it does something else. For example: write a bit of code that adds two number, but ...
15
votes
4answers
951 views

(Re)Implementing Tetris

In the spirit of re-implementing classic video games, I would like to invite the community to create their best implementation of Tetris. For reference, a screenshot of the official NES version of ...
12
votes
23answers
1k 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" ...
8
votes
2answers
372 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 (CFWS) and ...
6
votes
2answers
683 views

Fastest semiprime factorization

Write a program to factorize a semi-prime number in the shortest amount of time. For testing purposes, use this: 38!+1 (523022617466601111760007224100074291200000001) It is equal to: ...
5
votes
6answers
254 views

Return each number from a group of numbers

The challenge The program must return all numbers included into a group (comma and hyphen separated sequence) of numbers. Rules s is the sequence string; all numbers included in s are positive; ...
3
votes
2answers
271 views

PHP Codegolf: Reading/writing files and the CLI

I have been participating in a number of PHP codegolf challenges recently and some of the techniques that are used to read data from a file such as fopen() and fread() or file_get_contents() really ...
66
votes
37answers
6k 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 ...
6
votes
5answers
734 views

Tips for golfing in PHP

What general tips do you have for golfing in PHP? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to PHP (e.g. "remove comments" is not ...
4
votes
2answers
367 views

2-dimensional ray tracing

The challenge is to implement a 2-dimensional ray tracing program, text-based. Sources of white light are @ symbols. R, G and B are light filters. / and \ are mirrors with 80% reflectivity. ? is a ...
10
votes
4answers
384 views

Textual maze solver

Given a maze on stdin and an entry point, write a program that prints a path to the exit on stdout. Any path is acceptable, as long as your program does not generate the trivial path (passing through ...
15
votes
11answers
1k views

Palindromic palindrome checker

Write a program to test if a string is palindromic, with the added condition that the program be palindromic itself.
4
votes
24answers
910 views

Mathematical Combination

Write a program that takes an input such as: n,k which then computes: and then prints the result. A numerical example: Input: 5,2 Internal computation: Printed Output: 10 I'd like ...
129
votes
46answers
3k views

Code Chess: Fibonacci Sequence [closed]

Building upon the proven success of Code Golf, I would like to introduce Code Chess. Unlike Code Golf, which strives for concision, Code Chess will strive for cleverness. Can you create a clever or ...
51
votes
64answers
2k views

Code Golf Christmas Edition: How to print out a Christmas tree of height N

Given a number N, how can I print out a Christmas tree of height N using the least number of code characters? N is assumed constrained to a min val of 3, and a max val of 30 (bounds and error ...

15 30 50 per page
1 2 3 4 5 21