instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Given two positive reals \$a\$ and \$b\$, output some positive reals \$r_i\$, such that \$\sum r_i=a\$ and \$\prod\left(r_i+1\right)=b\$. You can assume that it's possible. You can also assume that your float type have infinite precision.
Test cases:
2,3 => 2
2,4 => 1,1 or 1/2,(sqrt(57)+9)/12,(9-sqrt(57))/12 or etc.
2,... | stackexchange_codegolf |
(2 Jan 2018) Because of the winning criteria I am going to accept the Jelly answer, but I am also giving upvotes to all other answers which all use astounding methods as well
Introduction
There are lots of challenges asking for a shortest program to calculate mathematical constants. I saw some with restrictions like ba... | stackexchange_codegolf |
As someone who can't be bothered to look at their pentominos to see if it makes a rectangular shape, I've decided to make you write a program that does it.
Your task
Given some input split by newlines containing 12 unique characters, decide if it is a valid solution.
A valid solution MUST
Have 5 of each character (exc... | stackexchange_codegolf |
I'm sure most of us have heard of zip bombs and similar decompression bomb tricks, where a maliciously crafted input creates a massively disproportionate output. We even had a question on here to do that to a compiler at one point.
Well, it occurs to me that Markdown is a compression format of sorts, replacing bulky H... | stackexchange_codegolf |
Create a cat program, a.k.a a program that takes an input and prints it.
...Except, the program will randomly take characters away from your input and print that instead.
Each character in the input should have generally equal odds to be removed with the program, though, as it is hard to make that, the odds for each ch... | stackexchange_codegolf |
The primorial \$p_n\#\$ is the product of the first \$n\$ primes. The sequence begins \$2, 6, 30, 210, 2310\$.
A Fortunate number, \$F_n\$, is the smallest integer \$m > 1\$ such that \$p_n\# + m\$ is prime. For example \$F_7 = 19\$ as:
$$p_7\# = 2\times3\times5\times7\times11\times13\times17 = 510510$$
Adding each num... | stackexchange_codegolf |
The input message consists of ASCII characters
The encoded output message consists of blocks of 0
A block is separated from another block by a space
Two consecutive blocks are used to produce a series of same value bits (only 1s or 0s):
After the ACSII character(s) have been converted to binary, go through the string:
... | stackexchange_codegolf |
I haven't. :P So I decided to define one:
A tralindrome is a string which contains three equal-length sections X, Y, Z such that
all characters in the string are included in at least one of the three sections,
X starts at the first character, Y starts at or right after the last character of X, and Z starts at or right... | stackexchange_codegolf |
Your challenge is to read a "password" from the keyboard / standard input.
Challenge:
Read a string s invisibly.
For each of the characters in s, print a character c.
In realtime.
Rules:
You must print c in realtime. As soon as the user enters a character you must display c.
c must be constant, i.e. it must be the s... | stackexchange_codegolf |
Everyone knows log scales are for quitters. Therefore, you must write a program or function that de-quitifies a bar graph with a log scale given a base.
The bar graph input is taken as a single string which is a list of bars, where each bar of the log scale bar graph is separated by the printable (or whitespace) delimi... | stackexchange_codegolf |
You know what a palindrome, a prime and a date are.
Your task is to list all dates in 100 thousands of years that fulfill
all three characteristics.
Nevermind anything but the numbers, use the following formats: YYYYMMDD and YYYYYMMDD.
Dates between 0000-01-01 and 9999-12-31 should be printed as 8 digit palindrome... | stackexchange_codegolf |
Write a quine which attempts to invert the case of as many ascii characters in the source code as possible. For example in javascript:
(x=function(y){return ('(x='+y+')(x)').toUpperCase();})(x)
Standard quine rules apply.
The score is given by number of bytes in the source code - number of case inversions. For examp... | stackexchange_codegolf |
99 Varieties of Dosa is a popular chain of roadside dosa stalls across South India. This is inspired by a combination of this chain and the classic CodeGolf challenge "99 Bottles of Beer".
Recreate the variant of the menu of the popular '99 Varieties of Dosa' listed below.
(Note: Despite the name, the list contains 10... | stackexchange_codegolf |
While writing my essay for Shakespeare, I realized that I needed to shorten my quote references to more manageable lengths. I had previously been writing this:
(Act 1, Scene 2, Lines 345-346)
But I've now been told to write them like this:
(I.ii.345-6)
Clearly, I need some golfed code to golf my Shakespeare quote ref... | stackexchange_codegolf |
Background: the Ramsey number \$R(r,s)\$ gives the minimum number of vertices \$v\$ in the complete graph \$K_v\$ such that a red/blue edge coloring of \$K_v\$ has at least one red \$K_r\$ or one blue \$K_s\$. Bounds for larger \$r, s\$ are very difficult to establish.
Your task is to output the number \$R(r,s)\$ for ... | stackexchange_codegolf |
Challenge
Unlike the circumference of a circle (which is as simple as \$2\pi r\$), the circumference (arc length) of an ellipse is hard.
Given the semi-major axis \$a\$ and semi-minor axis \$b\$ of an ellipse (see the image below, from Wikipedia), calculate its circumference.
By definition, you can assume \$0 < b \le a... | stackexchange_codegolf |
Inspired and looted from this dice challenge by Arnauld
Input
You are given a 5x1 or 1x5 (your choice) dice matrix which consist of binary 3x3 sub-matrices.
Goal
Given a valid dice matrix, you are to score it using the rules of 6,5,4 which are as follows:
If the roll contains 6,5,4, add the other two dice together and... | stackexchange_codegolf |
Given a side-view of a mini-golf course and the power of the swing, determine if the ball will make it into the hole.
A course will be in this format:
____ ____ _
__/ \ / U \
__/ \ / \_
\_/
The ball starts directly before the first piece of ground o... | stackexchange_codegolf |
Given a string containing some parentheses and some other ASCII printable characters, like this: (abc((123))(k)) your task is to remove any sets of parentheses that are redundant.
A set of parentheses is redundant if:
It encloses another set of matching parentheses, like ab((123)), or
It encloses the entire string, li... | stackexchange_codegolf |
Preamble
We've already proven we're good at adding two numbers, but many solutions only operate on tiny numbers like 2³²-1, honestly we can do a lot better.
The Challenge
Given two unsigned, non-negative integers, add them together and return the output.
Input may be taken in any convenient format (String, Array of byt... | stackexchange_codegolf |
Setting the Scene:
It is an average afternoon, as you unwind after a long day by engaging in your favorite pastime: answering the plethora of captivating questions on PPCG. It hasn't been a good day for you; those damned Pyth programmers keep getting best answer and it's killing your vibe. Suddenly, you notice a new qu... | stackexchange_codegolf |
Challenge
Given a string with any characters a-z or A-Z, return an 'encrypted' string, where all characters are replaced by the character next to it (assuming a QWERTY keyboard).
Case (uppercase, lowercase) does not matter.
The input will only have characters a-z and A-Z.
Shortest code in bytes wins.
Example Input a... | stackexchange_codegolf |
Inspired by this challenge, which got closed. This is meant to be an easier, but no less interesting version of that.
This is the robbers thread of a cops-and-robbers challenge. For the cops thread, see here.
Cops will provide a program/function and a flag. Robbers will guess a password. When the password is given to t... | stackexchange_codegolf |
In this cops-and-robbers challenge, robbers must crack cop answers by finding out which languages the cops used.
This is the Cops thread. For the Robbers' challenge, see here
Cops, you are to write a program, which, when executed in a specific language, does one of the following:
Outputs one of the 5 phrases below
Out... | stackexchange_codegolf |
Your task is to print this exact text:
z
yz
xyz
wxyz
vwxyz
uvwxyz
tuvwxyz
stuvwxyz
rstuvwxyz
qrstuvwxyz
pqrstuvwxyz
opqrstuvwxyz
nopqrstuvwxyz
mnopqrstuvwxyz
lmnopqrstuvwxyz
klmnopqrst... | stackexchange_codegolf |
There are two forms of nouns, singular and plural. The conversion between these two is quite easy.
Normally, you end it with s. ex. car => cars.
If it ends with s,x,z,ch or sh, end it with es. ex. bus=>buses.
If it ends with y with a consonant just before it, change the y to ies. ex. penny => pennies.
If it ends wi... | stackexchange_codegolf |
Imagine you have two lights. These lights blink on and off at a specific rate:
Light 0: Delay 0ms and then blink every 1000ms
Light 1: Delay 500ms and then blink every 1000ms
Let's simulate these lights for the first 2000ms:
0ms: Light 0 on
500ms: Light 1 on
1000ms: Light 0 off
1500ms: Light 1 off
2000ms: Light 0 ... | stackexchange_codegolf |
You can depict a triangular number, T(N), by writing one 1 on a line, then two 2's on the line below, then three 3's on the line below that, and so on until N N's. You end up with a triangle of T(N) numbers, hence the name.
For example, T(1) through T(5):
1
1
22
1
22
333
1
22
333
4444
1
22
333
4444
55555
To keep t... | stackexchange_codegolf |
Related: Multiply Quaternions
Challenge
Given a string made of ijk, interpret it as the product of imaginary units of quaternion and simplify it into one of the eight possible values 1, -1, i, -i, j, -j, k, -k.
The evaluation rules are as follows:
$$
ii = jj = kk = -1 \\
ij = k, \quad jk = i, \quad ki = j \\
ji = -k, \... | 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 |
Say that you have a string like this:
abaabbbbbaabba
Count the number of times that a specified character appears in the input string, but only if the character appears only once in a row. For example, if the character is a,
abaabbbbbaabba
^ x x ^
The total would be 2 (the aa's wouldn't count because the a app... | stackexchange_codegolf |
Write the shortest program that solves Rubik's cube (3*3*3) within a reasonable amount of time and moves (say, max. 5 seconds on your machine and less than 1000 moves).
The input is in the format:
UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR
(this particular input represents the solved cube).
Fi... | stackexchange_codegolf |
J-uby is the Language of the Month for June 2022, so I'm looking for tips for golfing in it. As usual, please post one tip per answer, and avoid general tips such as "remove whitespace" or "avoid comments".
| stackexchange_codegolf |
You should write a program or function that given a list of positive integers multiplies each element with the smallest positive integer possible to create a strictly increasing list.
For example if the input is
5 4 12 1 3
the multiplications will be
5*1=5 4*2=8 12*1=12 1*13=13 3*5=15
and the output will be the incre... | stackexchange_codegolf |
We define \$a(n)\$ as the 1-indexed position of \$n\$ in the sequence of positive integers with the same binary weight, i.e. the same number of 1's in their binary representation. This is A263017.
Given a positive integer \$n\$, your task is to determine how many positive integers \$k\$ satisfy:
$$k-a(k)=n$$
For instan... | stackexchange_codegolf |
In an earlier challenge I asked code golfers to produce strings which copy each character in a string. For example:
TThhiiss iiss ddoouubbllee ssppeeaakk!!
This challenge is simply to detect if some text meets the definition of a double speak string.
There is an even number of characters.
When split into pairs, ev... | stackexchange_codegolf |
You are to approximate the value of:
$$\int^I_0 \frac {e^x} {x^x} dx$$
Where your input is \$I\$.
Rules
You may not use any built-in integral functions.
You may not use any built-in infinite summation functions.
Your code must execute in a reasonable amount of time ( < 20 seconds on my machine)
You may assume that inp... | stackexchange_codegolf |
Your goal is to write a program that will print out the Laplace transform of a polynomial function with integer coefficients \$f(x)\$. The Laplace transform of \$f(x)\$ is defined as \$\int_0^\infty f(x) e^{-sx} dx\$.
The standard input for the polynomial function will be
a+bx+cx^2+dx^3+...
If the coefficient is zero,... | stackexchange_codegolf |
Your challenge is to turn input text to brain-flak code that will output the text.
Tutorial taken from here with permission here
Brain-Flak has two stacks, known as 'left' and 'right'. The active stack starts at left. If an empty stack is popped, it will return 0. That's it. No other variables. When the program starts,... | stackexchange_codegolf |
I'm a teacher, and in a few days I have to give my students a test. Now, I'm always worried about my loveliest students being hurt by the least loveliest ones when they cheat, so I want to randomize the tests so no one can cheat off of anyone.
Right now, I have my tests saved in this format:
When was Java invented?
W... | stackexchange_codegolf |
Cops thread (read first)
Robbers, your task is to find a Shue program p that when given the cops input i, outputs a program h, which outputs "Hello Shue!". The length of your p has to be less than or equal to the length of the cop's p. The robber with the most cracks wins.
| stackexchange_codegolf |
Inspired by the challenge A pile of weights.
Challenge
Given an integer as a weight in pounds, output an ASCII barbell that can represent the weight. Weights will come in the form of the barbell (which will weigh 45lbs) and plates with the following weights: 45lbs, 35lbs, 25lbs, 10lbs, and 5lbs. Weights will be repre... | stackexchange_codegolf |
Your task is to write the shortest algorithm in a language of your choosing that accomplishes the following:
Given two matrices it must return the euclidean distance matrix. The euclidean distance between two points in the same coordinate system can be described by the following equation:
\$D = \sqrt{ (x_2-x_1)^2 + (y_... | stackexchange_codegolf |
You want to write your English essay. However, all characters on your keyboard broke other than the arrow keys and the enter key. You want to find out how to place the characters so you can write your essay with the least movement.
Formally, you have to assign to each character of !"$%&'()+,-./0123456789:;<=?[]`abcdef... | stackexchange_codegolf |
Your task is to turn a square root like this:
√12
into a form like this:
2√3
For our purpose, we only need to output the left number here:
2
Test cases
4 -> 2
9 -> 3
12 -> 2
13 -> 1
108-> 6
Specifications
You may assume for the input that \$n>0\$. \$n\$ has to be as large as possible.
If the number is already a ... | stackexchange_codegolf |
As many of you will know, almost every programming language has a standard casing system; unfortunately, we have not been able to agree on a singular system to use and now must frequently switch between camelCase, snake_case, PascalCase and kebab-case.
Now I know what you're thinking... wouldn't it be nice if we had a ... | stackexchange_codegolf |
This question is similar to Do the circles overlap?, except your program should return True if the circumference of one circle intersects the other, and false if they do not. If they touch, this is considered an intersection. Note that concentric circles only intersect when both radii are equal
Input is two x, y coordi... | stackexchange_codegolf |
Related to this question.
A room is defined to be a (not necessarily convex) non-intersecting polygon, expressed as an ordered list of 2-dimensional coordinates. A sufficiently bright lightbulb is placed at a specific point inside the room, and emits light in every direction. Your task is to find the total illuminated ... | stackexchange_codegolf |
Lambda calculus is a system of computation based on single-argument functions; everything in it is such a function. Due to this functional nature, juxtaposition is commonly used to denote function application, grouped from left to right. For example, \$(f g) h=f g h\$ denotes what would conventionally be written \$(f(g... | stackexchange_codegolf |
The class System.Globalization.EastAsianLunisolarCalendar of the mscorlib.dll assembly is non-nested public but its sole instance constructor is internal and it also declares some internal abstract members.
The problem: Write a C# class in your own assembly (code must compile with usual C# compiler) where a class deriv... | stackexchange_codegolf |
Background
There's a common riddle that goes something like this:
A snail is at the bottom of a 30 foot well. Every day the snail is able to climb up 3 feet. At night when they sleep, they slide back down 2 feet. How many days does it take for the snail to get out of the well?
The intuitive answer is
30 days, becau... | stackexchange_codegolf |
So, last week I posted a challenge to play Duck, Duck, Goose. This lead to a number of Minnesotans commenting about their regional 'Gray duck' variation.
So here's the rules:
Using this list of colours:
Red
Orange
Yellow
Green
Blue
Indigo
Violet
Gray
Write a program to follow these rules:
Select one of these colours,... | stackexchange_codegolf |
(Inspired quite heavily by this challenge)
In the original challenge you were to make a horizontal zipper, however, looking down at my hoodie, my zipper is much more vertical (and a little bit broken) :P
Input
You will be given a single string (s), and a pair of integers (a and b) in any format. Where:
a < (length-of-... | stackexchange_codegolf |
@BeastlyGerbil presents, the world's very first MOBIUS SUDOKU:
Google Sheets version
(The left most square backs onto the right most square, and the middle squares back onto each other. The ends are then attached as indicated.)
RULES:
Normal sudoku rules apply for rows and boxes - boxes are split into groups of 3... | stackexchange_codegolf |
Your program has to have an year like 1957 to be the input and then output the century of that year.
For example:
In: 1946
Out: 20
In: 1705
Out: 18
In: 1900
Out: 19
In: 100
Out: 1
In: 2001
Out 21
because 1946 is in the 20th century.
Keep in mind that 2000 should be 20th century or 1900 should be in 19th century.
There... | stackexchange_codegolf |
CODE GOLF & Coding Challenges: In today's challenge, you'll be asked to print the following very special AND tricky AND satisfying Prime Number...! Are you golfers ready?
67796869327179767032383267111100105110103326710497108108101110103101115583273110321161111009712139115329910497108108101110103101443212111111739108108... | stackexchange_codegolf |
Background
Variable declaration statement in C consists of three parts: the name of the variable, its base type, and the type modifier(s).
There are three kinds of type modifiers:
Pointer * (prefix)
Array [N] (postfix)
Function () (postfix)
You can specify a list of function arguments inside the parens, but for the s... | stackexchange_codegolf |
The Goldbach conjecture states that:
every even number that is greater than 2 is the sum of two primes.
We will consider a Goldbach partition of a number n to be a pair of two primes adding to n. We are concerned with numbers is of increasing Goldbach partition. We measure the size of a number's Goldbach partitions ... | stackexchange_codegolf |
In the tabletop RPG named Pathfinder, there is a feat that characters can take called Sacred Geometry, which allows a character who has it to buff their spells in exchange for doing some math: to use it, the character rolls a number of six-sided dice equal to their ranks in a particular skill, consults a table based on... | stackexchange_codegolf |
A haiku is a poem with three lines, with a 5/7/5 syllable count, respectively.
A haiku-w is poem with three lines, with a 5/7/5 word count, respectively.
Challenge
Write a program that will return true if the input is a haiku-w, and false if not.
A valid haiku-w input must consist of 3 lines, separated by a newline.
L... | stackexchange_codegolf |
We define a tree-like list, or trist for short, as the empty list or a list containing only previously constructed trists.
The natural numbers can either include 0 or not, according to your preference.
The task is to create a pair of functions or complete programs f and g (they don't have to be named like this or even ... | stackexchange_codegolf |
Incremental Game Time Format
Goal
Incremental games often have a countdown timer expressing the days, hours, minutes and seconds until a task is complete. Depending on the space available, they can be formatted as:
2d 13h
23h 59m 48s
14m
3h 0m 0s
The goal of this code golf is to write a function or program that perfo... | stackexchange_codegolf |
Challenge
Given a SE user's ID, output the sum of their reputation from across all of the Stack Exchange networks the user has signed up to.
Rules
If a user has 101 or less reputation on a site, count it as zero in the sum.
You should not count Area 51 rep or hidden communities!!
URL shorteners are disallowed.
Example... | stackexchange_codegolf |
In this challenge you will take two lists as input and you will zip them. The zip can be defined with this recursive expression:
\$
\mathrm{zip}(a,b) = \begin{cases}
\left[\,\,\right] & a = \left[\,\,\right] \\
[a_0]\mid\mid\mathrm{zip}(b, t) & a = [a_0] \mid\mid t
\end{cases}
\$
or this Haskell program if you would l... | stackexchange_codegolf |
Mountain range number
A number is a mountain range number if the inequalities satisfied by their consecutive digits alternate. In a way, looking at the number's digits should exhibit a /\/\/\... or a \/\/\/... pattern.
More formally, if our number n has \$k\$ digits
$$n = d_1d_2d_3\cdots d_k$$
then n is a mountain rang... | stackexchange_codegolf |
You've gotten out of Earth's gravity well - good for you! However, you're feeling a bit uncomfortable in zero-gravity, and you want to replicate 1 \$g\$ of force in a centrifuge. Use the equation for force in a centrifuge:
$$\text{RCF} = \frac{r_\text{m} \, \left(\frac{2 \pi N_\text{RPM}}{60}\right)^2}{g}$$
Where
\$\t... | stackexchange_codegolf |
Your task is to fill the bucket with numbers upto a given input.
Rules
Numbers occupy the leftmost position then rightmost, then leftmost and so on.
After overflow, the numbers start to gather around the bucket in a similar manner. They occupy position diagonally.
The examples should make it clear what the expected out... | stackexchange_codegolf |
You will be given a string. It will contain 9 unique integers from 0-9. You must return the missing integer. The string will look like this:
123456789
> 0
134567890
> 2
867953120
> 4
| stackexchange_codegolf |
You want to send an ASCII letter to someone, but you need an envelope to put it in. Your task is to output an envelope given a size as input.
Rules:
Given positive integer input i, your envelope will be i characters tall (not counting the top row), and i*2 characters wide (not counting the side columns). In other word... | stackexchange_codegolf |
Your task is to get two numbers, and output the digit sum of them. We'll define digit sum as the following:
take the decimal (base 10) digits of each of them, and pad with 0s the shortest number (e.g. [1,9], [0, 7])
sum the digits as vectors (e.g. [1, 16])
convert the number back from base 19, and output it (e.g. 1*19... | stackexchange_codegolf |
The Challenge
Given an input string (or array) consisting of < and >, output a sequence (array or string) of integers such that:
the operators are all correct when applied in order between consecutive numbers in the output
all integers are positive (1 or greater)
the sum of the integers is as small as is mathematicall... | stackexchange_codegolf |
Given a natural number \$n\$, return the \$n\$-th cuban prime.
Cuban Primes
A cuban prime is a prime number of the form
$$p = \frac{x^3-y^3}{x-y}$$
where \$y>0\$ and \$x = 1+y\$ or \$x = 2+y\$
Details
You may use 0 or 1 based indexing, whatever suits you best.
You can return the \$n\$-th prime given the index \$n\$ or... | stackexchange_codegolf |
All-pairs shortest paths is a standard pathfinding problem. This is a twist on that.
Definitions
We are searching for paths on a directed graph. Graphs are defined by square matrices, for example
0 3 2.5
1 0 1
0 -1 0
Write M(r,c) = value in M at row r, column c is the cost to travel from node r to node c. The gra... | stackexchange_codegolf |
Task
Given a positive integer n, output the joined compound of circles
The circles are of square of size n+2 but removing the corner edges and the middle, before finally overlapping n times of itself
E.g.
2
->
####
####
####
####
->
##
# #
# #
##
->
## ##
# # #
# # #
## ##
Testcases
1
->
#
# #
#
2
->
... | stackexchange_codegolf |
Consider a finite, one-dimensional grid where each cell is marked with one of two symbols (I will use the symbols < and >, but you can use other symbols).
When a pinball is placed on one of the cells, it moves according to the following rules:
If the pinball is on a cell that is marked with <, the pinball moves one ce... | stackexchange_codegolf |
Given an unordered list of musical pitches, write the shortest program/function (scored in bytes) to sort the list from lowest pitch to highest.
Pitches will be given in scientific pitch notation, consisting of a tone name followed by an octave number. Here, the tone name will be a single letter A–G, possibly followed ... | stackexchange_codegolf |
We are going to bring down an imaginary building with a series of explosions. Our building is a 5x5 matrix of integers ranging 1-9, each representing a single brick.
The challenge is to set of a series of explosions to bring down our building as much as we can, why not! Each brick that is connected (horizontally, verti... | stackexchange_codegolf |
Given a ruler length in inches and fractions of an inch, and a granularity in fractions of an inch, output the values of all marks on the ruler, starting from 0, in ascending order.
Input ruler length will be a mixed fraction (integer and proper fraction)
Input granularity will be a proper fraction in the form 1/(2ⁿ), ... | stackexchange_codegolf |
Task
Given a positive integer n, draw the corresponding rocket.
Examples
From n = 1 to 4 the rockets are below. For your program's output, the trailing newline after a rocket is optional.
|
/ \
*---*
| o |
| o |
*---*
/_\
|
/ \
/ \
*-----*
| o o |
| o o |
| o o |
| o o |
*-----*
/___\
|
/ \
/ ... | stackexchange_codegolf |
Find the moves that bring a chess squad to a given destination.
You control a chess squad consisting of a king and several other pieces, on a larger chess board. Your army is placed so that no piece is further than K=8 squares away (horizontally and vertically) from your king. You will receive a destination square for ... | stackexchange_codegolf |
This challenge is based on this Stackoverflow question.
With a positive number as input, output it as the sum of each digit multiplied by its power-of-10 representation.
Input
A number, as an integer, a string or a list of digits/characters.
The number will be strictly positive.
If you accept the number as a string or... | stackexchange_codegolf |
For this challenge, you will be required to write 3 programs:
The first program should be a quine, i.e, it should print it's own source code.
The second program should read the input and print all of it.
The third program should simply print the string "Hello, Permutations!", with or without quotes.
In addition to th... | stackexchange_codegolf |
Sequel of this AWESOME challenge
You, a genius tech prodigy detective, have successfully disarmed the bomb and want to break into the computer. The police found the password 67890-=yuiop[]hjkl;'\vbnm^&*()_+:"| on a piece of paper, but much of the keyboard is broken and there are no other ways of inputting characters.
T... | stackexchange_codegolf |
If you wanted to compute a very large long problem, that on a machine that you could buy today for an inflation adjusted price, will take some amount of years/decades. The issue is, if you only have that budget, and so can only purchase one machine. So if you purchase the machine now, it may actually take longer to com... | stackexchange_codegolf |
You should complete four tasks in a language which:
must return no results* when searched for on this (codegolf.se) website, for example ToffeeScript;
must have a page listed at Esolang, Rosetta Code or Wikipedia;
be a distinct language, rather than a distinct version (e.g. python 2.1 would be valid iff python satisfi... | stackexchange_codegolf |
Write a program or a function to print the following cube (if you allow me to call it so) in different sizes:
^L^L^L^L^L^L^L^L^L^L^L
//^L^L^L^L^L^L^L^L^L^L^L
////^L^L^L^L^L^L^L^L^L^L^L
//////^L^L^L^L^L^L^L^L^L^L^L
////////^L^L^L^L^L^L^L^L^L^L^L
//////////^L^L^L^L^L^L^L^L^L^L... | stackexchange_codegolf |
Challenge:
Given a matrix input, determine the amount of diagonals and anti-diagonals with duplicated numbers.
So if we have a matrix like this:
[[aa,ab,ac,ad,ae,af],
[ba,bb,bc,bd,be,bf],
[ca,cb,cc,cd,ce,cf],
[da,db,dc,dd,de,df]]
All diagonals and anti-diagonals would be:
[[aa],[ab,ba],[ac,bb,ca],[ad,bc,cb,da],[ae,... | stackexchange_codegolf |
September 1993 is known on Usenet as the September that never ended. Thus, for example, the day this question is being posted is Saturday, September 8740, 1993.
Your program or function should take any Gregorian date (with positive year) as input and return the same date as output if it's prior to September 1993 or the... | stackexchange_codegolf |
Consider depicting a simple, open, two-dimensional curve on a W wide by H high grid of text where X represents part of the curve and . represents empty space and no other characters are used.
Every grid space has 8 neighboring grid spaces, its Moore neighborhood. Grid spaces beyond the borders are considered empty.
A g... | stackexchange_codegolf |
This is an answer-chaining challenge in which each answer builds on the previous answer. I recommend sorting the thread by "oldest" in order to be sure about the order in which the posts are made.
Note: This has become quite a long-lasting challenge, and posting new answers is fairly difficult. As such, there's now a ... | stackexchange_codegolf |
Inspired by @AviFS.
Given a string containing brackets, e.g.
[xyz]]abc[[def]hij[
You can parse through it with a stack of brackets. When you find an open bracket, push a value to the stack, when you find a close bracket, pop from the stack. If you make these values indices, you know where you need to remove brackets.
... | stackexchange_codegolf |
A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.
Given three strings A, B and C (note the order) as input, find the length of the longest string S such that:
Condition 1: S is a subsequence of A
Condition 2: S is a sub... | stackexchange_codegolf |
Design a function or program that, when run normally, outputs the triangular numbers. However, when any single character is deleted, the program/function should not function in the original programming language, but instead produce the triangular numbers in one other programming language.
Scoring
Your score will be the... | stackexchange_codegolf |
I am exploring a unique approach to the classic problem of Reverse Polish Notation on code.golf. Unlike the conventional solutions, my focus lies on leveraging the eval function in GolfScript. This twist was inspired by a comment in a related thread, where the absence of eval was deemed a limitation.
"It's a shame no ... | stackexchange_codegolf |
Goal:
Write a complete program or function which takes a formula in propositional logic (henceforth referred to as a logical expression or expression) and outputs that formula in conjunctive normal form. There are two constants, ⊤ and ⊥ representing true and false, a unary operator ¬ representing negation, and binary o... | stackexchange_codegolf |
The popular webcomic Homestuck makes use of a programming language called ~ATH to destroy universes. While this code golf challenge is not to write a program to annihilate our existence, we will be destroying some more tame (albeit less interesting) entities: variables.
~ATH (pronounced "til death," notice how ~ath is... | stackexchange_codegolf |
Write a sorting algorithm for a list of integers that has an average performance of O(n^2).
This is code-golf, so the shortest code in bytes wins.
RULES:
The characters wasted for the declaration of the list are not counted
(e.g. var c = new List<int>() { 4, 2, 1, 3 }; is not counted)
Builtins to sort a list are not ... | stackexchange_codegolf |
So you are given a POSITIVE base 10 (decimal) number. Your job is to reverse the binary digits and return that base 10 number.
Examples:
1 => 1 (1 => 1)
2 => 1 (10 => 01)
3 => 3 (11 => 11)
4 => 1 (100 => 001)
5 => 5 (101 => 101)
6 => 3 (110 => 011)
7 => 7 (111 => 111)
8 => 1 (1000 => 0001)
9 => 9 (1001 => 1001)
10 => ... | stackexchange_codegolf |
In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.
Your task, if you wish to accept it, is to write... | stackexchange_codegolf |
The Xerox Alto, originally released in 1973, was the first computer to feature the now-familiar angled mouse pointer. The Alto's bitmapped pointer looked like this (redrawn from Fig. 2 here):
Your task in this code-golf challenge is to write a program/function that generates an ASCII art representation of the mouse po... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.