instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Guidelines
Task
Given two non-negative integers, find the sum of both numbers... to the power of 4.
Examples
2, 3 -> 97 (2^4 + 3^4 = 97)
14, 6 -> 39712 (14^4 + 6^4 = 39712)
0, 25 -> 390625 (0^4 + 25^4 = 390625)
Rules
You will only ever receive two non-negative integers as input (bonus points if you get it to work wi... | stackexchange_codegolf |
Input
The code should take an integer \$n\$ between 1 and 1000.
Output
The code should output positive integers with \$n\$ bits. Accompanying each integer should be its full factorization. Each integer should be a uniformly random \$n\$ bit number.
Score
The score for your code will be the number of integers it outputs... | stackexchange_codegolf |
According to this page, the best strategy to guess English hangman words is to calculate the odds of each letter in a word list that meet our conditions. But, as I'm really lazy, I don't really want to compute every word in the dictionary by myself. But, as I know that you are always here to help me, I'm sure you will ... | stackexchange_codegolf |
With the US election going on right now, I noticed that there is one (completely meaningless, but still) thing which Trump can still achieve and which is out of reach for Biden: Having the won states being connected.
Task: Given a list of strings of two-letter abbreviations (see below) for US states, determine whether ... | stackexchange_codegolf |
Input: A valid 6 HEX digit color code wihout a # prefix
Valid:
000000
FF00FF
ABC123
Your job is to find to which one of these:
Red: FF0000
Green: 00FF00
Blue: 0000FF
White: FFFFFF
Black: 000000
the input color is the closest too, in this case you try to only match it to black or white when the RGB is the same v... | stackexchange_codegolf |
You have to decompose a positive integer/fraction as a product of powers of factorials of prime numbers.
For example
22 = (11!)^1 × (7!)^(−1) × (5!)^(−1) × (3!)^(−1) × (2!)^1
10/9 = (5!)^1 × (3!)^(−3) × (2!)^1
Use this special notation: prime number#power
to denote each term, e.g. (11!)^4 is denoted as 11#4.
Output... | stackexchange_codegolf |
Giuga numbers (A007850) are composite numbers \$n\$ such that, for each prime factor \$p_i\$ of \$n\$, \$p_i \mid \left( \frac n {p_i} -1 \right)\$. That is, that for each prime factor \$p_i\$, you can divide \$n\$ by the factor, decrement it and the result is divisible by \$p_i\$
For example, \$n = 30\$ is a Giuga num... | stackexchange_codegolf |
This problem is about separating a string representing a product identifier into three components.
The first part consists of upper and lower letters of arbitrary length which represents the warehouse.
The second part is digits which represents the product number. This part is also of arbitrary length.
The last par... | stackexchange_codegolf |
Reading a book is easy, but printing a book can be a bit tricky. When printing a booklet, the printer needs to have the pages arranged in a certain manner in order to be read from left to right. The way this is done is using a pattern like below
n, 1, 2, n-1, n-2, 3, 4, n-3, n-4, 5, 6, n-5, n-6, 7, 8, n-7, n-8, 9, 10,... | stackexchange_codegolf |
World Bowling scoring
Many people have gone to their local bowling center to play a few games of bowling, and many people continue to struggle to calculate their scores. World Bowling has introduced a simplified scoring system in order to attract more people to the sport. This scoring system is utilized in internation... | stackexchange_codegolf |
The absolute value of a number \$x\$ is normally written as \$|x|\$. The left and right side of the absolute value uses the same symbol, so it is not immediately obvious how to parse nested absolute values e.g. \$||1-2|+|3-|4-5|||\$
Your goal is to parse such an expression containing nested absolute values:
The express... | stackexchange_codegolf |
Your task here will be to write a very dumb AI capable of fetching all treasures on a map.
Map
The map is defined as follow: (artist-mode™-powered)
Basic case:
+-+-+-+-+-+-+-+-+-+-+-+-+-+
|P| | | | | | | | | | | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | | | | | | | | | | | | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | |T| | | | | | | ... | stackexchange_codegolf |
Task
Given a positive integer number and a threshold, split into every possible way without generating any numbers above the threshold.
Examples
Input: 15008
Threshold: 400
Valid Output:
[[1, 5, 0, 0, 8], [15, 0, 0, 8] [1, 50, 0, 8], [150, 0, 8]]
Invalid outputs:
[[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 500... | stackexchange_codegolf |
The Seidel Triangle is a mathematical construction similar to Pascal's Triangle, and is known for it's connection to the Bernoulli numbers.
The first few rows are:
1
1 1
2 2 1
2 4 5 5
16 16 14 10 5
16 32 46 56 61 61
Each row is generated as follows:
If the row number is even (1-indexed):
Bring... | stackexchange_codegolf |
Write a program that takes an undirected graph and finds the minimum cut, i.e., the set of edges that, if removed, would disconnect the graph into two or more connected components. The program should have a time complexity of \$O(n^2m)\$, where n is the number of vertices and m is the number of edges in the graph.
One ... | stackexchange_codegolf |
Goal
Using the programming language of your choice, write the shortest program to eliminate comments from a string representing a C program.
Input
The string can be taken as any form of input, but it may also be taken as a variable.
Instructions
Two different kinds of comments are to be removed:
multiline comments, ... | stackexchange_codegolf |
Objective
Given a dimension of an SI unit, convert the Lorentz-Heaviside version of a Planck unit \$1\$ into SI metric.
What is a Planck unit?
Planck units are a set of units of measurement. It defines five fundamental constants of the universe as dimensionless \$1\$.
What is a dimension?
There are five types of fundam... | stackexchange_codegolf |
I honestly can't believe this challenge does not already exist.
The challenge
Write a function.
The specifics
Your program must define some sort of callable function. This includes anything commonly known as a function, a lambda function, or a subroutine. All of these types of callables will be referred to as a "funct... | 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 |
A reflexicon is a self-descriptive word list that describes its own letter counts. Take for example the one found by Ed Miller in 1985 in English:
Sixteen e’s, six f’s, one g, three h’s, nine i’s, nine n’s, five o’s, five r’s, sixteen s’s, five t’s, three u’s, four v’s, one w, four x’s
This reflexicon contains exactl... | stackexchange_codegolf |
This is the robbers' thread. The cops' thread goes here.
Write a code that has the same number of bytes as the cop post and where the revealed characters are identical. The code must produce 1 in its initial state, and produce the numbers 2, 3 .. when single alterations are made.
The winner will be the robber that crac... | stackexchange_codegolf |
There are 5 different "special characters": % & # $ !
These special characters are in a string with numbers. Like so: "5 ! 60%2$5.3" (valid). You must determine the validity of the string and there are certain rules in order to determine validity of the string.
Rules:
These special characters can exist in a string... | stackexchange_codegolf |
We've all seen those online "maths hax" that look like this:
Think of a number, divide by 2, multiply by 0, add 8.
And, by magic, everyone ends up with the number 8!
Language
Let's define a programming language which uses the syntax of the text above, called "WordMath". WordMath scripts follow this template:
Think of... | 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 |
Description
You have a list of integers and start counting from the first term to the next and continue from that to the next and so on..
How many times have you counted?
For example given [ 2, 5, 3, 8 ]
you start at 2 and count to 5 -> 3 4 5 (3 times)
then from 5.. 4 3 (2 times)
and finally 4 5 6 7 8 (5 times)
You co... | stackexchange_codegolf |
Your challenge is to take a name (string) as input, like
Albert Einstein
and output:
Einstein, Albert
Pseudocode:
set in to input
set arr to in split by " "
set last to the last element of arr
remove the last element of arr
set out to arr joined with " "
prepend ", " to out
prepend last to out
output out
More test c... | stackexchange_codegolf |
Introduction
In number theory, a number is considered evil if there are an even number of 1's in its binary representation. In today's challenge, you will be identifying whether or not a given number is evil.
Challenge
Your job is to write a full program or function which accepts a single, non-negative integer as input... | 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 |
Let's solve this user's homework; I think it's an interesting exercise!
Input
Two 3-digit natural numbers.
Outputs
Two 2-digit numbers. In each of the output numbers, one digit is taken from one input number, and the other from the other number. The choice is independent. The first output number should be the minimal p... | stackexchange_codegolf |
And no, This is not a dupe of Translate ASCII text to braille.
There are 28=256 Braille patterns in Unicode. (By 'Braille' I mean 8-cell ones)
W, wait. How many ASCII characters were there?
27 = 128?
Well then, Let's turn ASCII into Braille, 'cause there is absolutely no reason not to!
The way from ASCII, to Braille... | stackexchange_codegolf |
Let \$p(x)\$ be a polynomial. We say \$a\$ is a root of multiplicity \$k\$ of \$p(x)\$, if there is another polynomial \$s(x)\$ such that \$p(x)=s(x)(x-a)^k\$ and \$s(a)\ne0\$.
For example, the polynomial \$p(x)=x^3+2x^2-7x+4=(x+4)(x-1)^2\$ has \$1\$ and \$-4\$ as roots. \$1\$ is a root of multiplicity \$2\$. \$-4\$ is... | stackexchange_codegolf |
Description
Your task is to implement a simple UNIX command parser and file system. Your program will have to implement a file system that can be modified via commands.
The starting directory of your file system is an empty root directory /, with no subdirectories or files. Your program must be capable of handling the ... | 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 |
Classic Tetris was often a difficult game to play. One problem was that you could only work with the Tetris piece you were given, so if you had an awkward board, it would sometimes be difficult to find a suitable location to put your piece. Another problem was that you could only look one piece ahead, so it was difficu... | stackexchange_codegolf |
When making phone calls internationally, phone numbers are prefixed with a code indicating what country the number is located in. These codes are prefix codes, meaning that no code is a prefix of another.
Now, earlier today you missed a call, and you're kind of curious where that call might have come from. So you want ... | stackexchange_codegolf |
Well... there are 59 (now 60) questions tagged sorting, but no simple quicksorts.
That must be fixed.
For those unfamiliar with quicksort, here is a breakdown, courtesy of Wikipedia-
Pick an element, called a pivot, from the array.
Reorder the array so that all elements with values less than the pivot come before the... | stackexchange_codegolf |
Given an integer n, output the smallest prime such that the difference between it and the next prime is at least n.
For example, if n=5, you would output 23, since the next prime is 29, and 29-23>=5.
More Input/Output Examples
1 -> 2 (3 - 2 >= 1)
2 -> 3 (5 - 3 >= 2)
3 -> 7 (11 - 7 >= 3)
4 -> 7
5 -> 23
6 -> 23
7 -> 89
8... | stackexchange_codegolf |
Originally from a CMC I proposed for the last BMG event
Challenge
Given a non-negative integer \$n\$, create a 2D array of size \$2^n × 2^n\$ which is generated in the following manner:
Divide the matrix into four quadrants of size \$2^{n-1} × 2^{n-1}\$.
Visiting order of the four quadrants is defined to be the Z-shap... | stackexchange_codegolf |
This question is a part of the lean LotM.
A ring is a type of structure that takes the rules of addition and multiplication we are familiar with and abstracts them, so we can reason about them. To do this we state a number of expected properties as axioms and see what we can say about systems that follow these axioms.... | stackexchange_codegolf |
Create a function which takes in a input integer and then returns the number of factors it has, like if you pass 25 then it will return 3 since it has 3 factors i.e. 1,5,25.
Challenge:
Make the fastest and the smallest code!
| stackexchange_codegolf |
Challenge :
Given a string representing a mathematical expression return the result
Input :
A string representing a mathematical expression : '1 + 2 - 3 * (2/3 * 1)'.
Output :
The result after performing all operations.
Operators :
Possible operators
+ ---> plus
- ---> minus
* ---> multiplication
/ -... | stackexchange_codegolf |
Taking in Input
Define a function f as follows:
IF x < 0:
f(x) = -√|x|
ELSE:
f(x) = √x
In your programs/functions, each point (x, y) given as input will correspond to the point (f(x), f(y)). For example, if the points (4, -2) and (-1, 5) are given as input, your program will be dealing with the points (2, -√2)... | stackexchange_codegolf |
A prime knot is:
a non-trivial knot which cannot be written as the knot sum of two non-trivial knots.
Explanation of a knot-sum: put the two knots adjacent,
... then draw two lines between them, to the same strand on each side, and remove the part between the lines you just drew. This composition of two knots will f... | stackexchange_codegolf |
Sandbox
The major scale (or Ionian scale) is one of the most commonly used musical scales, especially in Western music. It is one of the diatonic scales. Like many musical scales, it is made up of seven notes: the eighth duplicates the first at double its frequency so that it is called a higher octave of the same note.... | stackexchange_codegolf |
You are given an \$ 25 \times 25 \$ square lattice graph. You are to remove certain nodes from the graph as to minimize your score, based on the following scoring system:
Your score will be the \$ \text{number of nodes removed} \$ \$ + \$ the \$ \text{size of the largest connected component} \$. In the smaller \$ 4 \ti... | stackexchange_codegolf |
Back when I was a freshman in highschool taking chemistry, I'd look at the periodic table of elements and spell dirty words out with the number of the elements (HeCK would be 2619, 2-6-19).
I was thinking about this the other day when I saw an amazing shirt that spelled out BeEr (4-68)
So my codegolf challenge is short... | stackexchange_codegolf |
What does "jelly" mean in the title?. Cop's thread
Robbers, you are to choose an uncracked Cop answer, and attempt to find a Jelly program which is:
shorter than the Cop's answer
solves the linked challenge, according to the rules of the challenge
So long as these two bullet points are met, your answer cracks the Cop... | stackexchange_codegolf |
How well do you know the site? Let's find out.
This is a cops-and-robbers challenge. Robber's thread.
As a cop, you need to:
Find a non-deleted, non-closed challenge on this site to answer. The challenge cannot have the following tags: cops-and-robbers, popularity-contest, code-trolling, underhanded, busy-beaver, k... | stackexchange_codegolf |
Letter dice are common in word games. It can be fun to try to spell funny words with boggle dice, for instance. If you grab a handful of dice, chances are you won't be able to spell certain words. This challenge is a generalization of that idea.
Challenge
Given a list of dice which each have at least 1 face and a word,... | stackexchange_codegolf |
Description :
Given a string as input, check if it is a valid ordinal number in English or not. If it is valid return truthy value otherwise return falsy value. (Suggested by @Arnauld. Thanks . Also by @JoKing)
For users who want to know about ordinal numbers go here :
https://www.mathsisfun.com/numbers/cardinal-ordina... | stackexchange_codegolf |
Related to AoC2017 Day 18, Part 2. (Anyone want to add Duet to esolangs?)
Duet is an assembly-like language that involves two processes running the same program simultaneously. Each process of Duet operates with 26 registers named a to z, all initialized to zero, except for the register p which contains the process ID... | stackexchange_codegolf |
Create a program that, given an integer N, outputs the number of years we have to get to N A.D. or how many years it has been since N A.D, as a string or int. For example, given 2014, the program should output 5 as it has been that many years since 2014. Input of the year in which you run the program should result in 0... | stackexchange_codegolf |
Tichu is a card game in which players take turn playing sets of cards from a deck consisting of a standard 52-card deck, plus 4 additional cards:
the dragon, which has a greater value than any other card
the phoenix, which can act as a wildcard
the dog, which passes the turn to your partner
the Mah Jong, which has val... | stackexchange_codegolf |
Intro (semi fictional)
I'm the solo developer of a game, I'm already struggling with character design as is. Hence I've thought of a smart solution, I'll just use images for regular monsters, outline them a bit and suddenly they are boss monsters! That will save me from thinking up new bosses yay.
However, I have appro... | stackexchange_codegolf |
Create a bijective function between the syntactically valid BF programs and the natural numbers
This means that you will assign each BF program a nonnegative integer (0,1,2,...) in such a way that each number gets a BF program without syntax errors (and without whitespace or comments).
Note that something like Binaryf*... | 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 |
You are going to be planting pumpkins soon, and you are preparing your supplies. Pumpkins come in all sorts of sizes and have their sizes written on the seed bag. A pumpkin that is size n will grow to be n units wide. However pumpkins need their space.
If a pumpkin is stuck between two other pumpkins with not enou... | stackexchange_codegolf |
Sandbox
French License Plates
French license plates come in a sequential order, following a specific pattern of numbers and letters : AB-012-CD
Challenge
Write a program or function that, for a given number, outputs the corresponding french license plate number. Your program should not handle any special case as specif... | 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 |
In this challenge, your task is to input a rectangle ASCII pattern (You may assume only printable characters need to be handled, and you may assume a trailing newline or not), C4_4 symmetrify, and output it.
Here, C4_4 symmetric means symmetric under 90-degree rotation around a corner of the corner character. The corre... | stackexchange_codegolf |
Though there is a prime factorization challenge and it's here, this, I feel, will be a bit more interesting than that one.
To understand this, let's have an example; I will use 5,184 for this. \$5184 = 2^6 \times 3^4\$. However, for this challenge, such a factorization is insufficient - the reason is that 6 and 4 are c... | stackexchange_codegolf |
When encountering a problem whose input is meant to be read sequentially, but you may also want to push back onto the input like a stack, which languages have the optimal boilerplates for doing so, and how?
For example, from Create a Boolean Calculator, we have a string like:
1AND0OR1XOR1
We want to "pop" 5 chars 1AND... | stackexchange_codegolf |
Make an upside down triangle of positive integers. Every number in the triangle must be distinct. Each number is the summation of its two parents (similar to how Pascal's triangle is constructed, but upside-down). Construct it in such a way that the bottom number is minimized.
For example, for input n = 4, here is a po... | stackexchange_codegolf |
Challenge
Given a binary number as input through any means, "simplify" the number using a full program or a function.
Input
[binary]
binary is a number in binary that is over 0.
Output
Take the input, convert it to base 10 without using a builtin, then if that number contains only 1s and 0s, convert it into a base 1... | stackexchange_codegolf |
Given a atomic number, print how many electrons are in each shell of the element that the atomic number corresponds to.
Expected input/output:
Input -> Output
1 -> 1
2 -> 2
3 -> 2, 1
4 -> 2, 2
5 -> 2, 3
6 -> 2, 4
7 -> 2, 5
8 -> 2, 6
9 -> 2, 7
10 -> 2, 8
11 -> 2, 8, 1
12 -> 2, 8, 2
13 -> 2, 8, 3
14 -> 2, 8, 4
15 -> 2, 8... | stackexchange_codegolf |
Introduction
We all know and love our Fibonacci sequence and have seen a myriad of challenge on it here already. However, we're still lacking a very simple case which this answer is going to provide: Reversed fibonacci! So given F_n your job is to find n.
Specification
Input
Your input will be a non-negative integer, w... | stackexchange_codegolf |
Your task is to write program which will draw 800x600 black-and-white image with something resembling a forest.
Like this (it is dithered photo):
Rules
You are disallowed to use any existing images - you should generate image purely algorithmically
Use only 2 colors - black and white (no grayscale)
Each time program ... | stackexchange_codegolf |
You may know the game The Six Degrees of Kevin Bacon, based on the conjecture that every actor in Hollywood can be connected to Kevin Bacon by no more than 6 "co-star" relations, so Kevin Bacon is supposedly the "best-connected" node in that graph. Your task will be to find the Kevin Bacon of a graph.
We will use posit... | stackexchange_codegolf |
In this task you are given an odd number of white balls and the same number of black balls. The task is to count all the ways of putting the balls into bins so that in each bin there is an odd number of each color.
For example, say we have 3 white balls. The different ways are:
(wwwbbb)
(wb)(wb)(wb)
for the two differ... | stackexchange_codegolf |
The Challenge
Write a program or function that takes no input and outputs a 3-dimensional vector of length \$1\$ in a theoretically uniform random direction.
This is equivalent to a random point on the sphere described by $$x^2+y^2+z^2=1$$
resulting in a distribution like such
Output
Three floats from a theoretically ... | stackexchange_codegolf |
This includes tips for all related derivatives, as coding in these langs often primarily consists of writing the function in the lambda calculus and then compiling it down at the end.
Among others, this includes tips for:
Standard combinator calculi
SKI system
BCKW system
Esolang combinator calculi
Iota/Jot/Zot
La... | stackexchange_codegolf |
Description :
Given a string as input, check if it is a valid ordinal number in English or not. If it is valid return truthy value otherwise return falsy value. (Suggested by @Arnauld. Thanks . Also by @JoKing)
For users who want to know about ordinal numbers go here :
https://www.mathsisfun.com/numbers/cardinal-ordina... | stackexchange_codegolf |
You task here is very simple:
Given a positive integer n without leading zeroes as input, split it in all possible ways
Examples
Input->Output
111 -> {{111}, {1, 11}, {11, 1}, {1, 1, 1}}
123 -> {{123}, {12, 3}, {1, 23}, {1, 2, 3}}
8451 -> {{8451}, {845, 1}, {8, 451}, {84, 51}, {84, 5, 1}, {8, 45, 1}, {8, 4, 51}... | stackexchange_codegolf |
The random Fibonacci sequence is defined as follows:
$$
f_n =
\begin{cases}
f_{n-1}+f_{n-2} \text{ with probability } 1/2 \\
f_{n-1}-f_{n-2} \text{ with probability } 1/2 \\
\end{cases}
$$
$$
f_1 = f_2 = 1
$$
i.e. whether the next term is the sum or difference of the previous two is chosen at random, independently of ... | stackexchange_codegolf |
Create a program or function which takes a list of strings as input, and outputs the longest string that is a substring of all input strings. If there are several substrings of equal length, and no longer substring, output any one of them.
This may mean outputting the empty string.
If there are several valid outputs, ... | stackexchange_codegolf |
In a very unusual accident involving a small sample of radium, an electrocuted whale, and three gummy bears, some of The Management™'s source code has been mutated. Little does The Management™'s boss know, it was actually the Cops© who had been responsible, in an attempt to thwart The Management™'s "evil" plans. So the... | stackexchange_codegolf |
Challenge
You have a Chinese Checkers board looking like this:
board = [
[''],
['', ''],
['', '', ''],
['', '', '', '', '', '', ''],
['', '', '', '', '', ''],
['', '', '', '', ''],
['', '', '', '', '', ''],
['', '', '', '', '', '', ''],
['', '', ''],
... | stackexchange_codegolf |
Inspired by this Puzzling challenge.
Challenge
Given a 2D rectangular grid where each cell is either an empty space or a wall, find the path (or one of the paths) from the top left cell to the bottom right, which satisfies the following:
Only movement to one of four adjacent cells is allowed.
The path breaks (or passe... | 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 |
This challenge requires integration with C, so you can stop reading if you're not interested.
Matrix multiplication is a simple operation, but the performance depends a lot on how efficiently the code is written.
Let's compute m = x * y. The following code is the implementation of the textbook algorithm.
for (int i = 0... | stackexchange_codegolf |
Related.
Given a number \$n\$, Euler's totient function, \$\varphi(n)\$ is the number of integers up to \$n\$ which are coprime to \$n\$. That is, no number bigger than \$1\$ divides both of them.
For example, \$\varphi(6) = 2\$, because the only relevant numbers are \$1, 5\$. This is OEIS A000010.
We can now define th... | stackexchange_codegolf |
This is cops-and-robbers. This is the Cops thread. For the robbers thread, go here.
I've noticed a number of OEIS (On-line Encyclopedia of Integer Sequences) challenges since I joined the site. It seems only fair that we have a cops-and-robbers challenge that determines who is the master of online integer sequences, on... | stackexchange_codegolf |
One element of the list aa, ab, ba, bb, c has been removed, and the remainder shuffled and joined with no separator. Find the missing element.
For example, if the input was aaabbac, this is made by concatenating aa ab ba c, so the output would be bb.
Rules
Standard I/O rules apply.
You must take input as a string (or ... | stackexchange_codegolf |
There is a competition with \$n\$ participants in total. Alice is one of the participants. The outcome of the competition is given as a ranking per participant with a possibility of ties; e.g. there can be three participants who won 2nd place, and the next best participant gets the 5th place.
More rigorously, a partici... | stackexchange_codegolf |
A normal Brainfuck program starts out with an array of cells, all containing the number 0. This program, on the other hand, must be able to run starting with any number x in the leftmost cell. The only rule is that at the end of program execution, the "pointed-to" cell must be cell x. (The leftmost cell is cell 0).
Ea... | stackexchange_codegolf |
Dealing with equations in the absence of a good equation editor is messy and unpleasant. For example, if I wanted to express an integral and its solution, it might look something like this:
Integral[x^3 e^(-m x^2 b /2), dx] =
-((2 + bmx^2)/(b^2*e^((bmx^2)/2)*m^2))
At integrals.wolfram.com, this is called "input form." ... | stackexchange_codegolf |
Definition
a(1) = 1
a(2) = 1
a(n) = a(n-a(n-1)) + a(n-a(n-2)) for n > 2 where n is an integer
Task
Given positive integer n, generate a(n).
Testcases
n a(n)
1 1
2 1
3 2
4 3
5 3
6 4
7 5
8 5
9 6
10 6
11 6
12 8
13 8
14 8
15 10
16 9
17 10
18 11
19 11
20 12
Reference
Obligatory OEIS A005185
| stackexchange_codegolf |
My first code golf question post! Hope u like it ;-)
The task is simple. Write either an stdin-stdout program or a function. Input is a 2D array which contains only either characters or the integer 0. You are allowed to replace the integers with the character '0' or null instead in any language (kudos to @SuperStormer ... | stackexchange_codegolf |
Somehow, we don't yet have a challenge for finding the inverse of an arbitrarily-sized square matrix, despite having ones for 3x3 and 4x4, as well as a more complex version.
Your task is, given a square \$n\times n\$ non-singular matrix \$M\$, output the matrix \$M^{-1}\$ that satisfies
$$MM^{-1} = I_n$$
There are a nu... | stackexchange_codegolf |
This challenge is simple: Take a path to an png image file as input and overwrite that file with a copy of itself rotated 90 degrees clockwise. You may assume that the file has dimensions of 128x128 pixels. You may not use image metadata modifications (like Exif) to rotate the image; the pixels themselves must be trans... | stackexchange_codegolf |
Given N integers, output the sum of those integers.
Input
You may take the integers in any reasonable format, including:
stdin
arguments
an array or list
Rules
Your code must not include the characters + or -.
Standard loopholes apply. Take note of Abusing native number types to trivialize a problem.
This is code-... | stackexchange_codegolf |
Overview
Shue (Simplified Thue) is a language that was designed by AnttiP for this challenge. A Shue program consists of the possible outputs and a list of string replacements. For example, the following program prints "yes" if an unary string is even:
yes
no
11=2
12=1
22=2
1=no
2=yes
Try it online!
The possible outpu... | stackexchange_codegolf |
Sound synthesizers use envelope generators to control how certain parameters of the sound (such as overall loudness) change with time. In many synthesizers an envelope is defined by four parameters, as represented in the following figure from Wikipedia:
Attack time (A): time taken for the envelope to reach its maximum... | stackexchange_codegolf |
As you may know, the typical binary floating point numbers in a computer language are quite different than the typical integer numbers in a computer language. Floating point numbers can represent a much larger range, and can represent fractional amounts, however there is a trade-off that is frequently elided.
The dista... | stackexchange_codegolf |
Euler's totient function, \$\varphi(n)\$, counts the number of integers \$1 \le k \le n\$ such that \$\gcd(k, n) = 1\$. For example, \$\varphi(9) = 6\$ as \$1,2,4,5,7,8\$ are all coprime to \$9\$. However, \$\varphi(n)\$ is not injective, meaning that there are distinct integers \$m, n\$ such that \$\varphi(m) = \varph... | stackexchange_codegolf |
Given a range and a list thereof, while keeping the existing intervals in the list unchanged, split the additional range into sub-intervals and add them to the list, such that all the ranges in the final list are disjoint and contain all numbers present in the input ranges.
The goal is to create an insertInterval(inte... | stackexchange_codegolf |
This is the logo for LAPACK, a widely used software library for numerical linear algebra.
Your task is to print the logo (color and matrix brackets not required) as this exact string. Trailing newline is allowed.
L A P A C K
L -A P -A C -K
L A P A -C -K
L -A P -A -C K
L A -P -A C K
L -A -P A C -K
| stackexchange_codegolf |
Just because the reverse and palindrome were not too challenging individually :)
Write a program (full program or function) that satisfies the following: given a string input,
the program as-is outputs the input string unchanged.
the program reversed outputs the input string reversed.
the program palindromized outputs... | stackexchange_codegolf |
Challenge
Given the following C# method:
private static bool Test(bool a, bool b)
{
if (a && b) return false;
if (a) if (b) return true;
return false;
}
Supply the values a and b so that true is returned.
Winning condition
The first entry who can supply the correct arguments to make the given method evalua... | stackexchange_codegolf |
When you leave, my challenges fade to grey, 0A0AE16, 0A0A0AE16...
A while ago, I made this programming language (https://esolangs.org/wiki/Dragostea_din_tei) which uses an interesting number system. It is base two for integers, but for decimals it divides a base two integer by a power of ten.
The input should be a floa... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.