All Questions
0
votes
0answers
22 views
Build a working game of Tetris in Conway's Game of Life
Here is a theoretical question - one that doesn't afford an easy answer in any case, not even the trivial one.
In Conway's Game of Life, there exist constructs such as the metapixel which allow the ...
0
votes
3answers
28 views
Generate a pronouncable word
The challenge is simple:
generate a word.
Specifications:
Word must be pronouncable.
This is defined as "alternating between a consonant and a vowel."
A consonant is one of the following letters: ...
-3
votes
0answers
58 views
some words being left out [closed]
This program will generate a list of all English words for a set of letters, but some words are not in the output, i have checked the dictionary file and it contains the words but they still are not ...
0
votes
0answers
55 views
Generate numerical permutations with conditions and template metaprogramming
This, but via template metaprogramming:
template <int n> struct insanity { int[][n] permutations; }
Generate all numbers with n digits (0-9) such that each digit is either:
Zero
The first ...
6
votes
4answers
213 views
Generate Skolem sequences
Beat this
I was hanging out with a friend in a pub around 11:00 last night. She told me that a Skolem sequence is a sequence of 2n numbers where every number between 1 and n is repeated twice, and ...
3
votes
2answers
87 views
Return the last color of the input in Manufactoria
This puzzle is the next in my series of Manufactoria challenges.
Background
Manufactoria is a game / two-dimensional programming language. The player must create programs that will manipulate a ...
4
votes
3answers
263 views
Quickly divide in Manufactoria
Background
Manufactoria has been marketed as a game, but we code-golfers can see it for what it really is: a two-dimensional programming language. The Manufactoria programming language is based ...
0
votes
1answer
102 views
Determine stability of a system using the Routh-Hurwitz stability criterion
The Routh-Hurwitz is a criteria which serves to prove or disprove the stability of an electric control system.
Idea
Given a system which has an equation of the form P(s)/Q(s) where P(s) and Q(s) are ...
5
votes
2answers
251 views
Convert this character based table into html one
Take a following character table:
-------------------------------------------------------
| |1233456 | abc | xyz | | |
...
9
votes
3answers
298 views
Ratetod text fexir
I heva this wierd text where vewols seem to be ratetod :
I'm a badly written text. Some lunatic guy played with the order of vowels. Please fix me !
So I'd need a pragrom which can rateto the ...
6
votes
1answer
278 views
Can you barcode code in a bar?
Welcome to the piNapple bar, Melbourne. All of the finest code golfers are here, with their laptops, sampling cocktails and programming increasingly badly.
I feel a special need to reemphasise the ...
3
votes
3answers
230 views
Print element from the periodic table [duplicate]
Your task is simple: given a number as an input, you have to print the English name of the chemical element with that atomic number, up to and including ununoctium. For example, for an input of 77, ...
-1
votes
0answers
55 views
Shortest Password-generating algorithm in C [duplicate]
I was wondering what the shortest algorihm you could come up with for the following problem: I want to generate an (alphanum) pseudorandom password. What's the shortest vs. most elegant way to do ...
4
votes
0answers
256 views
Fastest simple regex matcher
Write a regex matcher that supports the following special characters.
? -> matches 1 or none of the previous character, class, or group
* -> 0 or more of the previous character, class, or ...
2
votes
5answers
424 views
Delete those pesky “.DS_Store” files
If you use OS X then you might be familiar with the infamous hidden ".DS_Store" files that are produced as a result of using Finder.
The challenge is to write code that will go through the entire ...
15
votes
8answers
577 views
Save money with price rounding
In Canada, the penny is no longer circulated. Cash payments are rounded to the nearest 5 cents.
Money can be saved by splitting purchases. For example, two $1.02 items cost $2.04 which rounds up to ...
1
vote
2answers
160 views
Floating points: Make Gaussian elimination go wrong
You know that some decimal numbers can't be expressed as IEEE 754 floating points. You also know that arithmetic with floating points can give results that seem to be wrong:
...
6
votes
2answers
366 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 ...
5
votes
0answers
271 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
226 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
134 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
535 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 ...
13
votes
10answers
791 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
200 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 ...
3
votes
10answers
322 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.
3
votes
7answers
458 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
173 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
92 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
213 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
250 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
543 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
355 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.
...
-6
votes
4answers
131 views
Write 'hello world' to standard output without using certain common words - C# only [duplicate]
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 ...
-4
votes
3answers
206 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 ...
2
votes
7answers
528 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 ...
14
votes
26answers
1k 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 ...
19
votes
6answers
702 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
385 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
344 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 ...
-1
votes
5answers
264 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 ...
-1
votes
1answer
290 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
369 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
144 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
226 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
101 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
489 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
406 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
400 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
624 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 ...





