instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
The Goal
The goal of this question is to put a twist on this question. Your answer should be able to convert an array of words associated with integers into those integers. As an extra challenge, allow support for , +, -, and _ in between numbers such as sixty seven, sixty+seven, sixty-seven, or sixty_seven.
Examples
... | stackexchange_codegolf |
This was one of a series of challenges leading up to Brain-Flak's birthday. Find out more here.
Challenge
For this challenge your objective will be to find the very first pair of matching brackets in a fully matched string of ()[]{}<> brackets. To borrow DJMcMayhem's definition of a fully matched string:
For the pur... | stackexchange_codegolf |
Let's say you have a sentence like:
this is a very long sentence with several words of no significance
It contains only the 26 lowercase letters of the alphabet and spaces.
And you have a dictionary, where each word contains any number of the 26 lowercase letters and nothing else:
henge
renton
Then the output should ... | stackexchange_codegolf |
Output this binary sequence of length 1160:
-++-+--++-++-+--+--++-+--+--++-+--++-++-+-++--++-+---+-++-+--+--++++--+--++-+--++-++----++-++-+-++--++-+-+---++-+--++-++-+--++-+--+---+-++-+--++-++-+--+--++-++-+--++-+--+++-+-+----+++-+--+--+++---++-++-+--+--+++--+-+-+--+-+++-++-+--+--++-+--++-++-+--+--++--+++---+++-+---++-+-... | stackexchange_codegolf |
Given a list of strings, replace each string by one of its non-empty substrings which is not a substring of any of the other strings in the list and as short as possible.
Example
Given the list ["hello","hallo","hola"], "hello" should be replaced by just "e" as this substring is not contained in "hallo" and "hola" and ... | stackexchange_codegolf |
A string is dot-heavy when its morse representation contains more dots than dashes. For example, the letter E is a single dot, which means it is Dot-heavy.
Input
The input string will only contain characters in the range of [a-z] or [A-Z]. You can decide if they should all be upper case, or all lower case. AAA is fine... | stackexchange_codegolf |
Given an array of letters in the range 'a' to 'o', compute how to construct the array by successively inserting the letters in alphabetical order. You will always start the insertion with a base array of all the 'o's that are in the array to be reconstructed.
Examples
Let the input array be:
['o', 'b', 'o', 'b', 'a']
... | stackexchange_codegolf |
Mary has given John two sticks of lengths a and b respectively, where a and b are positive integers.
John is very curious.
He would like to know how many triangles with integer perimeter can be formed, by having one additional side.
Please help him find it out.
(This is my first time composing this kind of stupid stori... | stackexchange_codegolf |
Given an integer n, your task is to determine whether it is a perfect square that when reversed, is still a perfect square. You may assume n is always positive.
When numbers such as 100 (10x10) are reversed the result may have leading zeros (001) In this case, ignore the leading zeros and treat it as 1 (1x1).
Test case... | stackexchange_codegolf |
Introduction
In the video the best way to count, binary is proposed as the best system of counting numbers. Along with this argument is a proposal on how to say numbers in this system. First, we give names to each "double power of two", \$2^{2^n}\$ for each \$n\$.
number = symbol = spoken
============================
2... | stackexchange_codegolf |
Overview
As most of y'all who visit chat know, I am Russian by ethnicity[citation not needed]. Recently, I switched from a keyboard that maps the letters 1-to-1 (mnemonic) to Windows' default mnemonic keyboard. Here are the letter mappings:
"`" -> "ъ"
"q" -> "я"
"w" -> "ш"
"e" -> "е"
"r" -> "р"
"t" -> "т"
"u" -> "у"
"i... | stackexchange_codegolf |
This is a rock paper scissors competition. Algorithms will face each other in 100 rounds of rock paper scissors. Except that the algorithms will also be able to read the source code of each other!
Leaderboard
1. Chaos Bot (by Aiden4) - 27 Points, 168 bytes
2. Anti-99%-of-posts (by Lyxal) - 24 Points, 489 bytes
3. Psued... | stackexchange_codegolf |
Piano keys are 3 characters wide, and 7 characters tall. However, if every key was 3 charactes wide, there wouldn't be enough room for the black keys. That's why some of the white keys have parts of them cut out. There are 3 types of white keys.
Keys with the right half missing (R):
____
| |
| |
| |
| |
| |
|... | stackexchange_codegolf |
You are given an array \$A\$, which may contain duplicate elements. In each swap, you may swap the value of any two indices \$i, j\$ (i.e. switch the values of \$A_i\$ and \$A_j\$). What is the least amount of swaps needed to sort the array, and what are the corresponding swapped indices?
Scoring
This is code-golf, so ... | stackexchange_codegolf |
In this challenge you will be converting a mixed number to an improper fraction.
Because improper fractions use fewer numbers, your code will need to be as short as possible.
Examples
4 1/2
9/2
12 2/4
50/4
0 0/2
0/2
11 23/44
507/44
Specification
You may assume the denominator of the input will never be 0. The inpu... | stackexchange_codegolf |
Output this 1364-digit base-10 number:
10346063175382775954983214965288942351853612536382034663905935101461222060548195774084941504127779027795484711048746289269095513027910438498906751225648197766590064457965461314130149942152545074712074006545797623075756579902190433531325851645586375231773037880535184421903026638874... | stackexchange_codegolf |
Information
Create a diagonal line given its length (let’s call the variable, say, \$n\$ where \$n > 0\$)
The diagonal line starts from the top left and goes to the bottom right.
You must use the ASCII character \ for the line.
The input number can be given from STDIN or if your program doesn’t support that, use a har... | stackexchange_codegolf |
Chaim Goodman-Strauss, Craig Kaplan, Joseph Myers and David Smith found the following simple (both objectively and subjectively) polygon that tiles the plane, but only aperiodically:
Indeed they found a one-parameter family of such aperiodic monotiles or "einsteins". The edges of all tiles in this family meet at 90° o... | stackexchange_codegolf |
The goal of a Rosetta Stone Challenge is to write solutions in as many languages as possible. Show off your programming multilingualism!
The Challenge
Your challenge is to implement a program that will input a list of numbers and output the rule used to generate each successive number in the series, in as many programm... | stackexchange_codegolf |
Given a matrix consisting of positive integers, output the path with the lowest sum when traversing from the upper left element to the bottom right. You may move vertically, horizontally and diagonally. Note that it's possible to move both up/down, right/left and diagonally to all sides.
Example:
1* 9 7 3 10... | stackexchange_codegolf |
I have recently been on a quest to create really really slow sorting algorithms that make Bogosort seem like it is the best.
The task is simple: Sort an array of integers in as long average time as possible, with the average Bachmann–Landau notation begin as high as possible, while keeping the best case performance fas... | stackexchange_codegolf |
The best solution I've found so far for a golf code puzzle I'm working on includes two rather fat-looking invocations of range. I'm very new at code golf, especially in Python, so I could use a few tips.
The relevant fragment is this
[x for x in range(n+1,7**6)if`x`==`x`[::-1]*all(x%i for i in range(2,x))]
The upper ... | stackexchange_codegolf |
The world's changing to a new time system! We need to update our computer programs. Given an input of epoch time (number of seconds since January 1st, 1970 00:00), print out a time in the new Noxu date-time format.
864 seconds make one Fluffster. 100 Fluffsters make a Skizzle. There are 4 Skizzles in one Zestpond. ... | stackexchange_codegolf |
Given the input of n and value. The code is supposed to nest the single element list with value repeated n times. The final output should be a multilevel nested list with single repeated values in all sublists.
This is code-golf, so the shortest code in bytes wins!
Test cases:
n = 1, value = 'a': ['a']
n = 2, value = '... | stackexchange_codegolf |
Happy New Year 2024!
2024 is a tetrahedral number. A tetrahedral number is a number that can be represented in the form \$n(n+1)(n+2)/6\$ for some positive integer \$n\$. Or, equivalently, they are the sum of the first \$n\$ triangular numbers. They are also the number of objects in a triangular pyramid which has \$n\$... | stackexchange_codegolf |
For any positive integer \$k\$, let \$d(k)\$ denote the number of divisors of \$k\$. For example, \$d(6)\$ is \$4\$, because \$6\$ has \$4\$ divisors (namely \$1, 2, 3, 6\$).
Given a positive integer \$N\$, display a "skyline" in ASCII art using a fixed character, such that the height of the "building" located at horiz... | stackexchange_codegolf |
The powers that be want to be able to quickly convert any number they have into their own number base using any format they would like.
Input
Your program must accept 3 parameters.
Number: The string number to be converted
InputFormat: the base string the number is currently in
OutputFormat: the base string that the ... | stackexchange_codegolf |
The narcissist is a program which, given its own source as input, prints a truthy value and, given anything other than that, prints a falsey value. Today, we're reversing this.
Create a program that, given the name of whatever your language's truthy value is (True, true, 1), prints its own source. Given the name of wha... | stackexchange_codegolf |
Construct a program or function that takes input in form of
<width>, <height>, <color1>, <color2>
and generates an output such that first row alternates between pixels of color <color1> and <color2> with a period of <height>. For each row that follows, the period shall be <height> - <row number>. Note that <color1> a... | stackexchange_codegolf |
Challenge:
Given the input array l with a list of strings, only keep the elements in the sequence that have a letter that's repeated at least 3 times. Like 'lessons' has 3 s letters, so it should be kept in the sequence. But, 'lesson' has only two s letters, so it should be removed.
Notes:
l will always be a sequence,... | stackexchange_codegolf |
Help, I've been diagnosed with prosopagnosia! This means I'm no longer able to recognise faces.... :(
Can you help me?
The challenge
You will be given an image as a matrix of regular ASCII characters separated by new line characters, and your task is to determine if it contains a face. Faces will look something like th... | stackexchange_codegolf |
Introduction:
Some times using a 24-hour clock are formatted in a nice pattern. For these patterns, we'll have four different categories:
All the same (pattern A:AA or AA:AA):
0:00
1:11
2:22
3:33
4:44
5:55
11:11
22:22
Increasing (pattern B:CD or AB:CD, where D==C+1==B+2==A+3):
0:12
1:23
2:34
3:45
4:56
12:34... | stackexchange_codegolf |
Consider an \$n \times n\$ grid of integers which is part of an infinite grid. The top left coordinate of the \$n \times n\$ grid of integers is \$(0, 0)\$.
The task is to find a circle which when overlaid on the grid gives the largest sum of values inside it. The constraints are:
The circle has its centre at \$(x, x... | stackexchange_codegolf |
Given an inconsistently indented piece of html code your task is to return the same text but correctly indented
Indent space = 4
Assume input will be non-empty.
Input can be taken as string or array/list of lines
Opening and closing tags must be on the same line as long as there is not any other tag inside. <td></td>... | stackexchange_codegolf |
The goal is to raise the error message with the most bytes! The error message may not be generated by the program itself, such as Python's raise. errors that do not terminate the program are not allowed unless they do not show an error message.
Here is an example in python that raises 243041 bytes of error code:
def a(... | stackexchange_codegolf |
You must write a program or function that, when given a nonempty string S of N printable ASCII characters†, outputs a program that will exit with exit code C, where C is the ASCII codepoint at position 0 in S. This program you write will additionally output a program P, such that, when run, it exits with exit code C′, ... | stackexchange_codegolf |
The Challenge
Given two strings/an array of strings, output the first string slowly shrinking and expanding back into the second string.
You can assume the strings will always start with the same character.
Example
Input:
"Test", "Testing"
Output:
Test
Tes
Te
T
Te
Tes
Test
Testi
Testin
Testing
First you output the fi... | stackexchange_codegolf |
Challenge
This coding challenge is to figure out how many rounds the cat can live.
In a \$4\times4\$ matrix, there are a number of mice and exactly 1 cat.
Example:
$$
\begin{array}
{|r|r|}\hline
& & & ⬜ \\
\hline
⬜ & & ⬜ & ⬜ \\
\hline
⬜ & ⬜ & ⬜ & \\
\hline
& & & \\
\hline
\end{array}
$$
But in each square of t... | stackexchange_codegolf |
Here's a problem to which I don't know the answer. Suppose you have an ordered list of integers with an operator in between each consecutive pair. Let's restrict ourselves to three operations that are closed over the integers, namely addition, multiplication and subtraction. Is there a good way to find the order we sho... | stackexchange_codegolf |
Art stolen from What size is the digit?
7-segment digits can be represented in ASCII using _| characters. Here are the digits 0-9:
_ _ _ _ _ _ _ _
| | | _| _| |_| |_ |_ | |_| |_|
|_| | |_ _| | _| |_| | |_| _|
Your job is to parse the art into normal numbers.
Notes on numbers
Each digit ... | stackexchange_codegolf |
As of time of submission to the sandbox, I had 17017 reputation, which you will all be able to factorise as 7×11×13×17, a product of 4 consecutive primes.
Please write a function or program to output all the products of two or more consecutive primes up to an input integer n. For example, given n=143 you should output ... | stackexchange_codegolf |
For each character in your program, the program with that character removed must produce a number smaller than the program with the next character removed. Your base program isn't required to do anything, and may be invalid.
An example submission could be abcd, where bcd outputs 1, acd outputs 4, abd outputs 5, and abc... | stackexchange_codegolf |
Inspired by this challenge
Given an integer in the range 0 <= n < 2**64, output the minimum sized container it can fit in out of
bit: 1
nibble: 4
byte: 8
short: 16
int: 32
long: 64
Testcases:
0 -> 1
1 -> 1
2 -> 4
15 -> 4
16 -> 8
123 -> 8
260 -> 16
131313 -> 32
34359750709 -> 64
This is code-golf, so the shortest ans... | stackexchange_codegolf |
This task is rather simple, and makes use of three distinct "operator" characters. Your task is, given a simple sequence of letters, perform the following task to encode it using <,>,*. You may choose to use either upper or lowercase letters, you do not have to handle both.
Cipher Explanation
The cipher is simple, you... | stackexchange_codegolf |
If you don't know what a queen is in chess, it doesn't matter much; it's just a name :)
Your input will be a square of arbitrary width and height containing some amount of queens. The input board will look like this (this board has a width and height of 8):
...Q....
......Q.
..Q.....
.......Q
.Q......
....Q...
Q.......... | stackexchange_codegolf |
Information
Create a diagonal line given its length (let’s call the variable, say, \$n\$ where \$n > 0\$)
The diagonal line starts from the top left and goes to the bottom right.
You must use the ASCII character \ for the line.
The input number can be given from STDIN or if your program doesn’t support that, use a har... | stackexchange_codegolf |
For this challenge, you must create a programme which takes an integer x and outputs its source x many times.
Rules
This is codegolf, the aim is to golf your programme to have the least amount of bytes
If you submit a function, the function must take x as a parameter and either return or print the entirety of your co... | stackexchange_codegolf |
The city defines a dog as any living entity with four legs and a tail. So raccoons, bears, mountain lions, mice, these are all just different sizes of dog.
Given an ASCII-art image of an animal, determine if that animal is a dog.
Rules
An animal is a dog if it has four legs and a tail.
The foot of a leg starts with one... | stackexchange_codegolf |
(Similar: Through the bases)
Normally, our number system is base ten, with the digits 0123456789. However, we can increase or decrease the base count (so hexadecimal uses 0123456789abcdef and octal uses 01234567.
Your goal is: given a string, interpret it in all bases 2-36 for which it's valid, compute the total, and e... | stackexchange_codegolf |
This question is inspired by this answer. Coincidentally, I used to use Ethiopian Multiplication when I was a kid, but had never known the name of the method until recently.
Ethiopian multiplication is a method of multiplying integers using only addition, doubling, and halving.
Method:
Take two numbers to be multiplie... | stackexchange_codegolf |
Given a polynomial in one variable with rational coefficients, output an equivalent expression containing only 1, variables, and definite integrals. For example, -x2 can be expressed as ∫x∫111dtxdu.
E := 1 | var | ∫EEEdvar
Any reasonable input/output method is allowed.
Examples:
Your score will be the your code length... | stackexchange_codegolf |
Specifically, Conway's PRIMEGAME.
This is an algorithm devised by John H. Conway to generate primes using a sequence of 14 rational numbers:
A B C D E F G H I J K L M N
17 78 19 23 29 77 95 77 1 11 13 15 15 55
-- -- -- -- -- -- -- -- -- -- -- -- -- --
91 85 51 38... | stackexchange_codegolf |
A simple one:
Take a positive integer n less than 1000, and output the integers from 1 to n interleaved with the integers from n to 1. You must concatenate the numbers so that they appear without any delimiters between them.
Test cases:
n = 1
11
n = 4
14233241
n = 26
1262253244235226217208199181017111612151314141315... | stackexchange_codegolf |
Be sure to see the other challenge, Reverse ASCII character map!
The ASCII charset (American Standard Code for Information Interchange) is the most widely-used character encoding standard. ASCII codes represent text in computers, telecommunications equipment, and other devices.
Challenge
Your challenge is to print a ... | stackexchange_codegolf |
Your task is to print this exact text:
| | | | | |
&***********&
| Code Golf |
| e---------f |
| d___________l |
| o-------------o |
| C_______________G |
###Dennis$Dennis###
#####################
Rules
Trailing or leading newline is allowed
code-golf, so shortest code wins!
| stackexchange_codegolf |
Earlier this week, we learned about how to format esoteric languages for commenting. Today, we're going to do the inverse of that. I need you to write a program or function that parses some well-commented esoteric code and parses the comments out, returning just the code. Using some examples from the previous challenge... | stackexchange_codegolf |
What tips do you have for golfing in (,)? I've found that there are so many ways to make code shorter, and I want more ways. I doubt there even are any tips for (,) that are applicable in the majority of programming languages, but if there are, feel free to include them.
Please, one tip per answer.
| stackexchange_codegolf |
I was seen multiple shortest "Hello World!" program, but this is the longest program.
The Rules
Each submission must be a full program.
This must be non-interpreted language (for example, JavaScript, Python, HTML, etc.)
Target OS must be Windows, Mac, Linux or MS-DOS.
The challenge
Writing a longest Hello World prog... | stackexchange_codegolf |
Summary
The goal of this challenge is to create an undone image-version of a 15-puzzle / sliding puzzle also called taquin in french.
Details:
Given an input composed of:
an image,
an integer n,
an other integer r,
your program, or function, or anything else that fits, must output the same image (i.e. same size and f... | stackexchange_codegolf |
Let's imagine we have a finite set of positive integers. This set can be represented as a line of dots where each integer present in the set is filled in like a scantron or punch card. For example the set {1,3,4,6} could be represented as:
*.**.*
* represents a member of our set and . represents an integer that is n... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Christmas is coming up, and Santa hasn't kept to his diet very well this year. Due to his size, he is getting the elves to collect a list of all the chimneys he will be able to fit down. Unfortunately, chimneys these days are a bit of ... | stackexchange_codegolf |
The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one.
The challenge is to compute the average Levenshtein distance between two independent and uniformly random chosen binary strings of length n each. Your... | stackexchange_codegolf |
Backstory
You own a tiny jewellery shop in the suburbs of the city. The suburbs are too much overpopulated, so your shop has a thickness of only one character to fit in the busy streets.
Recently, there has been lots of cases of robbery on the neighborhood, and you fear that robbers will also come to get your bounty.
T... | stackexchange_codegolf |
Challenge
Given a positive integer \$n\$, count the number of \$n\times n\$ binary matrices (i.e. whose entries are \$0\$ or \$1\$) with exactly two \$1\$'s in each rows and two \$1\$'s in each column.
Here are a few examples of valid matrices for \$n=4\$:
1100 1100 1100
1100 0011 01... | stackexchange_codegolf |
Challenge
Write a program or function that takes in a string s and integer n as parameters. Your program should print (or return) the string when transformed as follows:
Starting in the top-left and moving down and to the right, write s as a wave of height n. Then, from top to bottom, combine each row as a string (with... | stackexchange_codegolf |
Cell Phone Keyboard Typing
This question was asked a while back, but was closed due to poor specs. So, I'm redoing it, with better specs. This question is related, but goes in the opposite direction.
Before T9 came around, in order to type a character in a text message, you had to press one of the number keys a number ... | stackexchange_codegolf |
Write a regex that only matches valid country code top level domains (ccTLDs). Your regex must match both the domains with the dot and without the dot (it must match tv and .tv). Any domain that is not a ccTLD or does not exist (e.g. .info or .jobs or .xz) must not be matched.
Use Perl, POSIX, PCRE or Python.
For refer... | stackexchange_codegolf |
From Codidact with permission.
Description
APL trains are a series of functions, that get applied to an argument in this way:
(f g) x = f g x here f and g are prefix functions
(f g h) x = (f x) g (h x) here f and h are prefix functions, while g is an infix function
(a b c d e f) x = (a (b c (d e f))) x = a (b x) c (d x... | stackexchange_codegolf |
Introduction
In this challenge, I asked you to implement swap encoding.
Swap encoding is an encoding method where you iterate through the string, reversing substrings between identical characters. The basic algorithm is:
For each character in the string:
Check: Does the string contain the character again, after the ins... | stackexchange_codegolf |
What general tips do you have for golfing in dc?
dc is a calculator utility for UNIX/Linux that predates the C language. I am interested in how to make my dc programs (calculations?) shorter. I'm looking for ideas that can be applied to general code-golf that are at least a little bit specific to dc (eg. removing comm... | stackexchange_codegolf |
Challenge
I've checked that there is a question Compute the Discrete Cosine Transform which is a competition for implementing a shortest solution to compute the one dimensional discrete cosine transform.
The goal of this challenge is to implement a program to calculate three dimensional discrete cosine transform which ... | stackexchange_codegolf |
Is there a programming language that supports single tape Turing machines specified in some format?
I am aware multiple formats for expressing them exist, but is there a standard one using which an acceptable answer can be published on this site?
If it doesn't exist can somebody create one? Golfing Turing machines has ... | stackexchange_codegolf |
We are used to the term "squaring" n to mean calculating n2. We are also used to the term "cubing" n to mean n3. That being said, why couldn't we also triangle a number?
How to triangle a number?
First off, let's pick a number, 53716.
Position it in a parallelogram, whose side length equals the number of digits of the... | stackexchange_codegolf |
Challenge
You will be given an input string, anywhere the word "Lemon" is found it should be converted to "Lemonade" but the a, d, and e must be borrowed from somewhere else in the sentence.
Example
Example Input:
I found a lemon when I was a kid
Example Output:
I foun a lemonade whn I was kid
The Lemonade was c... | stackexchange_codegolf |
In a certain chatroom, we like making acronym jokes about the build tool we use called sbt. While it usually stands for "Scala Build Tool", we aim to come up with all sorts of meanings, such as:
Stupid Brick Teeth
Sussy Baka Training
Shady Blue Tourists
Seriously Big Toes
Silly Bear Topics
Salacious Bacon Tripod
Syrin... | stackexchange_codegolf |
This is the cops' thread to a cops-and-robbers challenge. Click the link to find the robbers' thread.
The challenge here is very simple. Create two programs of the same size, in the same language, which output (using 1 standard output method) two different natural numbers, \$x\$ and \$y\$. Submit both programs, bot... | stackexchange_codegolf |
What is the Fibonacci Rectangular Prism Sequence?
The Fibonacci Rectangular Prism Sequence is a sequence derived from the Fibonacci sequence starting with one. The first 3 numbers of the Fibonacci sequence (starting with one) are 1, 1, and 2, so the first number of the Fibonacci Rectangular Prism Sequence is the square... | stackexchange_codegolf |
Most people here are familiar with seven segment displays, which are also used in matchstick puzzles. Below are the digits 0 through 9 and letters a through z, except k,m,t,v,w, written in this format.
_ _ _ _ _ _ _ _
| | | _| _| |_| |_ |_ | |_| |_|
|_| | |_ _| | _... | stackexchange_codegolf |
The simple part: Given an input string containing only printable ASCII-characters (space - tilde), count the number of occurrences of each character and return the result on any convenient format. The result for a string a%hda7a should be something like: a:3, %:1, h:1, 7:1, d:1. Sorting is unnecessary, the delimiters a... | stackexchange_codegolf |
Background
The special linear group \$ SL_2(\mathbb{Z}) \$ is a multiplicative group of \$ 2 \times 2 \$ matrices whose elements are integers and determinant is 1.
It is known that every member of \$ SL_2(\mathbb{Z}) \$ is a product of some sequence of the following two matrices \$ S \$ and \$ T \$ (reference pdf):
$$
... | stackexchange_codegolf |
Introduction
In the prisoner's dilemma, two partners in crime are being interrogated, and have the choice to either betray their partner or stay silent.
If both prisoners betray each other, they both get 2 years in prison.
If neither betrays (both stay silent), they both get 1 year in prison.
If only one betrays and t... | stackexchange_codegolf |
Can you imagine solving the New York Times crossword puzzle without any clues? Maybe not with all of the creativity and new words and phrases appearing in modern crosswords, but with a fixed word list there's some hope. In this challenge, you create a crossword puzzle grid in which this is theoretically possible.
The... | stackexchange_codegolf |
Your goal is to determine whether a given number n is prime in the fewest bytes. But, your code must be a single Python 2 expression on numbers consisting of only
operators
the input variable n
integer constants
parentheses
No loops, no assignments, no built-in functions, only what's listed above. Yes, it's possible... | stackexchange_codegolf |
Intro
Beauty lies in the eye of the beholder. Output lies in the choice of the compiler. There are some codes that give different outputs based on what language they are executed in. Take for instance, the code given below:
# include <stdio.h>
# define print(a) int main(){printf("C is better"); return 0;}
print("Python... | stackexchange_codegolf |
Background
The Hamming weight of an integer is the number of ones in its binary representation. For this challenge, integers are represented with 32 bits, and they are unsigned.
Challenge
Given an integer between 0 and 2^32-1 (non-inclusive), output a different integer within the same range, and also with the same Hamm... | stackexchange_codegolf |
Draw this Ascii coffee cup:
o
o
o
__________
/ \__
| J | \
| A | |
| V | |
| A |__/
\__________/
Brownie points for coffee-script or java :)
Shortest code in bytes, function or program, trailing newline or white space is acceptable, drink up!
| stackexchange_codegolf |
Background
Recognizing primality seems like a poor fit for (artificial) neural networks. However, the universal approximation theorem states that neural networks can approximate any continuous function, so in particular it should be possible to represent any finitely-supported function one desires. So let's try to re... | stackexchange_codegolf |
This is the cops' thread. See the robbers' thread here.
In this cops and robbers challenge, the cops will be tasked with writing an algorithm that computes some function of their choice, while the robbers will try to come up with their algorithm. The catch is, the 'algorithm' must be a single closed-form mathematical e... | stackexchange_codegolf |
Dennis puts in a huge amount of effort for this community, including as moderator, language designer, and provider of TIO.
Unfortunately, his four-year-old daughter has caught a cold, so let us all help him keep track of her recovery (may it be speedy) by providing him with a thermometer:
.-----------.
| |
| ... | stackexchange_codegolf |
I haven't been on PP&CG for a while, so I thought I would post something!
Your task is to find how "smooth" a natural number is. Your method is to:
1: Convert the number to binary
2: Find the number of changes / switches
3: Find the length of the string (in binary)
4: Divide length by changes
So, an example. 5.
Sta... | stackexchange_codegolf |
This is a cops-and-robbers challenge based around defining languages and proving they are Turing complete.
This is the cops' thread. The robbers' thread is here.
Cops
As a cop, you will prepare two things:
A formal specification of a programming language, or other computational system. (Computational systems are defin... | stackexchange_codegolf |
If you've ever learned about primes in math class, you've probably have had to, at one point, determine if a number is prime. You've probably messed up while you were still learning them, for example, mistaking 39 for a prime. Well, not to worry, as 39 is a semiprime, i.e., that it is the product of two primes.
Similar... | stackexchange_codegolf |
Generate \$T=\{T_1,...,T_x\}\$, the minimum number of \$k\$-length subsets of \$\{1,...,n\}\$ such that every \$v\$-length subset of \$\{1,...,n\}\$ is a subset of some set in \$T\$
Here, \$n > k > v\$ and \$v \ge 2\$
Any number can appear only once in 1 set
Order of numbers is not important
Answer with code & explan... | stackexchange_codegolf |
Infix notation is a method of printing mathematical expressions where each operator sits between its two arguments, such as \$ \left(5 \cdot 4\right) + 3 \$.
Prefix notation is a method of printing expressions where operators sit before their arguments. The equivalent of the above is +*543. It's a bit harder to underst... | stackexchange_codegolf |
Happy New Year 2024!
2024 is a tetrahedral number. A tetrahedral number is a number that can be represented in the form \$n(n+1)(n+2)/6\$ for some positive integer \$n\$. Or, equivalently, they are the sum of the first \$n\$ triangular numbers. They are also the number of objects in a triangular pyramid which has \$n\$... | stackexchange_codegolf |
Given a BF program consisting of only the characters +-[]<>., with the property that there's an equal number of < and > between every matching pair of [].
You have to find the shortest program that can be achieved with the optimal memory layout (by rearranging the cells on the tape).
If there are multiple such programs... | stackexchange_codegolf |
Write a program or function that takes in a positive integer N and outputs the first N numbers of this amplifying zigzag pattern, using only the lines needed:
26
25 27 .
10 ... | stackexchange_codegolf |
In this challenge, you implement an interpreter for a simple stack-based programming language. Your language must provide the following instructions:
push a positive number
pop two numbers and push their sum
pop two numbers and push their difference (second number - first number)
pop a number and push it twice (dup)
p... | stackexchange_codegolf |
Challenge:
Given an array of non-negative whole numbers numbers in the range of 0 to Infinity, Check whether all of them are primes or not. (You can take input as a string too if you want)
Input:
Input: An array of numbers
Output: The array with every element replaced by one of these:
-1 -----> If 0, 1
... | stackexchange_codegolf |
Martin Ender recently hit 100K, and has come up with some pretty awesome languages. We're going to have a bit of fun with one of them, Hexagony (and a bit of regex for Retina)
As a brief overview, you need to write a program that inputs a Hexagony grid and determines if there is a path on that grid that matches a stri... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.