instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Your task, if you wish to accept it, is to write a program that outputs a non-zero number(can be integer or float). The tricky part is that if I reverse your source code, the output must be the original integer negated. Rules You must build a full program. That is, your output has to be printed to STDOUT. Both the num...
stackexchange_codegolf
Your challenge is to turn a Japanese word and a dictionary pitch accent number into a new string where the rises and falls in pitch are marked: e.g. (2, ウシロ) → ウ/シ\ロ. To help you out with this, I'll explain a little about Japanese phonology. Background: on moras For the purpose of this challenge, we will write Japane...
stackexchange_codegolf
Background In the sport of Table Tennis (aka Ping-Pong or Whiff Whaff), two opponents play a sequence of rounds, where each round consists of players hitting a ball back and forth until one player (may or may not be the server) gains a point. Table Tennis has some official rules that make for a good game, but we will u...
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
The task is to convert a string representing a number in decimal (base 10) representation to duodecimal (base 12). The input is thus a string, the output should be printed. The input number can be positive and negative, can be integer or rational. The decimal and duodecimal representations will have a finite number of ...
stackexchange_codegolf
The goal of this challenge is to check and extend the OEIS sequence A334248: Number of distinct acyclic orientations of the edges of an n-dimensional cube. Take an n-dimensional cube (if n=1, this is a line; if n=2, a square; if n=3, a cube; if n=4, a hypercube/tesseract; etc), and give a direction to all of its edges ...
stackexchange_codegolf
The Debian Linux distribution (and Debian-based distros, like Ubuntu, Kali and others) uses a package-manager called APT. To install program foo you would type into a terminal sudo apt-get install foo One little Easter Egg of APT is the following apt-get moo Which after typing will produce the following output ...
stackexchange_codegolf
Introduction How to prove that 1 = 2: 1 = 2 2 = 4 (*2) -1 = 1 (-3) 1 = 1 (^2) You can just multiply both sides by 0, but that's cheating. This is just bending the rules a little bit. Your challenge: Write a program/function that, when given two integers, outputs a "proof" that the two are equal. Rules Your program's...
stackexchange_codegolf
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
Objective Given an expression involving ternary values, evaluate it into a ternary value. Ternary Values The three truth values in question are the values of Haskell's Ordering, namely LT, EQ, and GT. They stand for "less-than", "equal-to", and "greater-than", respectively. Furthermore, they themselves have an order; L...
stackexchange_codegolf
"First they came..." is a poem by Martin Niemöller: First they came for the Socialists, and I did not speak out- Because I was not a Socialist. Then they came for the Trade Unionists, and I did not speak out- Because I was not a Trade Unionist. Then they came for the Jews, and I did not speak out- Because I was not a...
stackexchange_codegolf
I see from this SMBC comic that Zach Weinersmith is offering a generous 14 points to anybody who can find a way of generating the following series: 0, 1, 4, -13, -133, 52, 53, -155 Now, we all know that there are infinite ways of generating any given numeric series, so Zach is clearly just giving those points away. Bu...
stackexchange_codegolf
Objective: Print all multiples of 32 from 0 to an arbitrary number n. Rules: One argument will be given: a single integer from 0 to 231 - 1. This will be n here on out. The first iteration must be 0, and the last iteration must be n. 0 is to be counted as a multiple of 32. Each time a multiple is encountered, the mult...
stackexchange_codegolf
Chaim Goodman-Strauss, Craig Kaplan, Joseph Myers and David Smith found the following simple (both objectively and subjectively) polygon that tiles the plane, but only aperiodically: Indeed they found a one-parameter family of such aperiodic monotiles or "einsteins". The edges of all tiles in this family meet at 90° o...
stackexchange_codegolf
In a few British newspapers there is a game known as Hidato. It is somewhat similar to Sudoku, albeit instead of having 1-9 in a line and block, it's about placing numbers such that they connect in order from 01 all the way up to the highest one, so they are all touching horizontally, diagonally or vertically. Inputs w...
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
Any general tips for golfing in VB.net? This, similar to Pascal, is a very rarely used language, thus having very few resources online Visual Basic.NET (VB.NET) is a multi-paradigm, managed, type-safe, object-oriented computer programming language. Along with C# and F#, it is one of the main languages targeting the .NE...
stackexchange_codegolf
I'm new to this stackexchange, but I must say I am very impressed by the knowledge of some here, and the original codegolf answers for some questions. I'm not even sure if the following is possible, since my programming language knowledge is very limited, but it sounds like a pretty interesting challenge: Goal: Output ...
stackexchange_codegolf
Your challenge is to write a program to print all the primes (separated by one or more whitespace characters) less than a given integer N with an asterisk (*) next to each twin prime. A twin prime is a prime number that is either two more or two less than another prime. (Hardcoding outputs is allowed, but it is not lik...
stackexchange_codegolf
Introduction One question that I have come across recently is the possibility of dissecting a staircase of height 8 into 3 pieces, and then re-arranging those 3 pieces into a 6 by 6 square. Namely, is it possible to dissect the following into 3 pieces: x xx xxx xxxx xxxxx xxxxxx xxxxxxx xxxxxxxx And rearrange those 3 ...
stackexchange_codegolf
Scrolling through social media, one might encounter something like this: We can see that, following PEMDAS order of operations, the answer is clearly 11 9. For the sake of this challenge, PEMDAS means that multiplication will occur before division, so a/b*c = a/(b*c), not (a/b)*c. The same goes for addition and subtr...
stackexchange_codegolf
Task Implement a kind of "some users are typing" system, which can be found in Discord and some other chat clients. If 1 user (say, Bubbler) is typing, output Bubbler is typing... If 2 users (say, Bubbler and user) are typing, output Bubbler and user are typing... If 3 or more users are typing (say, Bubbler, randomuse...
stackexchange_codegolf
Given some positive integer \$n\$ generate all derangements of \$n\$ objects. Details A derangement is a permutation with no fixed point. (This means in every derangement number \$i\$ cannot be in the \$i\$-th entry). The output should consist of derangements of the numbers \$(1,2,\ldots,n)\$ (or alternatively \$(0,1,...
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
Given only a straightedge and compass, inscribe a rhombus inside the given rectangle, sharing two opposite points. Input Input is the dimensions of the rectangle. In the example shown, that would be 125, 50. You can take input in whatever way is most convenient (as two integers, list, strings, etc). The larger dimensi...
stackexchange_codegolf
Introduction In the prisoner's dilemma, two partners in crime are being interrogated, and have the choice to either betray their partner or stay silent. If both prisoners betray each other, they both get 2 years in prison. If neither betrays (both stay silent), they both get 1 year in prison. If only one betrays and t...
stackexchange_codegolf
This time, we want render the count of bytes in a human readable way to user. Let's write a program (a full one or a function or other acceptable formats) to do this. Input An non-negative integer, in range \$0\leq n<2^{31}\$, which means n bytes. Output A string, the human friendly representation of n bytes. Conventio...
stackexchange_codegolf
You'll get a human-readable question matching one of the following syntaxes, and are expected to print/return the corresponding result. Finding similarities between the human-readable inputs and matching them with minimum size code is explicitly part of the task, so I won't give a formal definition. "Will October begi...
stackexchange_codegolf
Input Two integers: A non-negative integer W in the range 0 to 2^64-1, specifying the weave. A positive integer S in the range 1 to 255, specifying the side length. These can be taken in whichever order suits you. Output An S by S ASCII representation of the requested weave (S newline separated strings of S character...
stackexchange_codegolf
Everyone knows how to add numbers by hand, right?––Well, I hope so, but for anyone who needs a quick reminder: To add 17282 and 1342, you proceed as follows: place the larger (value wise, not number of digits) number above the smaller number and match up the digits 17282 1342 draw the plus sign (+) to the left of th...
stackexchange_codegolf
Write a cat program, a quine, and a Hello World in the same language such that when two specific programs of the three are concatenated in a certain order, you get the third program. It does not matter which program is the first, second, and third are as long as all three types are represented once each. e.g. if \$A\$ ...
stackexchange_codegolf
I like card game challenges so I made this one for the Italian card game Scopa. My family has been playing this game since time immemorial. It has a very interesting scoring system that should be fun to golf. I will post an answer in R to get the fun started, that I am sure people will improve upon. The challenge: figu...
stackexchange_codegolf
Someone I know has no coding experience, but has proposed an algorithm* to determine the character limit of text fields they find online. They copy a string containing the numbers from 1 to 1,000 inclusive, not separated in any way, and they read the last few digits it displays. For example, after pasting, they might s...
stackexchange_codegolf
Manually summing a Cubically cube's faces is tedious and time-consuming, sorta like writing code in Cubically itself. In Most efficient cubifier, I asked you to translate ASCII to Cubically source. One of the answers there uses a cube initialization sequence and then modifies the resulting cube based on the sums of the...
stackexchange_codegolf
Sandbox Your challenge is to write a program that when first run, will do one of the actions below at random with equal chances of both: A cat program A standard cat program: read everything from STDIN and put it on STDOUT (or your language's closest equivalent). Do nothing and halt This shouldn't output anything....
stackexchange_codegolf
This is a cops-and-robbers challenge. For the cops thread, go here. This challenge involves two OEIS sequences chosen by the cops -- S1, S2 -- and how well those sequences can be golfed and obfuscated. The cops are constructing code A that produces S1 and giving a number X that they claim is the best Levenshtein distan...
stackexchange_codegolf
A Belphegor number is a number of the form \$(10^{n+3}+666)*10^{n+1}+1\$ (1{n zeroes}666{n zeroes}1) where \$n\$ is an non-negative integer. A Belphegor prime is a Belphegor number that is also prime. The \$n\$ values of the first few Belphegor primes are 0, 13, 42, 506 (A232448) Task Write a program that either: take...
stackexchange_codegolf
Sandbox Given a boolean matrix representing my grass field, sheep length \$n\$ and wool thickness \$k\$, you will have to count my sheep. A sheep is a single independent unbroken line of sheep length \$n\$ and thickness \$k\$. #|##|# | # #| | #|# are all valid sheep for \$n=2,k=1.\$ ##|###|## | ## ##|###| ## | ## ...
stackexchange_codegolf
Notice: I'm willing to give a bounty to any answer that I find interesting. Your challenge is to design a Turing-complete one instruction set computer (OISC): An OISC is an abstract machine that uses only one instruction – obviating the need for a machine language opcode. With a judicious choice for the single instruc...
stackexchange_codegolf
The newest "nice" OEIS sequence, A328020, was just published a few minutes ago. Number of distinct tilings of an n X n square with free n-polyominoes. This sequence counts tilings up to symmetries of the square. The sequence has six terms, but I'd like to see if folks here can extend it further. Example For n=4 there...
stackexchange_codegolf
Inspired by How do you write dates in Latin? Challenge Given a month-and-day date, output that date in abbreviated Latin, as explained below. Input Input is flexible, following conventions from other date and sequence challenges. You may choose to: Take a date in mm/dd or dd/mm format or two separate month,day argumen...
stackexchange_codegolf
Related: Is this quadrilateral cyclic? Background A tangential quadrilateral is a quadrilateral which has an incircle: Examples include any square, rhombus, or a kite-like shape. Rectangles or parallelograms in general are not tangential. Task Given the four vertices of a quadrilateral (as Cartesian coordinates), dete...
stackexchange_codegolf
Task Write a function that accepts two integers \$a,b\$ that represent the Gaussian integer \$z = a+bi\$ (complex number). The program must return true or false depending on whether \$a+bi\$ is a Gaussian prime or not. Definition \$a+bi\$ is a Gaussian prime if and only if it meets one of the following conditions: \$a...
stackexchange_codegolf
You find yourself in a strange place. A frighteningly dark maze, lit only by dim candles resting in the occasional hallway. Numerous paths lie only in impassable darkness, foreboding and-- ...Hm? What? Pick up a candle and carry it with you? No, no, that would be extremely rude. The Task Given a maze as input, output t...
stackexchange_codegolf
Find the most important character The challenge is to write a program that outputs the most occurrent character in the input string, excluding these bracketing characters ()[]{}. Each submission should consist only of non-trivial* characters. Each solution is scored using the formula in the scoring section. Bracketi...
stackexchange_codegolf
Let me explain one by one the above terms... We will call \$\text{Z-Factorial}(n)\$ of a positive integer \$n\$, \$n!\$ (i.e. \$n\$ factorial) without any trailing zeros. So, \$\text{Z-Factorial}(30)\$ is \$26525285981219105863630848\$ because \$30!=265252859812191058636308480000000\$ We will call Modified Z-Factorial ...
stackexchange_codegolf
The Task Your task is to create a program or a function that, given a sentence, outputs it translated to the Farfallino language. 'Y' is treated as a consonant. The usual rules for farfallino alphabet are based on the substitution of each vowel with a 3 letter sequence where the vowel itself is repeated with an interce...
stackexchange_codegolf
A Hamiltonian path in a graph is a path that visits each vertex exactly once; a Hamiltonian cycle is a Hamiltonian path that is a cycle – the path forms a simple closed loop. In this challenge the graph will be a n x n grid, where n is an even number greater than 2. Here is an example of a Hamiltonian cycle on 12x12 re...
stackexchange_codegolf
I have a set of colored plastic cups. They come in four colors: green, yellow, pink, and blue. When I put them on my shelf, I like to stack them in a certain pattern. Your job is, given a list of any number of four distinct values (to represent the four cup colors), output a visual representation of how I would stack t...
stackexchange_codegolf
This is the robbers' thread. The cops' thread is here. Your challenge is to take an uncracked submission from the cops' thread and find, for what input or inputs, the program will print Hello, World! and a newline. Capitalization, spacing, and punctuation must be exact. Please comment on the cop's submission when you'v...
stackexchange_codegolf
This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include: "Isn't the baby cute?", "Eh, baby shmaby" "Come buy from my store, we ...
stackexchange_codegolf
In @Adám's Dyalog APL Extended, the ⍢ (under) operator means conjugation: apply one function, then a second function, then the inverse of the first. It's fun to think of real-life actions in terms of conjugation: A problem is transformed by g into another domain where it more readily solved by f , and then transfor...
stackexchange_codegolf
You are piloting a spaceship, outfitted with an engine that can accelerate you at 1km/s^2 in the direction the ship is facing (you have very good inertial dampers). You also have thrusters which can rotate you 180 degrees in 1s (rotating 45 degrees takes 0.25s, etc.). You see on your scanner another ship, and decide t...
stackexchange_codegolf
I was asked this question in an interview but I was unable to figure out any solution. I don't know whether the question was right or not. I tried a lot but couldn't reach any solution. Honestly speaking, nothing came to my mind. Rocco numbers A positive integer \$n\$ is a Rocco number if it can be represented either a...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. As we all know, Santa comes down the chimney to deliver presents to good kids. But chimneys are normally full of smoke, and the Elves are worried about Santa's health. So they decide to blow the smoke out using an electronic air blower...
stackexchange_codegolf
You are given four integers: \$e,s,b\in\{0,1\}\$ and \$S\in \{0,1,2,4\}\$, where \$e,s,b,S\$ stand for egg, sausage, bacon and spam respectively. Your task is to figure out whether the corresponding ingredients match a valid entry in the following menu: [e]gg | [s]ausage | [b]acon | [S]pam -------+-----------+--------...
stackexchange_codegolf
At some point, I bumped into an SO question asking how to implement Perl's trivial hash-of-hashes data structure in Java. For those who don't know Perl, the hash value can be a scalar or another hash, or technically speaking hash reference. Arbitrary depth. Additional feature offered by Perl is autovivification - assi...
stackexchange_codegolf
Background BitCycle is a two-dimensional Turing-complete programming language involves moving bits around a playfield. Because I am too lazy to write BitCycle programs myself, you will be writing a program which outputs BitCycle programs for me! Unfortunately, the storage space on my computer is only about a bit, so yo...
stackexchange_codegolf
Draw lines between every pair of distinct points for n points arranged in a circle, producing something like the below result. Shortest code (in bytes) wins! Your lines don't have to be transparent, but it looks better that way. The output must be a vector graphic, or be an image at least 600 pixels by 600 pixels (eith...
stackexchange_codegolf
The challenge is to write a golf-code program that, given n positive real numbers from 0 to 10 (format x.y, y only can be 0 or 5: 0, 0.5, 1, 1.5, 2, 2.5 … 9.5 and 10), discard the lowest and highest values (only one, even though they are repeated) and shows the average of the remaining, in x.y format (y can be 0 or 5, ...
stackexchange_codegolf
Related: I double the source, you double the output! When Steve Jobs launched the iPhone 3G, the slogan said Twice as fast, half the price I changed the word fast to long to better represent this challenge. Objective Write a program that outputs a non-zero, even integer. If the source code is doubled, the value of t...
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
Inclusion-Exclusion lets you calculate the sizes of some unions and intersections between sets knowing some of the other values. I won't explain it exactly, but your challenge is to visualize inclusion-exclusion on a Venn Diagram. Because I'm nice, you'll be using rectangles, not circles. You will be given a list of re...
stackexchange_codegolf
In this challenge you are going to place letters from the alphabet in a Cartesian plane and output the result as a text. Your input will consist in a list of list with 3 parameters: X coordinate Y coordinate String How? We know that a Cartesian plane contain 2 axes \$(X, Y)\$ and 4 quadrants where the signs of the \...
stackexchange_codegolf
I'm currently cooking us some cup noodles, but we're really sleepy at the moment. They'll be finished in 50 seconds from now, can you wake me up then? Problem: Write a program or function that waits 50 seconds of busy waiting (so that you too doesn't sleep) and then outputs at least 1 visible character to wake me up. B...
stackexchange_codegolf
Introduction: Unfortunately an Accordion Solitaire Solver challenge already exists (Solve a game of Accordion), so instead this easier related challenge. Let's start by explaining how Accordion Solitaire works: You start with all 52 cards (or 53 if you add a Joker) in one big row. You pile up cards from right to left ...
stackexchange_codegolf
Try to create a simple ASCII art scissors animation! Challenge All inputs will be integers -31 through 31. The output will be an animation (To be outputted somewhere, as long as the previous frame is replaced. GIFs are allowed.), separated by (approximately) 1 quarter of a second. If the input (n) is positive: The ani...
stackexchange_codegolf
A simple graph is toroidal if it can be drawn on the surface of a torus without any edges intersecting. Your task is to take a simple undirected graph via any reasonable method (adjacency matrix, edge vertex sets, etc.) and decide whether or not it is a toroidal graph. You should output one of two distinct values for...
stackexchange_codegolf
You are to write a program that takes a list of strings as input. For every string in the list you are to determine the smallest N such that no other string in the list begins with the same N characters as the string in question. Now compose a new list with all these strings. Here is an example, on the left we have ...
stackexchange_codegolf
The goal of this challenge is to extend the OEIS sequence A334581. Number of ways to choose \$3\$ points that form an equilateral triangle from the \$\binom{n+2}{3}\$ points in a regular tetrahedral grid of side length \$n\$. The sequence begins 0, 0, 4, 24, 84, 224, 516, 1068, ... Example For example, if we take sid...
stackexchange_codegolf
Goal: Given any natural number k such that k<256, produce an deadfish program that gives the smallest solution possible. Background: Deadfish is a joke esoteric programming language. It has a single unsigned byte of memory, called the accumulator, initialized at 0. There are four commands which form a string. i = accu...
stackexchange_codegolf
Sequel to Verify Tents and Trees solution. Background Tents and Trees (try here) is a puzzle played on a square (or rectangular) grid, where the objective is to place tents horizontally or vertically adjacent to each of the trees, so that no two tents touch each other in 8 directions (horizontally, vertically, and diag...
stackexchange_codegolf
A challenge with simple rules but non-trivial algorithms. :-) Task Take input in the form of space-separated integers: N A B S Where N is the side length of a 2D square matrix filled with unique numbers (integers) between A and B inclusive. For each row and column in this matrix, the sum is always the same: S. (In oth...
stackexchange_codegolf
These are the classical puzzles: You need to boil eggs for exactly 9 minutes, or else the visiting Duchess will complain, and you will lose your job as head chef. But you have only 2 Hourglasses, one measures 7 minutes, and the other measures 4 minutes. How can you correctly measure 9 minutes? (taken from here) Let's...
stackexchange_codegolf
In this challenge you will be given an alphabetic string as input. We will define the "anti-string" of a given input to be the string with the case of all the letters inverted. For example AaBbbUy -> aAbBBuY You should write a program that takes a string as input and searches for the longest contiguous substring who...
stackexchange_codegolf
Gaussian integer is a complex number in the form \$x+yi\$, where \$x,y\$ are integer and \$i^2=-1\$. The task is to perform such operation for Gaussian integers \$a,b\$, that \$a=q \cdot b+r\$ and \$|r|<|b|\$ (\$q,r\$ are Gaussian integers, \$|z|\$ is defined as \$\sqrt{a^2+b^2}\$ for \$a+bi=z\$). Need to output only ...
stackexchange_codegolf
Let \$R, C\$ be positive integers and let \$0 < s \leq 1\$. Consider the \$R \times C\$ matrix \$\mathbf M\$ defined as \begin{equation} M(i,j) = \frac{\mathrm{mod}\,(j, i^s)}{R^s}, \quad i = 1, \ldots, R, \quad j = 1, \ldots, C \end{equation} where \$\,\mathrm{mod}\,\$ denotes the modulo operation: for \$a,b > 0\$ not...
stackexchange_codegolf
A bag, also called a multiset, is an unordered collection. You can call it a set that allows duplicates, or a list (or an array) that is not ordered/indexed. In this challenge, you are asked to implement bag operations: addition, difference, multiplication, division, counting and equality test. Operations The specified...
stackexchange_codegolf
Given two rectangles, which are possibly not in the orthogonal direction, find the area of their intersection. Input You may take the rectangles as input in one of the following ways: The coordinates of the four vertices of the rectangle. These coordinates are guaranteed to represent a rectangle. The coordinates of t...
stackexchange_codegolf
A pristine program is a program that does not have any errors itself but will error if you modify it by removing any contiguous substring other than the entire program. A crystalline program is sort of the opposite. It is a program which doesn't have any errors itself but will error if you modify it by adding any 1 cha...
stackexchange_codegolf
Have fun with this one, The Powder Toy is a interesting challenge for golf, especially with filt logic. The thing that makes TPT a challenge is the many many many many ways to approach a problem: Should I use Cellular Automaton rules, SWCH logic, Filt logic, subframe filt logic, and/or wall logic? As such, a location f...
stackexchange_codegolf
Background I am currently in an AP Comp Sci A: Java class, and I want to start some of my friends on code golfing. I have a challenge from the course, and I would like to see how many bytes the community can do this challenge in. Challenge details: Given two input strings, the main string and the pivot string, do the ...
stackexchange_codegolf
Can you imagine solving the New York Times crossword puzzle without any clues? Maybe not with all of the creativity and new words and phrases appearing in modern crosswords, but with a fixed word list there's some hope. In this challenge, you create a crossword puzzle grid in which this is theoretically possible. The...
stackexchange_codegolf
The set of all polynomials with integer coefficients is countable. This means that there is a sequence that contains each polynomial with integer coefficients exactly once. Your goal is it to write a function or program that outputs such a sequence. Example (you may use another sequence): // list of integers [i -> Z(i)...
stackexchange_codegolf
Let's say I have a .env file with the following contents: CF_WORKERS_ACCOUNT_ID=abcdef34632114 CF_WORKERS_API_TOKEN=abcdef34632114def3463def3463 FAB_DEV_ZONE_ID=434932843272439874329 I'm doing a screencast, and I want to quickly cat .env to show what's in the file, without broadcasting the exact values, since they're ...
stackexchange_codegolf
Given a nonempty list of nonnegative integers, consider rewriting it as an arithmetic problem where: A plus sign (+) is inserted between pairs of numbers that increase from left to right (a.k.a. from the start of the list to the end). A minus sign (-) is inserted between pairs of numbers that decrease from left to rig...
stackexchange_codegolf
Inspired by Does the start equal the end Given a string s and an integer n, output a truthy/falsey as to whether the nth char in s equals the nth from the end char in s. Input A non-empty string and an integer. You can use 0-based indexing or 1-based indexing. The integer is guaranteed to be valid based on the string. ...
stackexchange_codegolf
Challenge : Given two non-negative integers (X and Y > 1) calculate the sum of digits of their powers . i.e : sum of digits of X ^ Y . Input : Two non-negative integers X and Y Output : The sum of digits of X raised to power Y X ^ Y. Examples : 5 , 2 ---> 7 9 , 4 ---> 18 3 , 17...
stackexchange_codegolf
Your task is when given a chemical formula as input, output the total number of atoms in the formula. Input A chemical formula in any reasonable format. Each chemical formula has the following: A leading coefficient, which is a number \$N > 1\$. At least 0 groupings of elements surrounded by parentheses. Groupings ca...
stackexchange_codegolf
from Wikipedia, a number is called B-powersmooth if all prime powers \$p^v\$ that divide the number satisfy \$p^v \leq B\$. B-powersmoothness is important, for example, for Pollard's p-1 factorization algorithm. Task your task is to get two numbers, \$n\$ and \$B\$, and output if \$n\$ is \$B\$-powersmooth. Rules You ...
stackexchange_codegolf
You are piloting a spaceship, outfitted with an engine that can accelerate you at 1km/s^2 in the direction the ship is facing (you have very good inertial dampers). You also have thrusters which can rotate you 180 degrees in 1s (rotating 45 degrees takes 0.25s, etc.). You see on your scanner another ship, and decide t...
stackexchange_codegolf
Recently, my reputation was 25,121. I noticed that each digit grouping (i.e. the numbers separated by commas) was a perfect square. Your challenge is, given a non-negative integer N and a unary boolean Black Box Function f : Z* → B , yield a truthy value if each value of f applied to the digit groupings of N is truthy,...
stackexchange_codegolf
Your program's input is a string containing whitespaces, parentheses, and other characters. The string is assumed to be parenthesed correctly, i.e. each right parenthesis matches a unique left parenthesis and vice versa : so the program is allowed to do anything on incorrectly parenthesed strings, such as )abc, (abc or...
stackexchange_codegolf
The Task Your task is to create a program or a function that, given an input, outputs the input text with random letters capitalized, while keeping already capitalized letters capitalized. Every combination of capitalizations of the lowercase letters should be possible. For example, if the input was abc, there should b...
stackexchange_codegolf
We've had a lot of alphabet challenges. For this challenge, you are passed the output of an alphabet challenge, and you need to output the pattern scaled to size N. For example, if N=5 and you were passed the L-phabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ BBCDEFGHIJKLMNOPQRSTUVWXYZ CCCDEFGHIJKLMNOPQRSTUVWXYZ DDDDEFGHIJKLMNOPQR...
stackexchange_codegolf
The Chinese Remainder Theorem tells us that we can always find a number that produces any required remainders under different prime moduli. Your goal is to write code to output such a number in polynomial time. Shortest code wins. For example, say we're given these constraints: \$n \equiv 2 \mod 7\$ \$n \equiv 4 \mod ...
stackexchange_codegolf
Write a non-trivial regex that matches itself. For example, #.*$ will match a comment outside of a string in python until the end-of-line, and also matches itself in perl regex syntax. Rules: The regular expression must do something useful or practical. Tell what regex syntax you are using (e.g. perl or POSIX). Winner...
stackexchange_codegolf
Write the shortest program or function that will determine if an input is a valid Go type. Spec This challenge will use the following simplified subset of Go types. For more information, see the Golang specification. "Primitive" types: bool int,uint,float(32|64),complex(64|128),byte,rune string *T where T is any ty...
stackexchange_codegolf
Introduction cowsay is a Unix command made by Tony Monroe, written in Perl. It outputs a picture of a cow saying given text. For example: ________________________ < Typical cowsay output! > ------------------------ \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | ...
stackexchange_codegolf
Introduction: Although it seems challenges scored by least unique characters have been attempted, there are few which were well-received. I think it's a potentially interesting scoring criterion, as long as different languages aren't competing with each other (as with code golf). Challenge: Create a basic FizzBuzz prog...
stackexchange_codegolf