instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Robbers' Thread Your challenge is to find an existing challenge, and implement it in a way such that certain inputs fail. At least one input must not produce the correct output (use the other submissions on the challenge as a reference for this, but be sure to double-check). This must fail consistently, and you must kn...
stackexchange_codegolf
The brilliant engineers at <enter company you love to hate> have struck again. This time they've "revolutionised" the generation of random permutations. "Every great invention is simple" they say and their magical new algorithm is as follows: Start with a list 1,2,3,...,n of numbers to permute. For each element x in t...
stackexchange_codegolf
I have the code below working. But there must be a better way. file <- "http://s3.amazonaws.com/assets.datacamp.com/production/course_1127/datasets/tmp_file.csv" x <- read.csv(file = file) ts <- xts(x = x, order.by = as.Date(rownames(x), "%m/%d/%Y")) cd=coredata(ts) for (j in 1:length(names(ts))) cd[,j]<-cd[,j]/cd[1,...
stackexchange_codegolf
This was fun! However with only three digits, the fun was over way too soon. This challenge is similar, but we'll keep the fun going. The Challenge Print as many digits of the Golden Ratio φ as possible. The Golden Ratio is defined as the number that satisfies φ = (φ + 1)/φ and the first 100 digits are given by: 1.618...
stackexchange_codegolf
Given a digit x (between 0 to 9, inclusive) and a number n, calculate the sum of the first n terms of the following sequence: \$x,10x+x,100x+10x+x,\dots\$ For example, if x is 6 and n is 2, then the result will be 6+66 meaning 72. There can be trailing whitespace in the output but not leading whitespace.
stackexchange_codegolf
Challenge Giving a valid arithmetic sum with some missing numbers, output the full expression. Example: 1#3 123 + 45# => + 456 -------- -------- 579 579 Input Expression format can be an array ["1#3", "45#", "579"], a string "1#3+45#=579", or 3 inputs f...
stackexchange_codegolf
Thanksgiving in the United States is coming up on November 24th. Many people will have a large dinner with their families, traditionally including turkey and many side dishes. This typically means the family members must coordinate who's going to bring each of the various dishes. In this challenge, the goal is to write...
stackexchange_codegolf
Given an integer \$ n \ge 2 \$, you need to calculate \$ \lfloor n \log_2(n) \rfloor \$, assuming all integers in your language are unbounded. However, you may not ignore floating-point errors - for example, in python lambda n:int(n*math.log2(n)) is an invalid solution, because for example for n=10**15, int(n*math.log2...
stackexchange_codegolf
Challenge The primitive circle problem is the problem of determining how many coprime integer lattice points \$x,y\$ there are in a circle centered at the origin and with radius \$r \in \mathbb{Z}^+ \$ such that \$x^2+y^2 \le r^2 \$. It's a generalization of Code-Golf: Lattice Points inside a Circle. Input Radius \$r...
stackexchange_codegolf
Challenge: I want to know about the real roots of polynomials. As a pure mathematician, I care about the existence of such roots, rather than their numeric values. The challenge is to write the shortest program that takes a polynomial, of degree at most 4, and simply returns how many distinct real roots said polynomial...
stackexchange_codegolf
In C++, there exists a a <=> b three-way comparison operator that, for numerical types, does the following: If a < b, then return a negative number. If a = b, then return a (mathematically speaking) sign-less number. If a > b, then return a positive number. The Challenge Implement the shortest full program, function,...
stackexchange_codegolf
"Buzzing" Bill is a well respected beaver. He is the hardest working in his home dam. He was a strong beaver and was able to lift more logs than anyone at the dam. Unfortunately Buzzing Bill's career came to an end in a tragic accident. Being such a prominent figure in his town, the Beaver newspaper wanted to write a ...
stackexchange_codegolf
This is a repost of this challenge Challenge There is an old, popular riddle: Find an English word with 8 letters that, taken away one letter, creates a new valid word. Repeat that until there are no letters left. Example solution: starting staring string sting sing sin in I Your task is to write a program, which t...
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
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
Okay, I propose a shortest-key-logger challenge. As explained by the gentleman at "Are key-logger questions allowed?", strict rules have to be imposed in order to make this challenge valid for PPCG. The key-logger has to run on Windows, Linux or Mac OSX (any programming language is welcome). Upon execution, it has to ...
stackexchange_codegolf
Related: Clearly parenthesize APL trains Background In the most basic form, APL has two kinds of tokens: arrays and functions. For this challenge, we will use a lowercase letter a-z for an array, and an uppercase letter A-Z for a function. Furthermore, we will assume each character is a token of its own; Fx is equivale...
stackexchange_codegolf
Oh, No! the sentences are out of balance. Quick! balance them. A word is defined as follows: A sequence of letters [A-Za-z] separated by any non-letter character ([0-9] ~+- etc.) A word is BaLanCeD if its capitalization is the same forwards as it is backwards. Given a sentence with words, balance each word by capita...
stackexchange_codegolf
There are 97 ASCII characters that people encounter on a regular basis. They fall into four categories: Letters (52 total) ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz Numbers or Digits (10 total) 0123456789 Symbols & Punctuation (32 total) !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ Whitespace (3 total) Space , tab ...
stackexchange_codegolf
Challenge Display to the screen or write to stdout this exactly: ** ** **** **** **** **** **** **** **** ********** ********** ********** Winning This is code-golf, so the shortest submission (in bytes) wins.
stackexchange_codegolf
This is a repost of Evolution of “Hello World!”, originally written by user Helka Homba It should not be closed as a duplicated, due to meta consensus here. The original was asked over two years ago and was last active more than six months ago. I have permission from Helka Homba to post this here Since the original, ma...
stackexchange_codegolf
Given a matrix, output a representation of the matrix where the top left element is on top, the anti-diagonal is the central row and the bottom right element is at the bottom. For example, consider the following matrix: 1 2 3 4 5 6 7 8 9 The diamond version of this matrix is: 1 4 2 7 5 3 8 6 9 Inputs and output...
stackexchange_codegolf
Challenge Given a positive-length string \$S\$, a divisor of \$S\$ is another (not necessarily distinct) string for which there exists a number \$a\$ such that when we repeat the divisor \$a\$ times, we get the string \$S\$. For example, the string abcd is a divisor of the string abcdabcd with \$a=2\$. Your challenge i...
stackexchange_codegolf
(No, not this nor any of these) Given a string and a list of strings, fill in the all blanks in the input string with corresponding strings. Input/Output The input string contains only alphabetic characters, spaces, and underscores. It is nonempty and does not start with an underscore. In other words, the input string ...
stackexchange_codegolf
Challenge Given an array of positive integers and a threshold, the algorithm should output a set of consecutive-element-groupings (subarrays) such that each group/subarray has a sum greater than the threshold. Rules The solution should honor two additional criteria: be of highest cardinality of the groups (i.e. highes...
stackexchange_codegolf
This is a quine challenge related to Write the shortest self-identifying program (a quine variant) Write a function or a full program that compares lexicographically its source code and input, that is, output three distinct values of your choice telling if input / source code is Bigger, Equal or Less than source code /...
stackexchange_codegolf
Please note: By its nature, the spec for this challenge is difficult to understand. It probably requires at least a freshman course in computability theory, or equivalent background reading. In addition, the challenge itself is rather hard. Answering it will require writing an entire interpreter for some subset of your...
stackexchange_codegolf
The aim is to trim elements in from the ends of a list, depending on if they are in a second list of "falsey" results. For example, if the first list is [-1, 1, 2, 0, -1, 3, -1, 4, -1, -1] and the second is [-1], then we would remove all leading and trailing -1s from the first input, but not any -1s in the middle: [1, ...
stackexchange_codegolf
Given a ragged list of positive integers, where the maximum depth is \$d_\text{max}\$, return the same list, except for every element \$e\$, its depth is \$d_\text{max}+1-d_e\$ (where \$d_e\$ is the depth of that element). Your output should contain the minimal number of brackets, and you can assume the same from your ...
stackexchange_codegolf
Objective Given an ASCII character, toggle its "shift-ness" on the standard US keyboard (ANSI-INCITS 154-1988 (R1999)), then output it. Mapping ) ↔️ 0 ! ↔️ 1 @ ↔️ 2 # ↔️ 3 $ ↔️ 4 % ↔️ 5 ^ ↔️ 6 & ↔️ 7 * ↔️ 8 ( ↔️ 9 " ↔️ ' + ↔️ = , ↔️ < - ↔️ _ . ↔️ > / ↔️ ? : ↔️ ; (Capital Latin letters) ↔️ (Small Latin letters) [ ↔️ { \...
stackexchange_codegolf
The problem over here introduces an new type of strings: if you split the string into equal halfs and swap the pairs, it produces the same output as sorting the string. We call that a half-sort. Given a purely ASCII string, check if the string is in a half-sort. An example of a half-sort string The string node is a hal...
stackexchange_codegolf
Your task is to calculate the amount you have to pay for prescribed medication at a pharmacy in Germany. The amount is simply based on the full price of the item, which will be your input. It is a decimal number with exactly two fractional digits (ex. 5.43). You can assume it's strictly positive. Your task is to calcul...
stackexchange_codegolf
You are given an array A of length N and an array B of length N-1. You need to output array where items alternates: A[0], B[0], A[1], B[1], ..., B[N-2], A[N-1] Restrictions: N>0 Type of items is not specified, but code should work at least for unsigned integers. Sample input: A = [1,2,3,4] B = [7,8,9] Sample output:...
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
Related From Wikipedia: In number theory, the Calkin–Wilf tree is a tree in which the vertices correspond one-to-one to the positive rational numbers. The tree is rooted at the number \$1\$, and any rational number expressed in simplest terms as the fraction \$\frac{a}{b}\$ has as its two children the numbers \$\frac{...
stackexchange_codegolf
I'm currently working with a branchless language which does not have native Less-Than, Greater-Than or Equal-To functions. I do however have min, max and abs functions and standard arithmetic (+, -, / and *) available to me. I'd like to create these three functions (as L(a, b), G(a, b) and E(a, b) respectively, which w...
stackexchange_codegolf
Challenge closed, the shortest answer has been acccepted. A military projection is a projection where all lengths and the angles in the X-Z plane remain unattuned. Your task is to print a cube in military projection using /, |, \, -, and any whitespaces you want, given any integer greater than zero as it's side length....
stackexchange_codegolf
Background Page 219 of A New Kind of Science (a book by Stephen Wolfram, the creator of Mathematica) shows an interesting 2D pattern generated by constraints. The relevant section in the book starts at page 210; you can browse other pages for more context. In short, the large binary image is the result generated by 12...
stackexchange_codegolf
This challenge is as follows. (Uhoh no! Now everyone is going to use reciprocal division. Now all the answers are going to look the same and lose originality, ugh!) Given two integers multiply them, ... but you can't use the multiplication symbols "*" and "x". As you probably know multiplication is just an extension...
stackexchange_codegolf
Preface The available keys are the keys of the A through G and A minor through G minor. The Challenge Create a program that creates and saves to a playable audio file a "song" of using (uniformly distributed) random chords. The song must be of length n and in key k. The chords in each "song" must conform to the key. If...
stackexchange_codegolf
Context When I was a little kid, I watched a Disney movie where Goofy told his son "Boy, even a broken clock is right two or three times a day." (see this youtube clip, courtesy of @Arnauld). Rationale Given the previous statement, we wish to look at a clock that is stopped and answer the following question: is this cl...
stackexchange_codegolf
Introduction For the ones who never heard of this game before. You are playing a ball which needs to survive as long as possible. This is done by moving to the left or right, going to the holes. Since the map moves upwards, you need to go downwards to survive longer. If you search for images, you probably know which ga...
stackexchange_codegolf
Description A Caesar Shift is a very simple monoalphabetic cipher where each letter gets replaced by the one after it in the alphabet. Example: Hello world! -> IFMMP XPSME! (IBSLR, EGUFV! is the output for the actual challenge, this was an example of shifting by 1.) As you can see, spacing and punctuation remain unatt...
stackexchange_codegolf
The harmonic series is the "infinite sum" of all the fractions of the form \$\frac1n\$ for \$n\$ positive integer. I.e. the harmonic series is $$\frac11 + \frac12 + \frac13 + \frac14 + \cdots$$ It is well-known that this sum diverges, which means that if you define $$ H_n = \frac11 + \frac12 + \cdots + \frac1n$$ Then t...
stackexchange_codegolf
Challenge Your program needs to take an input of a string, where the string has only letters, no special characters, no numbers, and no accents (they look all weird). Then, your program should output a superscript version. Example Input: hello world Output: ʰᵉᶫᶫᵒ ʷᵒʳᶫᵈ Test Cases hello - ʰᵉᶫᶫᵒ code - ᶜᵒᵈᵉ golf - ᵍᵒᶫᶠ a...
stackexchange_codegolf
Background The number of values for a given type is called the cardinality of that type, and that of type T is written as |T|. Haskell and a few other languages have a certain set of enum types, each of which has a small finite number of values (the exact names vary, so this challenge uses some arbitrarily chosen names...
stackexchange_codegolf
Sometimes in chat, if someone says something you agree with, you'll send a message with an ^, which points at the message above: Radvylf: Cats are far superior to JavaScript You: ^ Sometimes you'll also add some text: Radvylf: I sure do like integers You: I mostly agree with ^ but floats are pretty neat too You can a...
stackexchange_codegolf
Since it was Pi day recently, I have noticed a number of challenges that ask you to calculate pi. Of course, a quiche lorraine is not quite a pie (you can claim a Bonus Score¹ of +1 if you guessed the challenge off of the title). As such, your job is to write an algorithm or method that looks like it approximates Pi at...
stackexchange_codegolf
Your challenge is to output this: https://stackoverflow.com/ https://serverfault.com/ https://superuser.com/ https://meta.stackexchange.com/ https://webapps.stackexchange.com/ https://gaming.stackexchange.com/ https://webmasters.stackexchange.com/ https://cooking.stackexchange.com/ https://gamedev.stackexchange.com/ ht...
stackexchange_codegolf
Consider the following spiral of positive integers: We now define grambulation as a binary operation \$\lozenge : \mathbb N \times \mathbb N \to \mathbb N\$, using this grid. Some example inputs and outputs for grambulation are: \begin{align*} 1 & \lozenge 9 = 25 \\ 1 & \lozenge 2 = 11 \\ 11 & \lozenge 10 = 25 \\ 9 & ...
stackexchange_codegolf
Source: Wikipedia For this challenge, you should write two programs which resemble the figure and ground of the above image, such that one of them prints figure and the other prints ground. Specifically: Write a program which takes no input and prints the string figure. The only allowed whitespace characters in your ...
stackexchange_codegolf
This challenge is inspired by Fortran's idiosyncratic implicit typing rules. Your task will be to determine the data type of the object GOD according to the implicit typing rules explained below. Background Fortran 77 has six data types: CHARACTER, COMPLEX, DOUBLE PRECISION, INTEGER, LOGICAL, and REAL. Any object not e...
stackexchange_codegolf
Context At Hogwarts School of Witchcraft and Wizardry, students are sorted into 4 houses, Gryffindor, Ravenclaw, Slytherin and Hufflepuff. This sorting is done by a magical hat, called the Sorting Hat. Task Your task is to code a sorting hat. In other words, you should create some deterministic rule that, given the nam...
stackexchange_codegolf
The task Given an ascii string, output a program in my esolang MAWP that outputs the inputted string when run. Useful functions in MAWP Numbers from 0-9: Pushes the number to stack M Takes the top two numbers off stack and pushes the sum to stack A Takes the top two numbers off stack and...
stackexchange_codegolf
You are given two strings \$a\$ and \$b\$ consisting of characters from a to z in lowercase. Let \$n\$ be the length of \$a\$. Let \$m\$ be the length of \$b\$. Let \$a'\$ be the string \$a\$ repeated \$m\$ times. Let \$b'\$ be the string \$b\$ repeated \$n\$ times. Check whether \$a'\$ is lexicographically less than \...
stackexchange_codegolf
Description "Imtiaz Germain primes" is not a technical name in Mathematics, but my weird creation, in the memoir of the famous mathematician Sophie Germain. These primes can be generated by the following process: 1. Take a Safe prime 2. Apply 2p + 1 on it to obtain a composite number 3. Apply 2p + 1 once more to obtain...
stackexchange_codegolf
4-Man Standoff Description You've somehow found yourself into a four-way standoff. A loaded gun rests in your hands, and some grenades are hooked on your belt. The objective is to have the most health at the end of a standoff. A standoff is over when at most one person has a positive amount of health. Each player has ...
stackexchange_codegolf
OEIS A000009 counts the number of strict partitions of the integers. A strict partition of a nonnegative integer n is a set of positive integers (so no repetition is allowed, and order does not matter) that sum to n. For example, 5 has three strict partitions: 5, 4,1, and 3,2. 10 has ten partitions: 10 9,1 8,2 7,3 6,4 ...
stackexchange_codegolf
Definitions: A triangle is considered a right triangle if one of the inner angles is exactly 90 degrees. A number is considered rational if it can be represented by a ratio of integers, i.e., p/q, where both p and q are integers. A number n is a congruent number if there exists a right triangle of area n where all thr...
stackexchange_codegolf
I noticed that there's no such question, so here it is: Do you have general tips for golfing in x86/x64 machine code? If the tip only applies to a certain environment or calling convention, please specify that in your answer. Please only one tip per answer (see here).
stackexchange_codegolf
It's time for CGCC to demonstrate our musical talent! In this challenge, you're going to compose songs while keeping your byte count as small as possible. On Day 0, multiple answerers will post a function or program that outputs nothing/an empty string. They will also give a single line that next day's answers must out...
stackexchange_codegolf
For many games played on a grid, hexagons are the Clearly Superior Choice™. Unfortunately, many free game art sites only have seamless tile sets for square maps. On a past project, I used some of these, and manually converted them to hexagons. However, I've gotten lazy in my old age. It should be easy to automate the p...
stackexchange_codegolf
Let's consider the following sequence: $$9,8,7,6,5,4,3,2,1,0,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71...$$ This is the sequence of \$9\$'s complement of a number: that is, \$ a(x) = 10^d - 1 - x \$ where \$ d \$ is the number of digits in \$ x \$. (A061601 in the OEIS).Your task is to add the first \$n\...
stackexchange_codegolf
Write a program (or function) (let's call it P1), that when run, outputs another program P2 of the same language and exactly 1 byte longer than P1. Program P2 when run, should output a 3rd program P3 that's 1 byte longer than P2. P3 must output a program P4 that's one byte longer than P3, etc. The same for P5, P6, ...,...
stackexchange_codegolf
What do you get when you cross Pascal's Triangle and the Fibonacci sequence? Well, that's what you have to find out! Task Create a triangle that looks like this: 1 1 1 2 2 2 3 5 5 3 5 10 14 10 5 8 20 32 32 20 8 Basically, instead of each cell being the sum of the cells ...
stackexchange_codegolf
Tamagotchi and Giga Pets were small electronic devices which simulated a little virtual pet. This pet had several stats, like health, hunger, etc. I recently wrote this example: import msvcrt,os,sys;d=m=100;h=s=t=p=0;f=10 while 1: os.system('cls'if os.name=='nt'else'clear');print("health:",d,"\nhunger:",h,"\nsleep:",...
stackexchange_codegolf
You might already be familiar with the game: Basketball FRVR in facebook. There are two types of score you can make: A virgin-shot:(we call it so in our country :D) When the ball enters the basket without touching the rim or A stale shot: When the ball enters the basket, but after touching the rim. The game is over ...
stackexchange_codegolf
Your program must print out this exact sequence: 1 2 4 10 24 54 116 242 496 1006 2028 4074 8168 16358 32740 65506 131040 262110 NOPE! As usual, shortest program wins. Standard code golf rules apply.
stackexchange_codegolf
Introduction: A typical cartoonish cactus usually looks like this: One big stem in the middle, with some L-shaped branches sticking out. We'll use this general shape for this challenge. Challenge: Given a pair of words, create an ASCII-art cactus with two upside down alphabets as stem. The first word is the left branc...
stackexchange_codegolf
Given a positive integer nesting level n and string s of printable ascii characters( to ~, output a program which, when run in the same language, outputs a program which outputs a program . . . which outputs the string s. A total of n programs should be generated, all of which should be run in the same language as your...
stackexchange_codegolf
7-segment digits can be represented in ASCII using _| characters. Here are the size 1 digits: _ _ _ _ _ _ _ _ | _| _| |_| |_ |_ | |_| |_| | | | |_ _| | _| |_| | |_| _| |_| Larger sizes are formed by making each segment proportionately longer. Here are a couple size 3 digits. ___ ...
stackexchange_codegolf
Task Write a function/program that, given three positive integers a, b and c, prints a Truthy value if a triangle (any triangle) could have side lengths a, b and c and outputs a Falsy value otherwise. Input Three positive integers in any sensible format, for example: three distinct function arguments, f(2, 3, 5) a lis...
stackexchange_codegolf
You have been hired by the government of North Dakota to encrypt the state's communications. Write two programs, one to encrypt a message and one to decrypt that message. The government is not really tech-savvy, so the encryption algorithm does not need to be sophisticated; just make sure the result doesn't look simila...
stackexchange_codegolf
Taylor series are a very useful tool in calculating values of analytic functions that cannot be expressed in terms of elementary functions, using only information about that function at a single point. In this challenge, you won't be actually doing any math with them, but merely making string representations of taylor ...
stackexchange_codegolf
The title of Numberphile's newest video, 13532385396179, is a fixed point of the following function \$f\$ on the positive integers: Let \$n\$ be a positive integer. Write the prime factorization in the usual way, e.g. \$60 = 2^2 \cdot 3 \cdot 5\$, in which the primes are written in increasing order, and exponents of 1...
stackexchange_codegolf
The majority function is a boolean function which takes three boolean inputs and returns the most common. For instance if maj(x,y,z) is the majority function and T denotes true and F denotes false then: maj(T,T,T) = T maj(T,T,F) = T maj(T,F,F) = F maj(F,F,F) = F This question concerns writing boolean functions as comp...
stackexchange_codegolf
Your challenge, should you choose to accept it, is to take as input: A program in DirectionLang (as an ASCII string consisting of DirectionLang instructions) A list of pairs of integers, henceforth known as the pretty places. This list may be taken in any reasonable format. You should then output a truthy value if th...
stackexchange_codegolf
This is a code-challenge with a custom scoring system, where the lowest score wins. Introduction Many smartphones allow to enter text by swiping your finger across the 2D virtual keyboard. This technology is usually combined with a prediction algorithm that outputs a list of guessed words, sorted from most likely to le...
stackexchange_codegolf
When Alice was touch typing on her QWERTY keyboard (Figure 1), she accidentally shifted both of her hands rightwards by one key, so q became w, w became e, etc. (p became [). Spaces were not affected because the space bar was quite big. Your task is to help her fix her message using the shortest number of bytes, i.e. u...
stackexchange_codegolf
To "function nest" a string, you must: Treat the first character as a function, and the following characters as the arguments to that function. For example, if the input string was Hello, then the first step would be: H(ello) Then, repeat this same step for every substring. So we get: H(ello) H(e(llo)) H(e(l(lo))) H(...
stackexchange_codegolf
Your task is to translate a 103-smooth number into an English word, using the method described below. How? Generate the list of prime factors (with repetition) of the input number. Sort the list: If 2 is not one of the prime factors, sort the list in ascending order. If 2 is one of the prime factors, remove it from ...
stackexchange_codegolf
Presented in honor of APL as an interactive tool turning 50 this year Background Ken [Iverson] presented his paper Formalism in Programming Languages in August 1963 at a Working Conference on Mechanical Language Structures, Princeton, N.J. The list of conferees is full of famous and soon-to-be famous names, and a few ...
stackexchange_codegolf
Back in 2018, there has been introduced new law in Poland to ban trading on sundays, but certain exceptions have been made (listed below). The task today is to determine, can one trade on the sunday provided by the user (according to these rules). Rules You can trade only if one of the following is satisfied: The day ...
stackexchange_codegolf
Definition An "integer triangle" is one with integer coordinates. For example the following triangle is an integer triangle: (0, 0), (0, 1), (1, 2) with perimeter 1 + sqrt(2) + sqrt(5) ≈ 4.650. Task The goal of this challenge is to count all integer triangles (up to congruence) with perimeter less than n. Input and Ou...
stackexchange_codegolf
Identify whether an IP address is internal, global, link-local, or reserved. Input should be an IPv4 address in decimal octets separated by periods. Output should be 0 for link-local (RFC 3927), 1 for internal (RFC 1918), 2 for global IPs (Internet), and 3 for otherwise reserved addresses. All these address types are d...
stackexchange_codegolf
There are clever ways of determining whether a number is a power of 2. That's no longer an interesting problem, so let's determine whether a given integer is an integer power of -2. For example: -2 => yes: (-2)¹ -1 => no 0 => no 1 => yes: (-2)⁰ 2 => no 3 => no 4 => yes: (-2)² Rules You may write a program or a func...
stackexchange_codegolf
Okey, we all know the normal way to throw a IllegalArgumentException in Java: throw new IllegalArgumentException(); // 37 characters But there must be a shorter (as in less characters) ways to do so. How can we produce a java.lang.IllegalArgumentException with even less code? The code fragment has to compile and run ...
stackexchange_codegolf
In the video game Minecraft, you can obtain beacons and put them on pyramid-like structures to give you special effects, such as speed or jump boost. Your task is to, given an effect, construct the beacon pyramid required for it. There are multiple sizes of beacon pyramids, required for different effects. The largest h...
stackexchange_codegolf
I recently saw this language in a challenge and it's awesome. Does anyone have some tips for code-golfing in it? Your tips should be at least somewhat specific to MarioLANG. Please post one tip per answer.
stackexchange_codegolf
Write a program that will generate a "true" output iff the input matches the source code of the program, and which generates a "false" output iff the input does not match the source code of the program. This problem can be described as being related to quines, as the program must be able to somehow compute its own sour...
stackexchange_codegolf
Part of the Code Golf Advent Calendar 2022 event. See the linked meta post for details. As a Christmas gift, you were given a toy solar system. In this toy, all the orbits are circular and happen in the same plane. Each planet starts at a fixed location, has a fixed circumference orbit, and moves at a fixed speed (all...
stackexchange_codegolf
I need this down to as few characters as possible. I would use Test-NetConnection but I need PSv2 compatability. Any help would be appreciated. $socket = new-object Net.Sockets.TcpClient $socket.Connect("192.168.5.5",445) $socket.Connected As a note I have tried this but it doesn't work (new-object Net.Sockets.TcpCl...
stackexchange_codegolf
Every odd degree polynomial has at least one real root. However this root does not have to be a rational number so your task is to output a sequence of rational numbers that approximates it. Rules Your input is an odd degree polynomial \$f\$ with integer coefficients in any reasonable format. You must output a sequen...
stackexchange_codegolf
This is a CMC (chat mini challenge) that I posted in our chatroom, The Ninteenth Byte, a bit ago. The Challenge Given a positive integer x, depending on the last 2 bits of x, do the following: x & 3 == 0: 0 x & 3 == 1: x + x x & 3 == 2: x * x x & 3 == 3: x ^ x (exponentiation) Input/Output Single Integer -> Single Int...
stackexchange_codegolf
The Challenge Your task is to create a program or function that outputs the following with no input: a bb ccc dddd eeeee ffffff ggggggg hhhhhhhh iiiiiiiii jjjjjjjjjj kkkkkkkkkkk llllllllllll mmmmmmmmmmmmm nnnnnnnnnnnnnn ooooooooooooooo pppppppppppppppp qqqqqqqqqqqqqqqqq rrrrrrrrrrrrrrrrrr sssssssssssssssssss tttttttttt...
stackexchange_codegolf
Challenge Display to the screen or write to stdout this exactly: ** ** **** **** **** **** **** **** **** ********** ********** ********** Winning This is code-golf, so the shortest submission (in bytes) wins.
stackexchange_codegolf
This is a sequence question of the usual type, as applied to OEIS sequence A038666. That is, do either of the following: Accept no or any input, and output A038666 until the heat death of the universe. Accept a positive integer as input, and output the \$n\$th term of A038666 or its first \$n\$ terms. (If using \$0\$-...
stackexchange_codegolf
Create a program that can be run in 4 different languages such that: One language prints "Hello World!" One language outputs its own source code One language outputs 99 bottles of beer on the wall, that is: 99 bottles of beer on the wall 99 bottles of beer Take one down, pass it around 98 bottles of beer on the wall ...
stackexchange_codegolf
In chess, the Fool's Mate is the fastest possible way to reach checkmate. It is reached with Black's second move. In chess notation, one possible sequence of moves that achieves Fool's Mate is 1.f3 e6 2.g4 Qh4#. This is not the only possible way to achieve this checkmate (in the same number of moves). There are three ...
stackexchange_codegolf
Like Brainfuck or JSFuck would be efficient in terms of number of characters needed, but what languages would have the highest amount of information per character? I was thinking of APL and J but there has to be more. My goal with this question is to find a program that would allow a person with theoretically infinite ...
stackexchange_codegolf