code-golf's questions - English 1answer

8.068 code-golf questions.

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 ...

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'...

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 ...

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 ...

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 ...

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 ...

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....

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 ...

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 ...

Today's challenge is to draw a binary tree as beautiful ascii-art like this example: /\ / \ / \ ...

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, ...

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 ...

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 ...

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 ...

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 ...

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 ...

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 ...

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 ...

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 ...

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 (...

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 ...

Having a function f that takes arguments x1, x2, …, xn                         &...

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 ...

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 ...

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 ...

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 ...

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 {...

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....

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 ...

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 ...

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 ...

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 ...

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/...

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 ...

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 ...

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. ...

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, ...

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 ...

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 ...

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 ...

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 ...

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....

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 ...

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 ...

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 (...

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 ...

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 ...

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 ...

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 ...

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' ...

Related tags

Hot questions

Language

Popular Tags