Questions tagged [code-golf]

Code-golf is a competition to solve a particular problem in the fewest bytes of source code.

Filter by
Sorted by
Tagged with
3
votes
4answers
285 views

Is this a Lucas number? [duplicate]

Write a program or function that takes an input greater than or equal to 2. It should output a truthy or falsy value corresponding to whether the input is a Lucas number or not. You may take input ...
3
votes
5answers
808 views

Alex the Truck Driver

Alex is a Truck Driver who wants to find the quickest way to deliver goods to multiple cities. He knows the distances between his destinations, but you need to write a program to help him find the ...
3
votes
5answers
313 views

Sorting for search by monotomy

Statement Given N distinct integers, output them in order such that for any integer J from 2 to N, for any K>0 obtainable by dividing J by 2 (rounding down) at least one time, the Jth integer ...
3
votes
6answers
400 views

Autocomplete the input

Pre-Note Because of popular demand, and to avoid disqualifying certain languages, the dictionary can now be provided as input parameter. Intro Given a dictionary of words, you should write an ...
3
votes
1answer
169 views

Black and white shirt 2

This is a more complicated version of this puzzle. The premise is the same but a few rules differ in a few key places, making for a more complex problem. Assume I have some number of black shirts and ...
3
votes
1answer
555 views

Find number of polynomials with a root which is a root of unity

Write a program which takes an integer argument and outputs the number of degree n monic polynomials with coefficients that are -1,1 or 0 which have a root which is a root of unity. To make it a ...
3
votes
13answers
468 views

Create a kind of quine, such that the program prints one character of itself, then two, then three and so on

Create quine variant such that the program prints its first character, then the first two, then three and so on until the whole program is printed. Example Suppose your code is ...
3
votes
14answers
2k views

Base-2 integer logarithm of 64-bit unsigned integer

Problem: In your choice of language, write the shortest function that returns the floor of the base-2 logarithm of an unsigned 64-bit integer, or –1 if passed a 0. (Note: This means the return type ...
3
votes
5answers
789 views

Isn't the point of math to just use numbers?

Write a program that converts a mathematical expression to words, evaluates the expression, and prints how the equation would be spoken aloud. Input The input must only contain numbers and the ...
2
votes
2answers
233 views

Simulate Rocket League Quick Chat

In Rocket League, there are controls assigned to quick chat. For PC, they are 1, 2, 3, and <...
2
votes
1answer
618 views

Recursive Mathematical Puzzle from a high school contest

The problem appeared on the 2013 SJCNY High School Programming Contest. It was the last question in the set of problems and no team produced a correct answer during the 2.5 hours they had to work on ...
2
votes
7answers
2k views

Alien Name Generator [closed]

Task Write a function to generate names of aliens and their worlds, so that the output is of the form: Greetings Earthfolk, I am ____ of the planet _____. "...
2
votes
0answers
246 views

Write the shortest code that bring to a solution of “The old curious knight with a lazy horse” problem [duplicate]

The Story: Once upon a time there was a curious Knight that lived on a never used chessboard in the Realm, an antique store. He spent all his career over there and when it came the moment of the ...
2
votes
4answers
487 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
7answers
389 views

Black and white shirts

This puzzle is based on this Math.SE post. A more complex version of this problem can be found over here. Assume I have some number of black shirts and some number of white shirts, both at least 1. ...
2
votes
0answers
126 views

Chemical sentences! Encrypting [duplicate]

Background You are bored in class, and having exhausted all the possible things to write on a standard calculator (Like 8008135) you turn to the periodic table. You want to figure out if you can ...
2
votes
3answers
360 views

Calculate the first n perfect numbers [closed]

Write a program that calculates the first n perfect numbers. A perfect number is one where the sum of the factors is the original number. For example, 6 is a perfect number because 1+2+3=6. No non ...
2
votes
1answer
395 views

Gode-Colf: Wipping Flords around [duplicate]

Here is another short string related code-golf. You must write a full program that reads a string (from STDIN or as command line arguments, as long as you specify which) and wips the flords around (...
2
votes
3answers
168 views

Most logical rectangle formula from numbers [duplicate]

Introduction The task is simple. When given a number, output the most logical rectangle. To explain what a logical rectangle is, I provided some examples: Input: ...
2
votes
5answers
534 views

Find the next number in the pattern

Write a program, that takes 5 numbers as input and outputs the next number in the pattern. Heres a text file with 1835 test patterns, containing 6 numbers separated by commas each line. Using the ...
2
votes
6answers
1k views

Self replicating Hello World program [closed]

Create a self-replicating Hello World Program. (The program has the ability to use the compiler, if you want). For example: ...
2
votes
1answer
336 views

Create a Boolean parser [closed]

What you need to do is create a Boolean parser. Boolean expressions, in case you haven't heard of them yet, have two inputs and one output. There are four 'gates' in boolean arithmetic, namely OR (...
2
votes
2answers
212 views

Tips for golfing in Visual Basic

This page is not for Visual Basic .NET Tips or VBA tips Visual Basic (VB or VB6) is an object-oriented and event-driven dialect of basic that was developed and released by Microsoft in 1991. The last ...
1
vote
6answers
295 views

Tips for golfing Yabasic

Yabasic, or Yet Another Basic is a dialect of basic created by Marc-Oliver Ihm that may be run on Windows, Unix and PAL versions of the Sony PlayStation 2. Development for this language is ongoing. ...
1
vote
2answers
1k views

Longest Seven Segment Word

This question was inspired by Tom Scott's video here. The English language has plenty of words, but what's the longest one that can be displayed on a seven segment display? Your challenge is given a ...
1
vote
0answers
74 views

Merry Christmas (and a Happy New Year) [duplicate]

The goal of this challenge is to create a program that outputs a string depending on the time of year. Output If the date is December 25, output: ...
1
vote
0answers
106 views

Encode the simple substitution cipher [duplicate]

Review First, let's review the Simple Substitution Cipher. To encode a string in the Simple Substitution Cipher, replace each letter in your string with another letter. A letter may not be used to ...
1
vote
1answer
234 views

Tips for golfing in Befunge 93 [duplicate]

What general tips do you have for golfing in Befunge 93? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Befunge 93 (e.g. "remove ...
1
vote
1answer
4k views

Find the Longest Palindrome in a String by Removing Characters [duplicate]

Problem: Remove characters from strings to make the longest (character length) palindrome possible. The first line gives an integer value of the number of strings to test. Each subsequent line is a ...
1
vote
2answers
243 views

Tips for golfing in Visual Basic .NET

This page is not for Visual Basic Tips Visual Basic .NET (VB.NET) is an multi-paradigm dialect of basic that was developed and released by Microsoft in 2002 as a replacement for Visual Basic. The ...
1
vote
1answer
208 views

Dyalog's International Problem Solving Competition (Phase I) – Code Golf Edition [closed]

Every year, Dyalog Ltd. holds a student competition. The challenge there is to write good APL code. However, this is a multiple-holes (common theme is manipulation of data of any type and structure, ...
0
votes
6answers
258 views

What's the missing column/row? (GCJ 2016-1A rankfile)

There is an N x N square of numbers. All columns increase strictly monotonically from top to down All rows increase strictly monotonically from left to right There ...
0
votes
2answers
308 views

How compute WPA key? [closed]

WPA2, the actual encryption standard that secures all modern wifi networks, has been cracked... This challenge has nothing to do with the way that the WPA2 was cracked, however is is about computing ...
0
votes
3answers
259 views

Output in the Correct Order

Ok lets say we get a input the following csv file (all entries are quoted strings) ...
0
votes
3answers
238 views

Havel-to-da-Hakimi [duplicate]

It was a dark and stormy night. Detective Havel and Detective Hakimi arrived at the scene of the crime. Other than the detectives, there were 10 people present. They asked the first person, "out of ...
0
votes
0answers
85 views

Josephus Problem [duplicate]

With n people numbered 1 to n in a circle, every second one is eliminated until only one survives. For example, for n=10, the elimination order is 2 4 6 8 10 3 7 1 9, so 5 survives. The problem: ...
0
votes
11answers
873 views

HyperNeutrino is back!

Today, @HyperNeutrino succeeded merging his two accounts, and finally got the reputation he lost back. Now, it's time to celebrate! Your task is to output this exact text: /\ ...
0
votes
7answers
405 views

Embedded Triangles!

Your task: given an integer n, output an embedded triangle to the nth depth. Standard methods of input and output, input in any ...
-1
votes
1answer
207 views

Solitaire no-win states [duplicate]

NOTE: SIMILIAR TO Solitaire Dreams - Creating a winnable solitaire starting hand Find a minimum of 5 deck orders where if the cards were dealt out would create a game of Klondike Solitaire where ...
-1
votes
5answers
338 views

Do not use the same code again [closed]

I want to give a task. The main rule is not to use the same code again, it means no loops, no jumps, no goto, no recursion, if you declare procedure it can be called only once and etc. Also if you ...
-1
votes
1answer
2k views

Solve this math problem in smallest amount of code [closed]

Here I found a cool math problem. I thought you could write some golfed code to compute all answers between x and x.(there is an infinite amount). Problem: Once upon a time, and old lady went to sell ...
-2
votes
1answer
7k views

Shortest way to generate UUID's version 3,4 and 5 in php

I have this function to generate UUID's: ...
-2
votes
1answer
233 views

Generate a hexdump of a file! [duplicate]

In this task, your goal is to write a program for generating hexdumps of files of arbitrary types. Input The input consists of a (relative or absolute) path to the file to be processed. It may be ...
-3
votes
1answer
208 views

Find an Eulerian Circuit

Challenge You have been assigned a task to write a program which takes a multigraph as its input and if it contains an Eularian circuit to return one. Otherwise, the program's behavior is undefined, ...
-4
votes
3answers
452 views

Find the hardest OEIS sequence to golf!

Notice: This question originally had people write comments with a shorter program, rather than new answers. This has been changed so that people with shorter programs can get reputation too. Hopefully ...
-5
votes
4answers
229 views

Binary Magic Cards [closed]

There's a cool magic trick that works using the power of binary. The effect of the trick is as follows: An audience member chooses some natural number in the range of ...
-5
votes
2answers
765 views

Make a golfing language [closed]

In this challenge, you get to create a language. Although you have to provide code in other languages, you will only be rated based on the language. Here are the requirements. You must invent a ...
-5
votes
4answers
290 views

Solve an algebraic expression

The Challenge Your task is to create a program that can solve an algebraic equation. Input Input will consist of a String. The string will be an equality ...
-6
votes
13answers
238 views

Am a I square repdigit? [closed]

Your Task You will write a program or function to return a truthy value if the integer inputted to it is a square repdigit, and a falsy value if it is not. A repdigit is an integer that contains ...
-6
votes
10answers
239 views

The year counter is here [closed]

Create a program that, given an integer N, outputs the number of years we have to get to N A.D. or how many years it has been since N A.D, as a string or int. For example, given 2014, the program ...