instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Leaderboard
154 Calculator
144 Taxman
138 Statistician
137 Solver
137 RandoAggroLawyer
136 Gambler
134 Turncoat
119 Lawyer
119 BloodyMurder
113 Bandit
79 Challenger
74 Mask
64 Random
An archive of the latest match, including the log and all output files, is available.
Calculator, by Brilli... | stackexchange_codegolf |
You may be aware of the famous old rhyme, "I before E, except after C". It is a rule taught to aid in the spelling of certain English words.
Quoting Wikipedia:
If one is not sure whether a word is spelled with the digraph ei or ie, the rhyme suggests that the correct order is ie unless the preceding letter is c, in wh... | stackexchange_codegolf |
The challenge is to golf a program that checks if a statement of propositional calculus/logic is a logical tautology (i.e. it is true for all possible values of the variables).
Input
Input formulas will use P, P', P'' ect. as variables. They can either be true or false.
(P and P') means both P and P' are true.
(P or P'... | stackexchange_codegolf |
Inclusion-Exclusion lets you calculate the sizes of some unions and intersections between sets knowing some of the other values. I won't explain it exactly, but your challenge is to visualize inclusion-exclusion on a Venn Diagram.
Because I'm nice, you'll be using rectangles, not circles.
You will be given a list of re... | stackexchange_codegolf |
Don't tell anyone, but I've nicked my uncle's time travel machine! My uncle is obsessed with prime numbers, though, and that shows in the machine — he has programmed it so that it can only go to dates that sum up to a prime number.
So it can't go to 1947-08-15 because 1947+8+15 = 1970, which is not a prime number. It ... | 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 |
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 |
Problem adapted from the book Fortran 77 by Donald M. Monro
Introduction
Digital plotting machines are widely used to produce various forms of drawings, graphs and other pictorial results. Most such machines can move their pens only in certain directions, usually as single steps in the X and Y direction or both. A typi... | stackexchange_codegolf |
The challenge
Interpret the stack-based programming language underload.
The stack is a stack of strings that can be concatenated together.
Each underload program is a string of some of these instructions:
~: Swap the top two elements of the stack.
:: Duplicate the top element of the stack.
!: Discard the top element o... | stackexchange_codegolf |
This challenge was originally sandboxed by Magic Octopus Urn; I adopted and posted it with his permission.
This is the cops' thread. The robbers' thread is here.
The challenge
Step One: Write a piece of code (function or full program) which checks for primality.
Step Two: Remove pieces of your code by replacing charac... | stackexchange_codegolf |
While I was traveling in the future, I noticed a funny game among kids circa 2275. When they don't want their great-great-great-great-grand parents to understand what they're saying, they use the BIBABOBU speak. Obviously, I couldn't understand anything either with my pre-cyborg era brain and I felt (or technically: I ... | stackexchange_codegolf |
Ken Iverson, 1920–2020
Let's implement his favourite expression:
Given a row of Pascal's triangle, compute the next row.
This can for example be computed by taking the input padded with a zero on the left, and the input padded with a zero on the right, and then adding the two element-by-element.
Test cases... | stackexchange_codegolf |
You are given a \$3\times3\$ square matrix where each cell is any digit between \$0\$ and \$9\$ except \$7\$. Your task is to figure out the minimum number of digits that must be replaced with \$7\$'s so that the sums of the digits in each row and each column are the same.
NB: There is no constraint whatsoever on the d... | stackexchange_codegolf |
Robbers thread
Cops,
Choose two strings of code, one public and one secret. We will call them P and S. You will be writing a program using only repetitions of these strings.
For example: if you choose P=helloand S=world, valid programs would be hello, world, helloworld, worldhello, helloworldworldhello, hellohellohello... | stackexchange_codegolf |
Chebyshev Polynomials are a family of orthogonal polynomials that pop up in all kinds of places in math, and they have a lot of quite interesting properties. One characterization of them is that they are the unique polynomials that satisfy \$T_n(\cos(x)) = \cos(nx)\$.
Challenge
Given an nonnegative integer \$n\$, you s... | stackexchange_codegolf |
Your code may not contain the letter "e", but must count the number of "e"s in the inputted string and output that as a number. Bonus points if you use a language that is not a codegolf language and a language that actually uses the letter e (unlike brainfuck) --- not a required criteria.
| stackexchange_codegolf |
BLC (Binary Lambda Calculus) is a binary encoding of untyped lambda calculus which was created to “provide a very simple and elegant concrete definition of descriptional complexity.”
What are some tips on how to golf down BLC programs/functions?
Please submit only one tip per answer!
| stackexchange_codegolf |
This is the cops' thread. The robbers' thread is here.
Your challenge is to write a program or function that, with a certain input, prints the exact string Hello, World! and a newline. Capitalization, spacing and punctuation must be exact.
Input may be taken via standard input, a file, or command-line/function argument... | stackexchange_codegolf |
The basis vectors for geometric algebra are
$$(e_0=1), e_1, e_2,\dots,e_n$$
They all square to 1 (we do not consider vectors which square to -1 or zero)
$$e_i \cdot e_i = 1$$
They are associative and anticommutative (except \$e_0=1\$ which is associative and commutative)
$$e_i \cdot e_j =-e_j \cdot e_i \: \; (i\neq j);... | stackexchange_codegolf |
Tangentially inspired by the opening to the What-If book.
The input is a rectangle of spaces as a string, list of string, etc., with objects made of #'s inside:
########
# #
########
### ####
### ####
###
The objects will always be non-intersectin... | stackexchange_codegolf |
Description
There are an infinite number of ASCII strings. Write a program that will output every possible ASCII string exactly once.
The ordering does not matter, but you must be able to show that for any possible ASCII string s, there exists an integer n such that s is the nth string in the output. This restriction m... | stackexchange_codegolf |
Presumably everybody here knows that for the legacy BIOS, the tiniest bootable disk image is 512 bytes (the lower bound is due to the 2-byte magic at offset 510), and there is a bootsector demoscene where people try to fit the entire demo into the 510 bytes of usable space.
Now that the BIOS is being superseded by UEFI... | stackexchange_codegolf |
Given π to an arbitrary number of places, your challenge is to locate indices of π where the index (1,2,3,4...) and the string of numbers from that index carry the same value for the length of the index.
That sounds complex, so let's look at an example!
Indices will count from +1 upwards through natural whole integers,... | stackexchange_codegolf |
Last year, there was a very popular challenge to create an image containing every 24-bit RGB colour.
My challenge is to create a smooth animation (24 frames/s say), where the colour of every pixel of every frame is unique. I will also allow duplication of colours as long as every colour appears the same number of time... | stackexchange_codegolf |
Definition
\$a(1) = 1\$
\$a(2) = 2\$
\$a(n)\$ is smallest number \$k>a(n-1)\$ which avoids any 3-term arithmetic progression in \$a(1), a(2), ..., a(n-1), k\$.
In other words, \$a(n)\$ is the smallest number \$k>a(n-1)\$ such that there does not exist \$x, y\$ where \$0<x<y<n\$ and \$a(y)-a(x) = k-a(y)\$.
Worked out ... | stackexchange_codegolf |
Print all the numbers from 0-100 in the right order using the Danish way of counting
How they count
Like English, they have dedicated words for 0-20, 30, 40 and 100
Instead of saying twenty-one and twenty-two, they say one and twenty and two and twenty
Starting with fifty they say multiples of 10 as n*20
50 = half thi... | stackexchange_codegolf |
The task
Most Casio calculators featured a variable M, which has 3 operators related to it: M, M+, and M-
M, as you can expect, returns the value stored in the variable.
M+ takes the number on the left and add it to M.
M- does the same thing as M+, but subtract instead.
To make the challenge just a bit more difficult, ... | stackexchange_codegolf |
We've had a lot of quine challenges, but a lot of the quine formats are similar, lets create some variance in our quines.
Your task is to create a selection of programs in the same language (at least 2), all of which output their own source code, however, none of these programs can share any characters.
For example, if... | stackexchange_codegolf |
Code Golf Challenge
Given a string of 10 characters:
'abcdefghij'
I want to format it in this pattern and print it in the console in a minimum number of characters:
(abc) def-ghij
My solution:
print(f"({s[0:3]}) {s[3:6]}-{s[6::]}")
| stackexchange_codegolf |
Recently, when doing some code-golf challenge, I came up with with two solutions, in 69 and 105 bytes. It's a remarkable coincidence, because:
69 (decimal) = 105 (octal)
69 (hexadecimal) = 105 (decimal)
What other numbers have this property (using different bases)? You should help me answer this question!
Write a pro... | stackexchange_codegolf |
I need a UUID. Your job is to generate one.
The canonical UUID (Universally Unique IDentifier) is a 32 digit hexadecimal number with hyphens inserted in certain points.The program should output 32 hex digits (128 bits), in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12 digits), where x is a random hexadec... | stackexchange_codegolf |
Because ARM is the July 2021 LoTM, I figured I'd create the tips thread.
ARM is probably the most successful architecture for the digital world. From mobile phones to supercomputers, ARM is everywhere! Consequently, let's have a thread where we can help each other shorten our ARM code.
One tip per answer, and no stupid... | stackexchange_codegolf |
Given a strictly positive integer, N, produce an output satisfying the following:
Produce an array of length N.
Every string (i.e. "word") in the array is of length N.
Every letter in the word is unique.
Every first letter of the words are unique between each other.
The remaining items of each word are equal to each o... | stackexchange_codegolf |
A prime number is a positive integer that has exactly two divisors 1 and the number itself. For example number 7 is a prime since it is divisible by 1 and 7. Number 1 is not a prime since it has only one divisor. Write a program or function that produces all even prime numbers.
This is a code golf challenge, shortest a... | stackexchange_codegolf |
I remember this was exam question long long long time ago.
There is a file say MyFile.txt, it can be any size and contains aphanumeric only
your task is to revese the words
example : "Go beyond the traditional laptop with Surface Laptop. It's backed by the best of Microsoft, including Windows and Office"
It should be "... | stackexchange_codegolf |
Background
You may be aware that periods in between letters in gmail addresses are ignored. Email sent to example@gmail.com, exam.ple@gmail.com, and e.x.a.m.p.l.e@gmail.com all end up in the same place!
This is a great way to have multiple different emails addresses for things like signing up for free trails, or filter... | stackexchange_codegolf |
About Hangul
As I'm Korean, I'm really proud of Korean character, Hangul(한글).
Hangul is a syllabary invented by King Sejong the great, 4th king of Joseon dynasty, in 1443.
Because today (October 9th) is Hangul day in Korea, I'll give you a challenge: Make some Hangul ascii-art
List of characters
So, To make ASCII art, ... | stackexchange_codegolf |
What general tips do you have for golfing in MathGolf? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to MathGolf (for tips which can be applied to loads of programming languages, look at the general tips).
| stackexchange_codegolf |
This expression actually has an omitted pair of parentheses.
1 + 2 * 3
To make things clear, it should be,
1 + (2 * 3)
Even this has its parentheses missing.
1 + 2 + 3
It actually means,
(1 + 2) + 3
People often assume left-to-right evaluation to such an arithmetic expression, but I want to make everything very cle... | stackexchange_codegolf |
A very simple challenge today. Output a truthy value whether the ASCII character (or it's code) supplied is a brainfuck instruction (one of +-,.<>[]), and a falsy value if it's a comment (everything else).
Input
+
#
<
>
.
P
,
Output
true
false
true
true
true
false
true
| stackexchange_codegolf |
There already is a Brainfuck interpreter question, but it is from 2011 and not up to date with current site standards and vague in places. I have proposed reposting this in chat, and it was well-received. Here goes.
Objective
Given the Brainfuck code and the program's input as input, run the Brainfuck code. As there ar... | stackexchange_codegolf |
I am sorry for the very long description. But i think some information of how /proc/self/cmdline works and how it can be used to get a integer input was necessary.
You may skip the sections you don't need.
While part of this task is related to C and Linux, it can be done in any almost language that can start other prog... | stackexchange_codegolf |
Rules:
Your program must print "hello world" when executed
Your program must be interpretable or compilable into 2 or more languages
Your program must require no input or arguments
Languages with identical syntax are too easy, and will be shunned. We all know you can write echo hello world in Bash and Batch, so let's ... | stackexchange_codegolf |
Given a string, character list, byte stream, sequence… which is both valid UTF-8 and valid Windows-1252 (most languages will probably want to take a normal UTF-8 string), convert it from (that is, pretend it is) Windows-1252 to UTF-8.
Walked-through example
The UTF-8 string
I ♥ U T F - 8
is represente... | stackexchange_codegolf |
Task
Given a matrix, your program/function should output a row-equivalent matrix in checkerboard form ( \$A_{ij}=0\$ if and only if \$i+j\$ is odd).
Two matrices are defined to be row-equivalent if and only if one can be obtained from the other by a sequence of elementary row operations (EROs), where each ERO consists ... | stackexchange_codegolf |
Try to create a simple ASCII art scissors animation!
Challenge
All inputs will be integers -31 through 31.
The output will be an animation (To be outputted somewhere, as long as the previous frame is replaced. GIFs are allowed.), separated by (approximately) 1 quarter of a second.
If the input (n) is positive:
The ani... | stackexchange_codegolf |
Einstein wrote a riddle. He said that 98% of the world could not solve it.
I solved this riddle in about 25 minutes while on the train to work.
It's basically just deduction.
The riddle
There are 5 houses in 5 different colors in a row.
In each house lives a person with a different nationality.
The 5 owners drink a ce... | stackexchange_codegolf |
Given a positive integer n, output the 2^n binary sequences of length n sorted in the following precise ordering.
Test cases:
0:
0 or 1 (defining this is a matter of debate)
1:
0
1
2:
00
01
10
11
3:
000
001
010
100
011
101
110
111
4:
0000
0001
0010
0100
1000
0011
0101
1001
0110
1010
1100
0111
1011
1101
1110
1111
e... | stackexchange_codegolf |
Challenge
Given a whole number divisible by 9 and one missing digit, find the missing digit.
The missing digit may be represented by any character other than the digits 0-9 as long as it is consistent.
If the missing digit could be 0 or 9, output something to signify so.
Assume the user is intelligent enough to put onl... | stackexchange_codegolf |
Anyone got tips for golfing in Thue. One tip per answer, and no tips aplicable to all languages (like remove comments)
| stackexchange_codegolf |
As the title says, your task is to print the largest string using the shortest code without taking any input value.
Rules
The program must take no input and print the largest string to STDOUT
The string must contain only ASCII Characters. If you don't know the ASCII Characters, take a look at the table
No Loops are a... | stackexchange_codegolf |
The task:
You have to input 2 numbers and output the results of several operations done with them.
Details:
Input 2 floating point numbers, x != 0 and y != 0 via stdin, command line or function arguments.
Output x+y,
x*y,
x^y (pow(x,y), not x XOR y),
x-y,
y-x,
x/y and
y/x on ST... | stackexchange_codegolf |
Fastest code is a scoring method on this site where the goal is to write code that is as fast as possible.
From the tag wiki:
The winner of a fastest-code challenge is determined by the runtime performance of the submissions. For fairness, all submissions should be benchmarked on the same machine, which usually means ... | stackexchange_codegolf |
This is the Robbers thread. For the Cops challenge, see here
As the robbers, your job is to crack the cops' answers. Choose an uncracked, unsafe cop answer and attempt to figure out which languages, in which order, the cop used.
Note that a crack is valid even if the languages are different. So long as the the language... | stackexchange_codegolf |
Schlosberg Numbers
In issue 5 of Mathematical Reflections, Dorin Andrica proposed the problem of characterising the positive integers n such that is an even integer. Eight people submitted correct solutions showing that these are the integers n for which is even. The published solution was by Joel Schlosberg, so I c... | stackexchange_codegolf |
Background
The monkeys need your help again organizing their defense and have asked you, Benjamin the code monkey, to create a program that will list all tower upgrade options as they appear in your insta-monkey collection. Each tower has three unique upgrade "paths", called "top", "middle", and "bottom", each having a... | stackexchange_codegolf |
Introduction
The game Minecraft has a 1 in 10000 chance of showing "Minceraft" instead of "Minecraft" on the title screen.
Your challenge
Your challenge is to code a function or program that takes no input, and on average 1 of 10000 times, returns "Minceraft" and the rest of the time returns "Minecraft".
Scoring
This i... | stackexchange_codegolf |
My mom really wants me to eat broccoli, but I hate it and never want to eat it. Mom wants to trick me so she cuts it into small pieces, puts it in a salad and mixes it. Help me find out if the salad contains broccoli!
Input:
Array of mixed letters of all the ingredients. For a single broccoli ingredient it could be:
[c... | stackexchange_codegolf |
For loops are used extensively in many languages, but what would you do if no languages supported them?
Create a way to execute a basic for loop without using any repetition structures (for, foreach, while, do, etc).
The basic for loop that you need to replicate is set up like this
for(i=0;i<1000;i++)
You must be able... | stackexchange_codegolf |
Challenge
Create a new file and write the string Hello World to it.
Restrictions
Your challenge must write to a file on disk, in the file system.
The file may not be a log file generated during normal operation of the interpreter.
The file must contain only the string Hello World. It is allowed to contain a trailing n... | stackexchange_codegolf |
The other day, our team went to an escape room. One of the puzzles involved a board of six mechanical switches where you had to find the correct combination of on and off in order to unlock a box, somewhat like this:
-v-v-v-
-v-v-v-
Being developers, we decided it would be more efficient to try every single one of 2^6... | stackexchange_codegolf |
An Armstrong number (AKA Plus Perfect number, or narcissistic number) is a number which is equal to its sum of n-th power of the digits, where n is the number of digits of the number.
For example, 153 has 3 digits, and 153 = 1^3 + 5^3 + 3^3, so 153 is an Armstrong number.
For example, 8208 has 4 digits, and 8208 = 8^4 ... | stackexchange_codegolf |
Consider the equation $$\frac x {y+z} + \frac y {x+z} + \frac z {x+y} = n$$ for positive integers \$x, y, z\$ and \$n \ge 4\$. Your code will receive \$n\$ as an input, and output three integers \$x, y\$ and \$z\$ such that the equation holds. You may assume that a solution always exists.
Background
This equation is a ... | stackexchange_codegolf |
A binary max heap is a rooted tree with integer labeled nodes such that:
No node has more than 2 children.
The label of every node is greater than all of its children.
We say a sequence of integers is heapable if there exists a binary max heap, whose labels are the sequence's elements, such that if \$p\$ is the paren... | stackexchange_codegolf |
It looks like a fun language, but the official site is down and the EsoLangs page doesn't explain it quite well and looks like it's missing stuff. Is there anywhere that the language is documented?
| stackexchange_codegolf |
Introduction
A bell tower will ring its bells every hour, n times, with n being the the current hour on a 12 hour clock.
For example, a bell will ring 5 times at 5pm, and 10 times at 10am.
Task
Given two times in a suitable format, output the number of times the bell will ring, inclusive of the start and end times
Exam... | stackexchange_codegolf |
In some languages, strings are started and ended with a quote mark ('). And quote itself is escaped by writing it twice sequentially. For example, empty string is written as '', and I'm is written as 'I''m'.
This question is about find out all non-overlapping strings from left to right in such format from the given inp... | stackexchange_codegolf |
Output either the text below, or a list of lists of integers (more details below).
0
10 1
20 11 2
30 21 12 3
40 31 22 13 4
50 41 32 23 14 5
60 51 42 33 24 15 6
70 61 52 43 34 25 16 7
80 71 62 53 44 35 26 17 8
90 81 72 63 54 45 36 27 18 9
91 82 73 64 55 46 37 28 19
92 83 74 65 56 47 38 29
93 84 75 66 57 48 39
... | stackexchange_codegolf |
In 2014, demoscener Jakub 'Ilmenit' Debski released a 250-byte(1) procedural graphics demo for the Atari XL called Mona. It's drawing the following picture(2):
Your task is to generate the exact same picture, using the language of your choice.
(1) Breakdown: 136 bytes of data + 114 bytes of code.
(2) The original pic... | stackexchange_codegolf |
Given a non-empty matrix of non-negative integers, answer which unique rows contribute most to the sum total of elements in the matrix.
Answer by any reasonable indication, for example a mask of the unique rows order of appearance (or sort order), or indices (zero- or one- based) of those, or a submatrix consisting of ... | stackexchange_codegolf |
Write a function (using as few bytes as possible) that takes a bi-dimensional array of any number of columns and rows in which:
0 represents empty block,
1 represents snake block.
The function must return the number of possible paths the snake traveled.
Example 1:
Input:
[
[1,1,1,1,1],
[0,0,0,0,1],
[0,0,0,0,1... | stackexchange_codegolf |
Remove all repeating words from an inputted sentence.
Input will be something like cat dog cat dog bird dog Snake snake Snake and the output should be cat dog bird Snake snake. There will always be a single space separating words.
Output order must be the same as input. (Refer to the example)
You don't need to handle p... | stackexchange_codegolf |
Because it's Saturday (UTC) and I'm hungry, I would like a slice of pizza. I will give you an order and I would like a nice hot ascii-art pizza. Up to the challenge?
The Drive-Thru
I'll place my order wherever your drive-thru is, whether it is STDIN, a function parameter, a command-line argument, but I'm not going to p... | stackexchange_codegolf |
A digit addition generator of an integer n is any integer x that satisfy the equation x + s(x) = n, with s(x) being the sum of the digits of x. (We will work under base 10 for convenience.)
For example, a digit addition generator for 29 would be 19, because 19 + (1 + 9) = 29. Some numbers have more than one generator. ... | stackexchange_codegolf |
There is a question to basically find the largest sum in an array, such that no two elements are chosen adjacent to each other. The concept is to recursively calculate the sum, while considering and not considering every element, and skipping an element depending on whether the previous element was selected or not.
I u... | stackexchange_codegolf |
Given a list of non-negative integers the function \$f\$ replaces every integer with the number of identical integers preceding it (not necessarily contiguously). So
f [1,1,2,2,1,3,3] = [1,2,1,2,3,1,2]
We will say that a list, \$X\$, is in a loop if there is some positive integer \$n\$ such that \$f^n X = X\$. That i... | stackexchange_codegolf |
Write a program to generate a rectangular word-search of size 6x9. Words may go downwards, rightwards and diagonally (downwards and to the right), they may also overlap on the board.
The challenge is to include as many different English words as possible from https://www.ef.co.uk/english-resources/english-vocabulary/to... | stackexchange_codegolf |
A Bit of Background
The exterior algebra is a central object in topology and physics (for the physics concept cf. fermion). The basic rule dictating the behavior of the exterior algebra is that \$yx = -xy\$ (and consequently \$x^2 = -x^2 = 0\$). Applying this rule twice we see that \$yzx = -yxz = xyz\$.
The product of... | stackexchange_codegolf |
An alphadrome is a word in which each letter in the first half of the word "reflects" its alphabetical "opposite" in the second half of the word. Write a program or function that returns truthy if the given word is an alphadrome and falsey otherwise.
For example, BEEB is a palindrome. Its first letter B "reflects" its ... | stackexchange_codegolf |
For this challenge, a list is considered valid if and only if it consists entirely of integers and valid lists (recursive definitions \o/). For this challenge, given a valid list and an integer, return a list of all depths at which the integer can be found.
Example
Let's consider list [1, [2, [3, [1, 2, 3], 4], 1], 1] ... | stackexchange_codegolf |
Adapted from the UIL - Computer Science Programming free response question "Carla" for 2018 District.
Introduction
In UNIX-like operating systems, each file, directory, or link is "owned" by a "user", who is a member of a "group", and has certain "permissions" represented by a ten-character string such as "drwxrwxrwx".... | stackexchange_codegolf |
Background
With the success of Simple Boolean Algebra Calculator, I present a more difficult problem.
Boolean Algebra concerns representing values with letters and simplifying expressions. The following is a chart for the standard notation used:
Above is what actual boolean algebra looks like. For the purposes of this... | stackexchange_codegolf |
Challenge:
Create a program that accepts a positive integer and checks if it can be written in the form of (3^x)-1, where X is another positive integer.
If it can, output X
If it can't, output -1 or a falsy statement.
Example inputs/outputs
Input:
2
It can be written as (3^1) - 1, so we output x which is 1
Output:
1
... | stackexchange_codegolf |
Prelude:
This challenge is different from "another cat program".
There's literal tons of different twists, why can't I have my own, people?
Unique things:
It isn't reading direct input to output.
It is manipulating the string in a way that for sure isn't a straight-up cat.
Challenge:
Given 3 inputs (or one input, s... | stackexchange_codegolf |
You have a box with a single digit number in each corner:
1|2
---
3|4
If we concatenate the digits along rows left to right, we get 12 and 34. If we concatenate the digits along columns top to bottom, we get 13 and 24. If we add all of these numbers, we get 12+34+13+24 = 83.
Challenge
Write a program to print all such... | stackexchange_codegolf |
Imagine a very simple language. It has just 2 syntax features: () indicates a block scope, and any word consisting only of 1 or more lower case ASCII letters, which indicates a identifier. There are no keywords.
In this language, the value of identifiers is not important except when they appear multiple times. Thus for... | stackexchange_codegolf |
This is a cops-and-robbers challenge the Cops' Thread can be found here
Your challenge, as robbers is to take outputs from the cops' thread and find anagrams of the output that when run as a program output the original output provided.
The winner will be the person with the most valid cracks on this question.
Rules
Yo... | stackexchange_codegolf |
Challenge: Implement incrementation without addition, multiplication, exponentiation, and any higher binary operators (and their opposites) in Python.
Winner is the person who can do it in the least amount of code. You score 5 characters less if you can do it for negative numbers and without unary operators.
| stackexchange_codegolf |
I hate hashes because they remind me of hashtags, help me find them in the input
Input
A piece of text
This is an #example text,
#designed for demo #purposes,
#to demonstrate the challenge.#
You may add a optional newline character at the end of the input if your program requires this
You may assume that there will ... | stackexchange_codegolf |
Make a cat program, with a catch. The program must refuse under all circumstances to output "Hello World", instead outputting "Goodbye World", with matching spacing (but matching casing is not required).
"Hello World" must never appear as a substring of the output, regardless of casing, not even if the two words are (o... | stackexchange_codegolf |
You have to make something that takes in one input from a default I/O method (as an integer), and prints out the sum of all the permutations of that number (not necessarily unique)
For example:
10 would return 11 because 10 can have 2 permutations (10 and 01), and the sum of those two numbers would be 11
202 would have... | stackexchange_codegolf |
The Challenge
Write a program that can take an input of a single-line string containing any ASCII printable characters, and output the same string encoded in Base85 (using a big-endian convention). You can assume that the input will always be ≤ 100 characters.
A Guide to Base85
Four octets are encoded into (usually) ... | stackexchange_codegolf |
Given a 24 hour time, e.g. 20:48, output the nearest time where each adjacent pair of digits has an absolute difference of 1, e.g. 21:01.
That is, each number in the output must differ from the numbers next to it by 1, and the output must be the closest time, forwards or backwards, for which this is true. Time can be c... | stackexchange_codegolf |
It is the year MDLXVII in a world in which the Roman Empire never fell, and the collapse into the dark ages never occurred. Due to the extended period of Pax Romana, the empire's economic stability enabled technology to progress at a rapid rate.
The Romans have begun to dabble with circuitry, and have invented an inge... | stackexchange_codegolf |
Imagine a grid where the origin square \$(0,0)\$ is at the top left of the screen, and positive \$x\$ is rightwards whereas positive \$y\$ is downwards. Coloured squares are at various positions on the grid.
In a magical void separate from the grid are multiple snake-like strips of squares, each of a fixed length and a... | stackexchange_codegolf |
Taken from: OEIS-A071816
Your task, given an upper bound of n, is to find the number of solutions that satisfy the equation:
a+b+c = x+y+z, where 0 <= a,b,c,x,y,z < n
The sequence starts out as described on the OEIS page, and as below (1-indexed):
1, 20, 141, 580, 1751, 4332, 9331, 18152, 32661, 55252, 88913, 137292, ... | stackexchange_codegolf |
Challenge
In this challenge, the input will be an ordered set of numbers and the program should be able to tell if the set of numbers is an Arithmetic Sequence.
Input
The input will be a list separated by ,(comma) or , (comma+space).
The minimum length of the list should be 3 elements.
Output
The Output can be a Boo... | stackexchange_codegolf |
You are Odysseus, and are finally free from Calypso (who has kept you captive for many years) after you drugged her while she was sleeping1. You wish to return to your homeland of Ithaca, but the ship you've stolen is a bit damaged and cannot steer. However, you have also stolen a map which contains the location of Cal... | stackexchange_codegolf |
Write a program/function that takes two integers in the range \$0\$ to \$255\$ inclusive, and returns whether the binary forms of the numbers are exactly one bit different.
For example, \$1\$ and \$0\$ have binary forms 00000001 and 00000000, which are one bit apart. Similarly, \$152\$ and \$24\$ are 010011000 and 000... | stackexchange_codegolf |
Given a string and a substring and a positive integer n.
Remove the n occurences of a substring from the end of the originally given string. If the substring is not present in the string or the number of times the substring appears is less than n, then the output is the original string. No space should be present in pl... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.