Tagged Questions
Code-golf is a competition to solve a particular problem in the fewest bytes of source code. If you want to score by characters instead of bytes, state this explicitly in the challenge. If source code length is not the primary scoring criterion, consider using another tag instead.
3
votes
0answers
28 views
AppleSauce Fader
Back in the day, all the 1337 kids used text faders in chatrooms. I don't know about you guys, but I want to feel cool like they did. The only problem is that their old scripts and applications were ...
6
votes
1answer
36 views
Find a function with cycles of every length
A function is said to have a cycle of length n if there exists an x in its domain such that fn(x) = x, where the superscript n denotes n-fold application of f. Note that a cycle of length 1 is a fixed ...
14
votes
15answers
459 views
Greatest Number in a Range When The Sum of Squares of its Prime Factors are Subtracted
The formula
Take for instance the number 300
The prime factors of 300 are [2, 3, 5] (unique numbers that are
factors of 300 and prime)
Squaring each of those numbers will give
you [4, 9, 25]
...
19
votes
5answers
1k views
Golf a golf-scorer
As a kid, I used to play the card game "golf" a lot. Your challenge, should you choose to accept it, is to calculate the score of a golf hand. Since there are over 9000 variations on this card game1, ...
6
votes
21answers
2k views
The Nine Pattern
Introduction
I stumbled across this (useless) pattern the other day while I was watching TV.
I named it "the 9 pattern" because the first number to use it was 9.
The gist of it is, you enter a number ...
7
votes
7answers
196 views
Largest Distinctly Sum-Free Partition
related and inspired by -- Finding sum-free partitions
A set A is defined here as being distinctly sum-free if
1) it consists of at least three elements, |A| ≥ 3, and
2) its distinct self-sum A + ...
20
votes
23answers
886 views
Divisor reduction
A divisor of a number n is any number that evenly divides n, including 1 and n itself. The number of divisors d(n) is how many divisors a number has. Here's d(n) for the first couple n:
n divisors ...
6
votes
8answers
1k views
On the Subject of Passwords
In Keep Talking and Nobody Explodes, players are tasked with defusing bombs based on information from their "experts" (other people with a manual). Each bomb is made up of modules, one of which can be ...
-3
votes
0answers
77 views
Output the first character at least ten thousand times in Lazy K [on hold]
In the fewest number of terms (application/parentheses are free), write a lazy K program that takes a single character of input and outputs it a fixed finite number of times which is at least ten ...
29
votes
17answers
2k views
Print the nth prime that contains n
This question will be a twist on finding the nth prime number.
Challenge
You must write a program that will take one input n, and output the nth prime number whose decimal representation contains ...
5
votes
6answers
285 views
Get the most dominant color!
In this challenge, your task is to write a program that takes in an image and returns the most dominant color in it. Dominant color here means the color with which most of the image is covered (see ...
3
votes
2answers
121 views
Chaining Words Together
Given two words and a list as input, your program must (in as few characters as possible, of course) find the shortest way to "chain" the first word to the last using the ones in the list. Two words ...
8
votes
8answers
279 views
Calculate the Numpad Taxicab
Credit goes where credit is due
Given two digits, x, and y, calculate the shortest number of horizontal or vertical jumps to get from x to y on a standard numpad, e.g.
789
456
123
00
You can ...
6
votes
1answer
133 views
Judge Some Titrations
In chemistry class, we were learning about titrations, and attempting one as a lab. We were using phenolphthalein as the indicator for the titration, so on top of grading the lab normally, my teacher ...
-14
votes
11answers
180 views
Output the alphabet using the alphabet
The title is pretty self-explanatory, isn't it?
Your task is to output the alphabet (the string "abcdefghijklmnopqrstuvwxyz") to STDOUT, using each and every letter of the alphabet in your program ...
3
votes
14answers
622 views
Find the number I/O shortest algorithm
Find the shortest function/algorithm to translate these numbers to the ones after the dash:
0 - 0
1 - 10
2 - 20
3 - 30
4 - 40
5 - 50
6 - 60
7 - 70
8 - 80
9 - 90
10 - 100
11 - 115
12 - 130
13 - 150
14 ...
15
votes
32answers
1k views
Toggle a string
The challenge involve simply toggling a string within another string.
Explanation
If the toggle string is a substring of the main string, remove all instances of the toggle string from the main ...
10
votes
1answer
176 views
RegEx-golf: match all contents in a string
Your task is to write a RegEx that matches everything inside strings.
A string is defined as everything surrounded by (but not including) two unescaped ".
A " can be escaped by \, which can also be ...
3
votes
7answers
175 views
Randomly Assign People to Tasks
The challenge is to assign people to tasks randomly~.
From stdin you get 2 lines. Line one is a comma-separated list of names. Line 2 is a comma-separated list of jobs.
The output required is one line ...
-1
votes
2answers
136 views
Find words that rhyme [on hold]
Challenge
Joe the rapper is struggling with rhyming words in his lyrics. He needs your help.
For this situation, we will use rhymes where the last syllable in a word is the same as the other word ...
3
votes
1answer
201 views
Let's play ASCII mini-golf [on hold]
Let's play code golf... by playing golf.
Input
Your input will be a string consisting of #'s, an o, an @, and .'s. For example:
......@..
.....##..
.........
......o..
. - playable golf course ...
30
votes
17answers
4k views
Will the beam hit?
A laser shoots a straight beam in one of the four orthogonal directions, indicated by <>^v. Determine whether it will hit the target O on a rectangular grid.
Each of these will hit (True):
...
17
votes
7answers
844 views
Normal and visual string reversion
Write some code that acts as a cat program. That is, to input a string and output it as is. But the normal reversion of your code must output the normal reversion of the input string. And the visual ...
10
votes
1answer
149 views
Recursive Steiner Chains
Steiner Chains are a set of N circles where each circle is tangent to 2 other non-intersecting circles as well as the the previous and next circles of the chain, as seen in the below images:
In ...
6
votes
1answer
195 views
Generate ASCII TetraVex
TetraVex is a tile-based edge-matching game that was originally coded by Scott Ferguson for the Microsoft Entertainment Pack 3 back in 1990. The game consists of a grid upon which square tiles are ...
-2
votes
2answers
144 views
Restricted average (arithmetic mean) – i.e. without obvious built-ins [closed]
Introduction
The arithmetic mean is defined as being equal to the sum of the numerical values of each and every observation divided by the total number of observations. Symbolically, if we have a ...
20
votes
17answers
2k views
How should you arrange your chairs?
You teach a class of students with interesting preferences for how their chairs are arranged. There are 3 very specific requirements they have for how the chairs are arranged:
They most be arranged ...
26
votes
23answers
4k views
Flatten the Array!
In this challenge, your task is to create a program which takes in a nested array and returns a single-dimensional flattened array. For Example [10,20,[30,[40]],50] should output [10,20,30,40,50].
...
7
votes
4answers
258 views
Three Indistinguishable Dice
Given three dice rolls (integer values from 1-6) in sorted order (so as to be indistinguishable), convert them to the sum of two fair dice with an identical distribution.
The answer for three to ...
11
votes
2answers
250 views
What's the chance that I'll win a door prize?
My local ACM chapter gives out door prizes to people who come to the meetings. You get an increased chance of winning if you solve the programming puzzle, however (but I always solve that puzzle). ...
11
votes
13answers
2k views
Grow a Treemote!
This is my friend Thomas. He is half tree, half emoticon.
| |
| :D |
| |
He is lonely. Let's make him some friends!
Given a text-based emoticon as input (e.g. ಠ_ಠ, :P, >_>, not 😀, ...
8
votes
1answer
284 views
How to find the item in a list whose f(item) is the smallest?
I have a list, l and a function f. f is not strictly increasing or decreasing. How can I find the item in the list whose f(item) is the smallest? For example, let's say the list is:
l = [1, 2, 3, 4]
...
15
votes
10answers
704 views
Compress your code in an image
This is a quine variation.
Introduction
We all write short code, because some obscure reasons, but whatever we do, the'll take up at least 144 pixels/byte (with a 12px font). But what would happen, ...
14
votes
10answers
473 views
Shortest Pangrammatic Window
A pangram is a sentence or excerpt which contains all twenty-six letters of the alphabet, as is demonstrated in this code golf challenge. However, a pangrammatic window is a pangram in the form of ...
10
votes
11answers
683 views
Discrete Convolution or Polynomial Multiplication
Given two non empty lists of integers, your submission should calculate and return the discrete convolution of the two. Interestingly, if you consider the list elements as coefficients of polynomials, ...
-4
votes
0answers
86 views
brute force the smallest regex for any regex in the fastest time [closed]
Any flavor of regex in any programming language is allowed. As far as test cases go, you will try to match only all element symbols, and this challange
One tip would be to try to do a general ...
-12
votes
9answers
175 views
Find the circumference! [closed]
Challenge
Well, find the circumference of any circle. You'll be using the formula 2*pi*radius or pi*diameter.
Rules
You will take an input, r or d, as command line argument or stdin. Your program ...
19
votes
32answers
4k views
Smallest integers after N divisible by 2, 3, and 4
Give credit to whom credit is due.
Objective Given an integer N > 0, out the smallest integers A, B, and C so that:
All of A, B, and C are strictly greater than N;
2 divides A;
3 divides B;
and ...
-4
votes
0answers
166 views
Harvest energy in Screeps, a MMO for programmers (not modding or “scripting”, regular gameplay)
Screeps is an MMO for programmers (not a regular MMO, this is not modding, but rather the only way to play) where you program creeps. Energy is used to do things in Screeps. There are energy sources ...
17
votes
10answers
1k views
Contaminated Squares
Introduction
Let's observe the following square, consisting only of the digits 0 - 9:
1034
4167
8414
3542
The outer shell of this square is:
1034
4 7
8 4
3542
It contains zeros, so we need to ...
5
votes
0answers
60 views
Tips for golfing in Erlang
Does anybody have tips for golfing in Erlang? I'm looking for specific things that can be applied to Erlang, not any language. I know we already have tips for Elixir, but that is different.
As ...
15
votes
1answer
329 views
Better way to read multiple int in C than scanf
I'm trying to read 4 ints in C in a golfing challenge and I'm bothered by the length of the code that I need to solve it:
scanf("%d%d%d%d",&w,&x,&y,&z)
that's 29 chars, which is ...
10
votes
1answer
223 views
How many squares are there?
This challenge is inspired by a picture that often roams on Facebook that looks like this. Except our base square will look more like this:
┌─┬───┬─┐
├─┼─┬─┼─┤
├─┼─┴─┼─┤
├─┼─┬─┼─┤
└─┴─┴─┴─┘
The ...
11
votes
5answers
288 views
Print the AdamN tile
Adam7 is an interlacing algorithm for raster images, such as PNG. It is called the "Adam7" algorithm because it was invented by Adam M. Costello, and it is generated by following a certain pattern 7 ...
1
vote
1answer
115 views
Continuously expanding code [duplicate]
Your job is to write a program that rewrites and makes itself longer on each run of the program.
Challenge
The program will print Hello, World!\n (\n denotes a newline). Then, it will modify its own ...
-1
votes
1answer
94 views
Needs more jQuery! [closed]
Inspired by this site, this question could potentially be a doozie. People on StackOverflow often overuse jQuery as an answer. Therefore, we need a way to recognize programmatically if a code snippet ...
2
votes
3answers
537 views
Calculate the Trump Tax [closed]
If elected president, Donald Trump plans to implement a system of four income tax brackets (full details can be found on his website here). Your job is to take two inputs, annual income and filing ...
13
votes
13answers
2k views
Fibonacci products
You can decompose a number greater than 0 as a unique sum of positive Fibonacci numbers. In this question we do this by repeatedly subtracting the largest possible positive Fibonacci number. E.g.:
1 ...
1
vote
9answers
406 views
Fix my Basic Orthography
Fix my Basic Orthography
While I am excellent at following the English capitalisation rules when writing, when I am typing I have a habit a capitalising almost everything (as you will see from the ...
7
votes
10answers
332 views
Columnar Transposition Cipher
Columnar Transposition Cipher
While I have plenty of programs I have written for more advanced ciphers, I just realised I don't actually have one for one of the simplest: Columnar Transposition. The ...