8.068 code-golf questions.

14 Determining Yes or No?

38 answers, 1.613 views code-golf decision-problem
After inputting a string [length 1-20], only containing the chars y for yes and n for no, your program should output the result (y or n). Example input: yynynynny would output y. The result is ...

75 You're on a 8 day streak!

23 answers, 5.341 views code-golf number
Duolingo, the language learning app, has a lot of things going for it, but there is one major issue that drives me crazy. It tells me how many days in a row I've used the app with a message like You'...

11 Generalized Cantor set segment lengths

5 answers, 241 views code-golf sequence fractal recursion
Problem Let's define a generalized Cantor set by iteratively deleting some rational length segments from the middle of all intervals that haven't yet been deleted, starting from a single continuous ...

10 Rolling Quine Dice

3 answers, 430 views code-golf random quine
Create a program that outputs itself. However, if the source code is repeated n times (by concatenating a copy of the source code to the end n times), then there should be 1/n probability outputting ...

-8 XOR reduction bools

19 answers, 272 views code-golf string math
Description : Given a string of space separated binary digits or space separated booleans or an array of binary digits or array of booleans . Your job is to find the xor of each until you end up with ...

3 clickerhero mercenaries

0 answers, 231 views code-golf simulation
Introduction I have recently started playing clickerheroes again. In the recent patch they introduced a new mechanic to mercenaries: their lifetime. Instead of having a random chance at dying now ...

73 The 9 Billion Names of God

11 answers, 10.723 views code-golf permutations
The 9 Billion Names of God is a short story by Arthur C. Clarke. It's about a group of Tibetan monks whose order is devoted to writing down all the possible names of God, written in their own alphabet....

72 Is this relationship creepy?

64 answers, 13.547 views code-golf number decision-problem
According to this XKCD comic, there is a formula to determine whether or not the age gap in a relationship is "creepy". This formula is defined as: (Age/2) + 7 being the minimum age of people you ...

72 Create an “H” from smaller “H”s

30 answers, 11.070 views code-golf ascii-art fractal
Challenge Create a function or program that, when given an integer size, does the following: If size is equal to 1, output H H HHH H H If size is greater than 1, output X X XXX X X where X is ...

25 Binary tree fractal

11 answers, 494 views code-golf string ascii-art fractal
Today's challenge is to draw a binary tree as beautiful ascii-art like this example: /\ / \ / \ ...

90 Make a “Ceeeeeeee” program

51 answers, 12.287 views code-golf string
Once I wrote a JavaScript program that would take as input a string and a character and would remove all characters except for the first one and the character given as input, one by one. For example, ...

21 Generate a Stack Exchange Favicon

29 answers, 3.032 views code-golf string ascii-art
Do you recognize the PPCG logo? it looks like this, when you do an ascii art of it. +---+ |PCG| +---+ v Now, In this Code Golf, You will make a code, that makes logos for other sites, similar to ...

18 Converting integers to English words

The goal of this code golf is to convert integers to English words. The program prompts for input. If this input isn't an integer, print NaN. If it is an integer, convert it to English words and ...

27 Fridge magnet substitution

14 answers, 3.159 views code-golf string decision-problem substitution
When writing a message with fridge magnets, you'll often find yourself substituting a 1 for an I. In this challenge, your goal is to find out if a message can be written using the letters of another ...

122 1, 2, Fizz, 4, Buzz

227 answers, 28.720 views code-golf string kolmogorov-complexity arithmetic
Introduction In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other ...

76 What my dog really hears

36 answers, 12.570 views code-golf string substitution
My dog is called Rex. Every time I scold him, he seems not very impressed and the only times I see him react is when I pronounce his name. If I say Rex, I told you not to do this! You're making me ...

17 Tips for golfing in MATL

12 answers, 1.026 views code-golf tips matl
MATL is a golfing language created by Luis Mendo. MATL has proven to be highly competitive, often beating submissions in other golfing languages such as Pyth, CJam and Jelly. What are some useful ...

13 Fewest operations to 100

Overview Given a list of digits, find the fewest operations to make 100 Input A string of digits, which may or may not be in numerical order. The order of the digits cannot be changed, however plus ...

34 Is this string a letter doing a cartwheel?

33 answers, 5.063 views code-golf string decision-problem
Challenge inspiration was this that I saw somewhere: The word "nun" is just the letter n doing a cartwheel Your challenge is to take a string and determine if it is the first letter doing a ...

23 A Geometrical Challenge

15 answers, 3.244 views code-golf string ascii-art geometry
Everybody loves geometry. So why don't we try and code golf it? This challenge involves taking in letters and numbers and making shapes depending on it. The Input The input will be in the form of (...

30 Is this number a factorial?

65 answers, 4.877 views code-golf math number decision-problem
The Task Given a natural number as input, your task is to output a truthy or falsey value based on whether the input is a factorial of any natural number. You can assume that the input number will ...

13 Make me some curry

10 answers, 1.352 views code-golf function functional-programming
Having a function f that takes arguments x1, x2, …, xn                         &...

12 Entropic Quine!

4 answers, 564 views code-golf quine stateful
Your task is to write a program or function which: When run for the first time, outputs its source code. On subsequent executions, it should output what it output previously, but with one random ...

12 Grouping Array Data

13 answers, 579 views code-golf array-manipulation
Given an integer matrix a and a nonnegative integer i, output a mapping b that maps the distinct values in the ith column of a to rows of a who have that value in the ith column. You may assume that ...

Find the longest line(s) in an image of the same color [on hold]

0 answers, 108 views code-golf image-processing
I was inspired by a graphic of the longest interrupted lines on a pixel art site: (image credit to JadeX#1046 on Discord) Challenge For this challenge, you must take an input image and get the ...

38 Detect heat waves

Background The Royal Netherlands Meteorological Institute defines a heat wave* as a series of at least 5 consecutive days of ≥25°C weather (“summery weather”), such that at least 3 of ...

9 Convert text to key presses

3 answers, 253 views code-golf keyboard
I am a robot. I bought this keyboard because of its easy rectangular layout: ~` !1 @2 #3 \$4 %5 ^6 &7 *8 (9 )0 _- += tab Qq Ww Ee Rr Tt Yy Uu Ii Oo Pp {...

20 Sort an Integer List

42 answers, 3.300 views code-golf sorting integer
The Challenge It's quite simple really, sort a list of numbers. Details You must sort a list of numbers in ascending order, without using any built-in sorting functions/libraries/etc (i.e. list....

14 Treasure Map Drawing Bot

13 answers, 1.150 views code-golf ascii-art
You're organizing a treasure hunt for your friends. To conduct things more easily, you want to draw a map of all locations where you hid the precious objects. Input Any form of input denoting a list ...

20 Function clipboard: paste

13 answers, 1.566 views code-golf number array-manipulation
This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event. Associated challenge: Function clipboard: copy. Introduction MATL's function ...

354 “Hello, World!”

So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...

17 Multiply two numbers

111 answers, 5.379 views code-golf math number
Input: Two decimal integers. These can be given to the code in standard input, as arguments to the program or function, or as a list. Output: Their product, as a decimal integer. For example, the ...

19 Insist on a new filename

23 answers, 2.180 views code-golf file-system interactive
At runtime, keep prompting for a line of input until the user input is not the name of an existing file or directory or other file system item, relative to the current working directory. Then return/...

-4 Merge two code in two languages into a polyglot [on hold]

Write a program that will merge any valid programs from two proper languages of your choice, into a polyglot. You can assume both programs compile. You can't assume the input is golfed, so if you ...

60 Collatz Conjecture (OEIS A006577)

86 answers, 7.295 views code-golf math
This is the Collatz Conjecture (OEIS A006577): Start with an integer n > 1. Repeat the following steps: If n is even, divide it by 2. If n is odd, multiply it by 3 and add 1. It is proven that ...

17 Give a permutation with no two consecutive integers next to each other

20 answers, 2.634 views code-golf restricted-complexity
Challenge Given an integer n ≥ 4, output a permutation of the integers [0, n-1] with the property that no two consecutive integers (integers with absolute difference 1) are next to each other. ...

16 Find the Fibonacci Patterns

11 answers, 1.695 views code-golf fibonacci
You are probably familiar with the Fibonacci sequence where the first two terms are 0, 1 (or sometimes 1, 1) and every term after that is the sum of the previous two. It starts like this: 0, 1, 1, 2, ...

18 Is this a consecutive-prime/constant-exponent number?

16 answers, 1.393 views code-golf number-theory primes
A while ago, I had a look at the prime factorization of 27000: 27000 = 23 × 33 × 53 There are two special things about that: consecutive-prime: The primes are consecutive: 2 is the ...

18 Find the prime factors

18 answers, 2.147 views code-golf number-theory primes factoring
In this task, you have to write a program, that computes the prime factors of a number. The input is a natural number 1 < n < 2^32. The output is a list of the prime factors of the number in the ...

175 Golf you a quine for great good!

280 answers, 34.469 views code-golf quine
Using your language of choice, golf a quine. A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output. No cheating -- that means ...

-6 Code Golf: simple way to get min & max

5 answers, 792 views code-golf math string function
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 ...

5 HTML2JSON Converter

2 answers, 721 views code-golf json
Edit I have posted a 250 lines reference implementation for review at CR, discussing the major class of the code. Download the complete Visual Studio 2013, .NET 4.5 source code (10 kB) from my server....

22 Random numbers with fixed sum

7 answers, 1.477 views code-golf random
Your task is to write a program or a function that outputs n random numbers from interval [0,1] with fixed sum s. Input n, n≥1, number of random numbers to generate s, s>=0, s<=n, sum of ...

65 Find the Factorial

151 answers, 11.802 views code-golf arithmetic
Create the shortest program or function that finds the factorial of a non-negative. The factorial, represented with ! is defined as such In plain English the factorial of 0 is 1 and the factorial of ...

34 The IHIH Pyramid

I find it fascinating how the letters "H" and "I" are very similar. "H" is a horizontal stroke surrounded by two vertical strokes; "I" is a vertical stroke surrounded by two horizontal strokes (...

68 Create output twice the length of the code

211 answers, 12.825 views code-golf self-referential
The Challenge Write a complete program that writes twice as many bytes to standard output as the length of the program. Rules The program must write ASCII characters to the standard output. The ...

15 Create Balanced BST from Sorted List of Integers

12 answers, 2.269 views code-golf binary-tree
Given a unique, sorted list of integers, create a balanced binary-search tree represented as an array without using recursion. For example: func( [1,2,3,5,8,13,21] ) => [5,2,13,1,3,8,21] Before ...

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

3 answers, 379 views code-golf tips
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 ...

9 Find the best move in a game of Tetris

1 answers, 686 views code-golf tetris
I like Tetris a lot, but I'm not very good at it. Just once I'd like to see that spaceship take off in front of my own eyes! And since computers are oh-so great at everything, the only possible ...

26 Efficient Typing on a Game Boy

6 answers, 1.233 views code-golf string keyboard
Many old Game Boy games often required string input from the user. However, there was no keyboard. This was handled by presenting the user with a "keyboard screen" like so: The 'character pointer' ...