instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Given two non-empty 01 strings, check if there is string containing both given strings, and their first appearance end at same position. Test cases: 01, 1 => true (01) 0, 00 => false (0 would at least come 1 character earlier) 01, 11 => false (can't meet on same position) 01, 0 => false (can't meet on same position) 11...
stackexchange_codegolf
Input _ _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_|| | ||_ _| | _||_| ||_| _||_| output 1234567890 Rules Code golf - shortest code wins. Input will be given as a 3-line string with each line separated by a newline, or as 3 separate strings. Each line is guaranteed to be a multiple of 3 characters lo...
stackexchange_codegolf
Given the 2-dimensional positions and velocities of a pair of billiard balls right before impact, calculate their velocities after a perfectly elastic collision. The balls are assumed to be ideal spheres (or equivalently: circles) with the same radius, same mass, uniform density, and no friction. Input consists of 8 nu...
stackexchange_codegolf
I recently stumbled across this image on wikimedia commons. It's a little bit of an information overload at first, but after examining it a bit it shows an interesting number system for writing nibbles. Image created by user Watchduck. First off a "nibble" is a 4 bit number which is really a number ranging from 0 to ...
stackexchange_codegolf
This challenge is to output to your terminal, window, canvas or screen the numbers zero to 10 inclusive. Each outputted number must be shown as a 4-bit wide nybble, so zero must show as 0000 and so on. You may separate each number outputted with a space, comma or carriage return. Smallest solution wins but the numbers ...
stackexchange_codegolf
Challenge Premise Consider a mosaic of \$m\times n\$ tiles, in \$k\$ unique colours designated by integers. Example (\$3\times6\$, four colours): 4 1 3 2 4 2 1 2 4 2 1 3 4 3 2 1 4 4 My poor man's mirror is a pane of glass of width \$\sqrt{2}\cdot\min(m,n)\$. I stand it diagonally on the mosaic, like so: 4 1 3 M 4 2 1 ...
stackexchange_codegolf
Background Here is a Halloween related challenge. As you may have seen from my last challenge I quite like what I term as ascii art animations, that is not just draw a pattern but draw a pattern that progresses. This idea came to me after I was asked a couple of years ago to liven up a (rather dull) presentation by mak...
stackexchange_codegolf
Challenge Calculate the strange sum of two natural numbers (also known as lunar addition): Given \$A=...a_2 a_1 a_0\$ and \$B=... b_2 b_1 b_0\$ two natural numbers written in the decimal base, the strange sum is defined, based on the maximum operation, as: \$A+B=... \max(a_2,b_2) \max(a_1,b_1) \max(a_0,b_0)\$ ... ...
stackexchange_codegolf
Given the sequence OEIS A033581, which is the infinite sequence, the n'th term (0-indexing) is given by the closed form formula 6 × n2 . Your task is to write code, which outputs all the subsets of the set of N first numbers in the sequence, such that the sum of the subset is a perfect square. Rules The integer N is g...
stackexchange_codegolf
Golf Me An OOP! Two important components of object-oriented programming are inheritance and composition. Together, they allow for creating simple yet powerful class hierarchies to solve problems. Your task is to parse a series of statements about a class hierarchy, and answer questions about the hierarchy. Input A seri...
stackexchange_codegolf
Input: Two integers n and k given in any form that is convenient for your code Output A random non-decreasing sequence of k integers, each in the range 1 to n. The sample should be chosen uniformly from all non-decreasing sequences of k integers with integers in the range 1 to n. The output can be in any reasonable f...
stackexchange_codegolf
The challenge is simple: Read 3 letters from a system input¹ and convert them to numbers (A-1, B-2, C-3...Z-26)². Print each of those numbers in the order the letters were inputted in, each on a new line and then the sum of all 3 numbers, on its own line as well. NOTE: There will be no extra input characters, only 3 le...
stackexchange_codegolf
The task is simple: given a 32 bit integer, convert it to its floating point value as defined by the IEEE 754 (32-bit) standard. To put it another way, interpret the integer as the bit-pattern of an IEEE binary32 single-precision float and output the numeric value it represents. IEEE 754 single precision Here is a conv...
stackexchange_codegolf
Given a string, you've to split it into groups of three characters (by padding _ at the end). Related, but still it's different. Sample I/O: 'abcde' -> 'abc', 'de_' '1234' -> '123', '4__' '' -> [] or falsey value 'Three spree!' -> 'Thr', 'ee ', 'spr', 'ee!' 6 MB string This is a code-golf, so fewest bytes wil...
stackexchange_codegolf
Your task is to write a program or function that detects accents in UTF-8 input. The catch is that your code must be written entirely in an 8-bit character encoding. The code will output a single integer which is the count of the number of accented letters in the input. Since Unicode is huge, the test input will consis...
stackexchange_codegolf
Here's a pretty common pattern for sorting algorithms: def sort(l): while not is_sorted(l): choose indices i, j assert i < j if l[i] > l[j]: l[i], l[j] = l[j], l[i] These algorithms work well because the indices i and j are chosen carefully, based on the state of the list l....
stackexchange_codegolf
The problem is taken from this comic: http://www.smbc-comics.com/?id=2874 Your program must convert a number to the smallest base system in which it has the most fours in its digit sequence. Shortest code wins! Function entries are allowed provided that the function prints the base in which the number is fouriest as w...
stackexchange_codegolf
Input: Ten unique integer coordinates, between (0,0) and (100,100). Output: The coordinates arranged in the order/an order such that a path drawn between the coordinates in that order is the shortest path possible. This is code golf so the shortest code wins!
stackexchange_codegolf
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 diagonally) and the number of tents on each row...
stackexchange_codegolf
Given a list of non-negative integers the function \$f\$ replaces every integer with the number of identical integers preceding it (not necessarily contiguously). So f [1,1,2,2,1,3,3] = [1,2,1,2,3,1,2] We will say that a list, \$X\$, is in a loop if there is some positive integer \$n\$ such that \$f^n X = X\$. That i...
stackexchange_codegolf
For this problem you are given an \$n \times n\$ matrix of integers. The task is to find a pentagon in the matrix with maximum sum. The pentagon must include part (or all) of the x and y axes as two of its sides starting from the top left cell. All the sides except one must be horizontal or vertical. The remaining si...
stackexchange_codegolf
Task Given an input, evaluate it as a mathematical equation following the order of operations. But, instead of the using PEMDAS, we drop the parentheses and exponentiation and introduce spaces - SMDAS - spaces, then multiplication & division, then addition & subtraction. How does that work? Every operator with more spa...
stackexchange_codegolf
This is my attempt to pair code-shuffleboard with code-golf. You need to write a full program or function that sums all codepoints of the input string. If there is no input, you can output any number, including 0. Rules The input will always be in printable ASCII. The sum of the codepoints of your source must be exact...
stackexchange_codegolf
The string tut-tutut-tut-tuttut-tut can be constructed with overlapping or concatenated instances of the word tut-tut: tut-tutut-tut-tuttut-tut tut-tut tut-tut tut-tut tut-tut The string tut-tututut-tutut-tut cannot: tut-tututut-tutut-tut tut-tut^ |tut-tut | tut-tut ...
stackexchange_codegolf
Introduction Just on Hacker news, John Resig contemplates transforming a query “foo=1&foo=2&foo=3&blah=a&blah=b” into one that looks like this: “foo=1,2,3&blah=a,b", https://johnresig.com/blog/search-and-dont-replace/. He claims "being 10 lines shorter than Mark’s solution". Query strings consist of sequences of name-v...
stackexchange_codegolf
What general tips do you have for golfing in Keg? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Keg (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Summary Inspired by the recent popularity of ASCII art challenges, this challenge's purpose is to draw an ASCII checkerboard, like one on which Chess can be played. Write a program that takes a positive integer n as an argument, in stdin, or as user input, and output an checkerboard with nxn squares, along with a borde...
stackexchange_codegolf
One way to represent a natural number is by multiplying exponents of prime numbers. For example, 6 can be represented by 2^1*3^1, and 50 can be represented by 2^1*5^2 (where ^ indicates exponention). The number of primes in this representation can help determine whether it is shorter to use this method of representat...
stackexchange_codegolf
Do randomly generated drum loops sound good? A drum loop is a \$5\times 32\$ matrix \$A\$ of \$1\$s and \$0\$s such that \$A_{1,1}=A_{1,17}=A_{2,9}=A_{2,25}=1\$, for each \$i\$, the \$i\$th row has exactly \$f(i)\$ different \$1\$s, where \$ f(1)=3, f(2)=2, f(3)=6, f(4)=8, f(5)=5\$, for each \$j\equiv 1\bmod 4\$, the ...
stackexchange_codegolf
Challenge: Given a matrix input, determine the amount of diagonals and anti-diagonals with duplicated numbers. So if we have a matrix like this: [[aa,ab,ac,ad,ae,af], [ba,bb,bc,bd,be,bf], [ca,cb,cc,cd,ce,cf], [da,db,dc,dd,de,df]] All diagonals and anti-diagonals would be: [[aa],[ab,ba],[ac,bb,ca],[ad,bc,cb,da],[ae,...
stackexchange_codegolf
A Munchausen Number in base \$b\$, also known as a Perfect digit-to-digit invariant or PDDI is a peculiar type of positive integer where the sum of its base-\$b\$ digits raised to themselves is equal to the number itself. They are named for the fictional Baron Munchausen, who apparently hoisted himself up via his own p...
stackexchange_codegolf
This question was inspired by Tom Scott's video here. The English language has plenty of words, but what's the longest one that can be displayed on a seven segment display? Your challenge is given a list of letters that may not be displayed, display the longest English word in a 7 segment display format? Input Input w...
stackexchange_codegolf
Curling is a sport where two teams aim to place stones as close to the centre of a target as possible. The winner of a curling end is the team whose stone is closest to the centre – they score as many points as the number of their stones closer to the centre than any of their opponents. Task Given two lists of pairs of...
stackexchange_codegolf
Write a full program or a function taking an unsigned integer number N and doing this cut out work: Cut out a hollow hexagon 'donut' shape with side B-C equal to 2N times '/' Translate the piece above by 3 lines. Repeat the job N times (from the piece obtained) decrementing by 2 '/' side B-C , until smallest hexagon ...
stackexchange_codegolf
Here's a simple one to stretch your compression muscles. Your code (a complete program) must output the spelled-out English representation of all the cardinal numbers from 1 to 100, and then all the ordinal numbers from 1 to 100. The numerals in each list should be delimited by commas and spaces and properly hyphenated...
stackexchange_codegolf
This is a cops and robbers challenge - Cop's Thread Each of the cops have been tasked to write a program that terminates after exactly 60 seconds, or as close as possible. For example: #include <unistd.h> int main(int argc, char **argv){ sleep(60); return 0; } Your goal is to take any of the uncracked submissi...
stackexchange_codegolf
Your challenge is simple: write a program or function which appears to print the first ten numbers of any integer sequence (on OEIS, the answerer may choose which sequence), but instead prints the exact text: Happy April Fool's Day! if and only if it is run on April 1st of any year. Run on any other day should make it...
stackexchange_codegolf
Consider an \$n \times n\$ grid of integers. The task is to draw a straight line across the grid so that the part that includes the top left corner sums to the largest number possible. Here is a picture of an optimal solution with score 45: We include a square in the part that is to be summed if its middle is above o...
stackexchange_codegolf
So I was playing around with this emulator of the Intel 4004 and decided I wanted to set a challenge for myself. The first use for the 4004 was in a calculator, so I decided that I would try to code golf every operator on said calculator(addition, subtraction, multiplication, division, decimal points, and the square r...
stackexchange_codegolf
A polygonal number is the number of dots in a k-gon of size n. You will be given n and k, and your task is to write a program/function that outputs/prints the corresponding number. Scoring This is code-golf. Shortest solution in bytes wins. Example The 3rd hexagon number (k=6, n=3) is 28 because there are 28 dots abov...
stackexchange_codegolf
So we're all hopefully familiar with Spreadsheet 'A1' cell notation. It's simply an alphanumeric representation of the positioning of said cell within a grid. The letter(s) represent the column positioning of the cell, and the number represents the row. The 'letter' part can consist of 1 or more letters from the 26 let...
stackexchange_codegolf
This challenge is about Haskell point-free style polynomial functions. Although you don't need to know Haskell language to do this challenge, Haskellers might have an advantage here. Point-free means roughly that variables(points) are not named and the function is created from compositions of others functions. For exam...
stackexchange_codegolf
Presumably everybody here knows that for the legacy BIOS, the tiniest bootable disk image is 512 bytes (the lower bound is due to the 2-byte magic at offset 510), and there is a bootsector demoscene where people try to fit the entire demo into the 510 bytes of usable space. Now that the BIOS is being superseded by UEFI...
stackexchange_codegolf
In this challenge, your task is to make write a program with less than 300 characters that takes a short paragraph or a few sentences that a candidate has said and output who said it. Input: Can be taken as a parameter to a function, input to a program etc. It will be a short paragraph, properly punctuated. Output: The...
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
Cops thread Robbers Robbers, your job is to find the slices of the corresponding cop's code. Scoring The robber with the most cracks wins. Example Take this code: iimmppoorrtt ssyymmppyy;;pprriinntt((ssyymmppyy..iisspprriimmee((iinnppuutt(()))))) The slice here is [::2], so the robber's post could look like this: Crac...
stackexchange_codegolf
This challenge is brought to you by real (and tragic) inspiration. Recently, the number row on my keyboard has been a bit sporadic. The keys 1-9 work sometimes--but other times they have no result. As an avid programmer, this is horrible! (See that exclamation point? That's how you know they're working right now.) Not ...
stackexchange_codegolf
Prelude: This challenge is different from "another cat program". There's literal tons of different twists, why can't I have my own, people? Unique things: It isn't reading direct input to output. It is manipulating the string in a way that for sure isn't a straight-up cat. Challenge: Given 3 inputs (or one input, s...
stackexchange_codegolf
A marquee is a low-tech board that allows customizable letters. For example, here is a marquee: SALE ON SNEAKERS However, someone might come along and vandalize it by removing letters to send a different message: S N AKE Given two non-empty string inputs, an original message and a new message, determine whethe...
stackexchange_codegolf
Introduction: Aaron is a young game developer. He recently joined the development team of a game where the players select their character from a predefined set, aka "heroes". Unfortunately, the names of the existing heroes are not evenly distributed throughout the alphabet. For example, there are 6 heroes that have a n...
stackexchange_codegolf
Challenge Given two strings in any default I/O format, do the following: NOTE: The challenge will refer to the first string as the "data" and the second referred to as the "program". Change the program to an infinite string which is just the program repeated infinitely (e.g. 10 --> 1010101010...). The challenge will r...
stackexchange_codegolf
Find the difference between the square of the sums and sum of the squares. This is the mathematical representation: \$\left(\sum n\right)^2-\sum n^2\$ Your program/method should take two inputs, these are your lower and upper limits of the range, and are inclusive. Limits will be whole integers above 0. Your program/m...
stackexchange_codegolf
If we have a binary matrix then we will say that a \$1\$ is stable if it is in the bottom row or it is directly adjacent to a \$1\$ which is stable. In other words there must be a path to the bottom row consisting only of \$1\$s. So in the following matrix the \$1\$s highlighted in red are not stable. $$ 0110\color{red...
stackexchange_codegolf
Your task is to generate an emoticon of three characters, the first character being one eye, the second the mouth, and the third another eye. Each eye is a random one of these characters: $'*+-;O^`ox~, and the mouth is a random one of these: ,-._coux. Each eye and the mouth must be on the same general level. These eyes...
stackexchange_codegolf
Once I wrote a JavaScript program that would take as input a string and a character and would remove all characters except for the first one and the character given as input, one by one. For example, computing this with inputs codegolf.stackexchange.com and e for the character yields: codegolf.stackexchange.com cdegolf...
stackexchange_codegolf
Food shortage in the Snakepit For the first time in 35 years, the snakepit is running out of food. The inhabitant snakes now have to fight each other in order to survive this food shortage. Only one snake can stand at the top of the food chain! Leaderboard Not here yet! Last update on February, 24th Link to visualizat...
stackexchange_codegolf
Introduction This question is inspired by this great question. Challenge Given a number \$N>0\$, output the largest integer \$a^b\$ that is smaller or equal to \$N\$, and the smallest integer \$c^d\$ that is greater or equal to \$N\$, where \$b>1\$ and \$d>1\$. Output should be a list of two integers, the first being s...
stackexchange_codegolf
Task Your goal, should you choose to accept it, is to write a program, that, given an input string (or array of characters), outputs every possible permutation of the letters in that string. I'm finicky with my output, so it should be sorted alphabetically, with no duplicates. Example: Input: buzz Output: buzz bzuz bzz...
stackexchange_codegolf
How well do you know the site? Let's find out. This is a cops-and-robbers challenge. Cop's thread. As a robber, you need to: Find a non-deleted, non-closed challenge that matches a cop's submission. The challenge cannot have the following tags: cops-and-robbers, popularity-contest, code-trolling, underhanded, busy-...
stackexchange_codegolf
First puzzle from me, suggestions for improvement gladly received! The scenario is; You work as a manager for a whitewater rafting company. Every morning, you are given a list of bookings, and you have to sort them into raft loads. Write a program or function in your chosen language that does this for you. Each raft ho...
stackexchange_codegolf
This question is the first of several Brain-flak Birthday challenges designed to celebrate Brain-Flak's first Birthday! You can find more information about Brain-Flak's Birthday here Last summer we had the Brain-flak Integer Metagolf, and the answers it generated have been very useful to the Brain-Flak community sinc...
stackexchange_codegolf
For a fixed n, consider the n by n Toeplitz matrices with entries which are either 0 or 1. The aim is to find maximum determinant over all such Toeplitz matrices. Task For each n from 1 upwards, output the maximum determinant over all n by n Toeplitz matrices with entries which are either 0 or 1. There should be one o...
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
Take the string abcdfghjk. To overwrite it, starting from f, with the string wxyz, you would continue along the original, replacing each character with the one from the replacement string. The result would be abcdwxyzk. Now, consider a string which would be too long to fit, like lmnopqrs. Starting at f you would get ab...
stackexchange_codegolf
Code-Bowling Challenge Write a program or function that produces the same output, no matter how you re-arrange the source code. (Output can't be an error) Pangram Scoring Your score is the amount of unique characters in your source code. A program with source code AJB would have a score of 3 A program with source ...
stackexchange_codegolf
The following problem is a common interview question, thus dull answers are discouraged. Go short or creative, best if both: Create the following pattern ########### ## ## # # # # # # # # # # # # # # # # # # # # # # # # # # # ## ## ########### In case you cry "dupe", I see y...
stackexchange_codegolf
Given a list or delimited string, output a list or delimited string with the first character of each word one word later. For this challenge, a "word" consists of only all printable ASCII characters, except the space, newline, and tab character. For example, take the string "Good afternoon, World!" (space-delimited): 1...
stackexchange_codegolf
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most interesting code golf in the common languages, finding the shortest solution in certain esolangs can be a serious challenge. For ...
stackexchange_codegolf
This is a somewhat proof-golf-like cops-and-robbers challenge. This is the robbers' thread; the cops' thread is here. Robbers The cops will post abstract rewriting systems. Your task is to crack their submissions by proving that the target string either can or can not be reached from the source string by applying their...
stackexchange_codegolf
The other day, our team went to an escape room. One of the puzzles involved a board of six mechanical switches where you had to find the correct combination of on and off in order to unlock a box, somewhat like this: -v-v-v- -v-v-v- Being developers, we decided it would be more efficient to try every single one of 2^6...
stackexchange_codegolf
I'm (still) trying to make another submission to the Largest Number Printable question, and I've got the following bit of code: f=->a{b,c,d=a;b ?a==b ?~-a:a==a-[c-c]?[[b,c,f[d]],~-c,b]:b:$n} h=[],$n=?~.ord,[] h=f[h]until h==p($n+=$n)-$n Ungolfed: f=->{b,c,d=a if b if a==b # a is not an array return a-1 elsif a...
stackexchange_codegolf
The Dal Segno and Da Capo are two very commonly used musical terms. They mean "from the sign" () and "from the beginning" respectively. There is also the idea of the coda (), which is the very end of a piece of music. It's what's played after the "main section" of the piece. A D.S. al coda (Dal Segno al coda), for exam...
stackexchange_codegolf
Task Continuously print a random character (a-z, A-Z, 0-9) not separated by a newline (\n). Expected output b7gFDRtgFc67h90h8H76f5dD55f7GJ6GRT86hG7TH6T7302f2f4 ... Note: output should be randomised. Requirements/Rules Output must be continuous (i.e. never ending), Output may not comprise of newlines, Output must b...
stackexchange_codegolf
Inspired by the Lego gear ratios challenge by Keith Randall. I, too, plan on building a giant lego robot that will eventually be able to destroy the other robots in the never-before-mentioned competition.* In the process of constructing the robot, I will be using a lot of gear trains to connect different parts of the r...
stackexchange_codegolf
This ascii-art challenge is about walking around a string like a snake. s-n-a-k .---. e d <-' a n-u-o-r You will be given a string \$ S \$ of length \$ l \$ and a positive integer \$ n \$ where \$ n ^ 2 \ge l + 1 \$. The string rotates 90° after writing \$ n \$ characters of \$ S \$, or when it hits itself. When \$ S ...
stackexchange_codegolf
Introduction (may be ignored) Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the fourth challenge in this series (links to the first, second and third challenge). In this ...
stackexchange_codegolf
Description There have been quite a few other challenges concerning these numbers before, and I hope this one is not among them. The n th triangular number equals the sum of all natural numbers up to n, simple stuff. There are a wikipedia page and an entry at OEIS, for those who wish to inform themselves further. Now, ...
stackexchange_codegolf
A simple way to scramble a 2x2x2 Rubik's cube is to make a sequence random moves. This is not how official scrambles are done, but can get pretty close to a uniform distribution of all possible scramble states. Due to the way a 2x2 only has two layers, doing one turn on one face is equivalent (without considering the p...
stackexchange_codegolf
this challenge was based on a sandboxed post by @dmckee Old fashioned cell phones were and are used heavily as texting platforms, unfortunately the keyboard has only 12 + a few buttons, and is therefor ill-suited to naive text entry. Common solutions make use of the traditional telephone coding (generally with a modest...
stackexchange_codegolf
Input: a sequence of uppercase letters (ASCII [65;90]) which is the Nth* lexicographical permutation of the multiset of its characters *permutations are numbered from 0 or 1 upwards Output: base-10 integer N Rulez There might be duplicates (that's how this challenge differs from this one) The characters are ordered b...
stackexchange_codegolf
Cops thread Robbers, your task is to crack a cops answer. Reveal the character that should be changed and what it should be changed to too. Please notify the cop if you cracked their challenge. The robber winner is the user with the most cracks. I will declare the winner cop and robber a week after this challenge is po...
stackexchange_codegolf
According to RollingStone, below are the 26 greatest singers of all time: Aretha Franklin Al Green Ray Charles Robert Plant Elvis Presley Mick Jagger Sam Cooke Tina Turner John Lennon Freddie Mercury Marvin Gaye Bob Marley Bob Dylan Smoke...
stackexchange_codegolf
This is what I thought this question was going to be, before I fully read it. A group of code golfers walk into The Nineteenth Bite Pizzeria and order a pizza. It comes in an irregular shape, made of unit squares. Your task is to help them cut it into identical slices. That is, the slices must have the exact same sha...
stackexchange_codegolf
Note that this challenge requires no handling or understanding of complex numbers. Given a non-empty square matrix where every element is a two-element (Re,Im) integer list, determine (giving any truthy/falsy values or any two consistent values) whether this represents a Hermitian matrix. Note that the input is a 3D ar...
stackexchange_codegolf
This is an answer-chaining challenge in which each answer builds on the previous answer. Taking no input, you are to output the most recent submission to this thread. I would HIGHLY suggest sorting by oldest and skipping to the last page to find the most recent answer. Scoring The winner will be chosen based on a point...
stackexchange_codegolf
Task Given a positive integer n, output the joined compound of circles The circles are of square of size n+2 but removing the corner edges and the middle, before finally overlapping n times of itself E.g. 2 -> #### #### #### #### -> ## # # # # ## -> ## ## # # # # # # ## ## Testcases 1 -> # # # # 2 -> ...
stackexchange_codegolf
Do you remember my mat properly grouped by colors? Yesterday I was looking at it and realized that some letters fit inside others. Example: a letter P fits in the place where the letter R goes. So here's a simple challenge: given two letters, return a truthy value if any one of the letters fits inside the other (direc...
stackexchange_codegolf
In Salesforce CRM, every object has 15-character alphanumeric ID, which is case-sensitive. If anyone's curious, actually it's base-62 number. However, tools used for data migration and integration may or may not support case sensitivity. To overcome that, IDs can be safely converted to 18-character case-insensitive alp...
stackexchange_codegolf
Given a number n, print the nth prime Fermat number, where the Fermat numbers are of the form 22k+1. This code should theoretically work for any n (i.e. don't hardcode it), although it is not expected to terminate for n > 4. (It should not return 4294967297 for n=5, as 4294967297 is not a prime number.) Do note that wh...
stackexchange_codegolf
Say that you have a string like this: abaabbbbbaabba Count the number of times that a specified character appears in the input string, but only if the character appears only once in a row. For example, if the character is a, abaabbbbbaabba ^ x x ^ The total would be 2 (the aa's wouldn't count because the a app...
stackexchange_codegolf
The Challenge Write a program that outputs Hello World, from line X!, where X is the line number, in the source code, of the actual print statement itself. The Rules In this context, we want the first line number of the statement which outputs the string to be displayed to stdout You should avoid simply searching thro...
stackexchange_codegolf
Generate \$T=\{T_1,...,T_x\}\$, the minimum number of \$k\$-length subsets of \$\{1,...,n\}\$ such that every \$v\$-length subset of \$\{1,...,n\}\$ is a subset of some set in \$T\$ Here, \$n > k > v\$ and \$v \ge 2\$ Any number can appear only once in 1 set Order of numbers is not important Answer with code & explan...
stackexchange_codegolf
You goal is to implement the operation of XOR (carryless) multiplication, defined below, in as few bytes as possible. If we think of bitwise XOR (^) as binary addition without carrying 101 5 ^ 1001 9 ---- 1100 12 5^9=12 we can perform XOR multiplication @ by doing binary long-multiplication but doin...
stackexchange_codegolf
Challenge Given the high resolution molecular mass of an organic molecule, output the molecule's molecular formula. Explanation The input will be a single number to three decimal places of precision, the relative molecular mass of the molecule. Here, the molecular mass is defined as the sum of the masses of the atoms i...
stackexchange_codegolf
I like golfing in tinylisp: (d M(q((x)(i x(i(disp x)0(M x))0 But I also like posting explanations with nicely formatted code: (d M (q ((x) (i x (i (disp x) 0 (M x)) 0)))) Can you help me generate the ungolfed code for my explanations? The task Given a line of tinylisp code, return or output the same cod...
stackexchange_codegolf
In the most common contemporary graphical desktop interfaces, when you perform double-click in a text, the word around your cursor in the text will be selected.† For example, let | be your cursor in abc de|f ghi. Then, when you double click, the substring def will be selected. Input/Output You receive two inputs: a st...
stackexchange_codegolf
The Scenario You are a taxi driver in your city. You picked up a passenger from the airport and he told you the place he'd like to go. To earn more money, you need to drive as much as you can. However, there are two problems: He always looks around. Therefore, you cannot pass from the same district twice. The passenge...
stackexchange_codegolf
kolmogorov-complexity is one of the tags on this site, representing challenges that test how much code is needed to output a given fixed result (usually a piece of text). The info page for this tag lists the string 4c1j5b2p0cv4w1x8rx2y39umgw5q85s7uraqbjfd as an example of a string with a high Kolmogorov complexity, sta...
stackexchange_codegolf
Take an input, and convert it from Two's Complement notation (binary where the first bit is negated, but the rest are taken as normal) into an integer (in a somewhat standard output form). Input can be as a string, a list of digits, a number, or pretty much any other format which is recognizably Two's Complement. Leadi...
stackexchange_codegolf
The Challenge I am thirsty and need a drink, but I don't know what to order. Your task is to provide me with either a drink or options for one. I/O Input will be either a base or a drink name. If given a base, your program should output one random drink from a list of drinks with that base. If given a drink name, your ...
stackexchange_codegolf