instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
The following is an unfolded milk carton: +-----+-\|/-+-----+-\|/-+-+ | | / \ | | / \ | | +-----+/---\+-----+/---\+-+ | | | | | | | | | | | | | | | | | | +-----+-----+-----+-----+-+ \ / \ / \ / \ / \_/ \_/ \_/ \_/ This is a code-golf kolmo...
stackexchange_codegolf
A few days ago I made a puzzle about moving people on an airplane. Now I am interested in the general version of this puzzle and the shortest code golf for it. I will briefly summarise the puzzle here. A small airplane went through some heavy turbulence and all its N passengers ended up sitting in reverse order, ie., p...
stackexchange_codegolf
Given an integer n, your task is to determine whether it is a perfect square that when reversed, is still a perfect square. You may assume n is always positive. When numbers such as 100 (10x10) are reversed the result may have leading zeros (001) In this case, ignore the leading zeros and treat it as 1 (1x1). Test case...
stackexchange_codegolf
Everyone knows log scales are for quitters. Therefore, you must write a program or function that de-quitifies a bar graph with a log scale given a base. The bar graph input is taken as a single string which is a list of bars, where each bar of the log scale bar graph is separated by the printable (or whitespace) delimi...
stackexchange_codegolf
This originally came from Give the best Chaitin incompleteness bound, but I realized that there was a fragment of this problem which still potentially gives a good coding challenge. First Order Logic With Equality First, I will need to fix an encoding of first order formulas ('For all x there exists y such that ...'). ...
stackexchange_codegolf
Your program has to make the computer produce a sound, any sound. Shortest code wins, not sooner than 10 days after the first valid answer. If there is a tie, the one submitted sooner, wins. The program should run on a reasonable, not too uncommon personal computer. Opening a pop-up, message box, etc. (for example, on...
stackexchange_codegolf
Given a non-flat list of integers, output a list of lists containing the integers in each nesting level, starting with the least-nested level, with the values in their original order in the input list when read left-to-right. If two or more lists are at the same nesting level in the input list, they should be combined ...
stackexchange_codegolf
The type 4 GUID is described by Wikipedia, quoth: Version 4 UUIDs use a scheme relying only on random numbers. This algorithm sets the version number (4 bits) as well as two reserved bits. All other bits (the remaining 122 bits) are set using a random or pseudorandom data source. Version 4 UUIDs have the form xxxxxxxx...
stackexchange_codegolf
You teach a class of students with interesting preferences for how their chairs are arranged. There are 3 very specific requirements they have for how the chairs are arranged: They most be arranged in a rectangle, even if it means some chairs go empty. There must be as few empty chairs as possible. They must be as "...
stackexchange_codegolf
Let us define the "multiplicative deltas" of values \$[\; a_0, \cdots a_N, \;]\$ as: $$ [\; a_1 / a_0, \cdots, a_{i+1} / a_i, \cdots, a_N / a_{N-1} \;] $$ The reverse operation - namely "multiplicative undelta" - returns values such that the above operation results in the given values. Example Given values \$[\; 1, 5, ...
stackexchange_codegolf
The point of this challenge is to find the smallest positive integer that uses up at least all of the digits supplied in the input after it is squared and cubed. So, when provided an input such as 0123456789 (i.e. a number that finds the result): 69² = 4761 69³ = 328509 It means that 69 is the result of such an input....
stackexchange_codegolf
Well, everyone loves Polyglots. You will be given two integers, in any standard form of input (no hardcoding). Your task is to write a polyglot which finds the minimum value in a language and the maximum value between the two numbers in the other language, and performs the following operations: The code which finds th...
stackexchange_codegolf
So I got kinda bored and was wondering if it was possible to make this code shorter without modifying anything except a file named coin.py... from random import*;c=['heads','tails'];print('u win'if choice(c)==input(' / '.join(c)+': ')else'u lose') The program asks the user for either "heads" or "tails", if the result ...
stackexchange_codegolf
Background Network discovery tool Nmap takes a list of TCP/UDP port numbers as input and performs a security audit against the listed ports. The target port listing on the command line includes selected port numbers as strings separated by a comma. To make specifying big amounts of ports more convenient the tool also s...
stackexchange_codegolf
The riddle In yesterday's newspaper, I found a puzzle in which a Rook should start in the lower-left corner of a 12x12 checkerboard and then, during a round trip, visit each field exactly once except for a selection which must be avoided. The puzzle came with a picture that identified the fields to be avoided as black:...
stackexchange_codegolf
The below pattern will form the basis of this challenge. /\ \/ /\ / \ / \ /\/ \/\ \/\ /\/ \ / \ / \/ /\ \/ Given an input width and height, each >=1, output the above ASCII art pattern repeated that many times, joining (and overlapping) at the small diamond...
stackexchange_codegolf
This challenge is inspired from this answer at the Ask Ubuntu Stack Exchange. Intro Remember the Windows ME screensaver with the pipes? Time to bring the nostalgia back! Challenge You should write a program or function which will output an ASCII representation of the screensaver. In the screensaver there should be a...
stackexchange_codegolf
Given a sequence of numbers, find the minimum number of jumps to go from the starting position to the end and come back to the starting position again. Each element of the sequence denotes the maximum number of moves that one can move from that position. At any position, you can make a jump of at max k moves, where k i...
stackexchange_codegolf
Your challenge is to construct a proper quine using as few distinct characters as possible. Scoring Your score is equal to the number of distinct characters in your code, aiming to minimise this. Standard quine rules apply.
stackexchange_codegolf
It frustrates me that when you say "base 16", the 16 is in base 10. We need a base neutral way of writing down numbers when favoring a specific base would be inappropriate. How it works We define <n> to be the nth prime. So <1>=2, <2>=3, <3>=5. Note that every positive integer can be uniquely represented by the product...
stackexchange_codegolf
Background MQTT (Message Queuing Telemetry Transport) is an ISO standard publish-subscribe-based messaging protocol (Wikipedia). Each message has a topic, such as the following examples: myhome/groundfloor/livingroom/temperature USA/California/San Francisco/Silicon Valley 5ff4a2ce-e485-40f4-826c-b1a5d81be9b6/status Ge...
stackexchange_codegolf
The objective Given the non-negative integer \$n\$, output the value of the hyperfactorial \$H(n)\$. You don't have to worry about outputs exceeding your language's integer limit. Background The hyperfactorial is a variant of the factorial function. is defined as $$ H(n) = 1^{1} \cdot 2^{2} \cdot 3^{3} \cdot \: \cdots ...
stackexchange_codegolf
In the game Tetris, there are 7 types of bricks or Tetriminoes, which are mathematically known as tetrominoes because they are all made with 4 square segments: The have the names I, J, L, O, S, T, and Z, that correspond to their approximate shapes. Counting 90° rotations, there are 19 unique shapes in total: I I I I ...
stackexchange_codegolf
Inspired by this tweet where a user stated the following: it's insane how much code would be cleaned up if JS got pipes and pattern matching i often do this since it's the best way to make use of TS inference and pattern matching would make it less hacky const result = (() => { if (scenario1) { return { t...
stackexchange_codegolf
An emirp is a non-palindromic prime which, when reversed, is also prime. The list of base 10 emirps can be found on OEIS. The first six are: 13, 17, 31, 37, 71, 73 However, due to the reversal rule, emirps are different in each base. For example, the first six binary emirps are: Bin | 1011, 1101, 10111, 11101, 1010...
stackexchange_codegolf
You are to write a program or function that outputs this exact text: OPQRSTU NQPONMV MREDCLW LSFABKX KTGHIJY JUVWXYZA IHGFEDCB May also be lowercase and trailing spaces and newlines are allowed. Standard loopholes are disallowed This is code-golf, so smallest byte count wins.
stackexchange_codegolf
Blackjack, also known as twenty-one, is a comparing card game between yourself and a dealer, where each player in turn competes against the dealer, but players do not play against each other. Play goes as follows, the dealer deals you a card. The dealer then deals them-self a card, face down. The dealer then deals yo...
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
Background The traveling salesman problem (TSP) asks for the shortest circuit that visits a given collection of cities. For the purposes of this question, the cities will be points in the plane and the distances between them will be the usual Euclidean distances (rounded to the nearest integer). The circuit must be "...
stackexchange_codegolf
Introduction: In general we usually speak of four dimensions: three space dimensions for x, y, and z; and one time dimension. For the sake of this challenge however, we'll split the time dimension into three as well: past, present, and future. Input: Two input-lists. One containing integer x,y,z coordinates, and one co...
stackexchange_codegolf
The picture: Sick of the same old grid where the answer is simply a square pyramidal number? Accept the challenge and write a program that given a positive integer \$n\$ counts how many squares are in the \$n^{\text{th}}\$ iteration of the Harter-Heighway dragon! The sequence of squares of size 1 is A003230 Your cod...
stackexchange_codegolf
The Meeker numbers are a 7 digit number in form of \$abcdefg\$, where \$a×b=10c+d\$ and \$d×e=10f+g\$. As an example \$6742612\$ is a meeker number, here \$6×7=10×4+2\$ and \$2×6=10×1+2\$, so it is a meeker number. Additionally, a Meeker number does not have any leading zeros (so \$a \ne 0\$) The Challenge Your program...
stackexchange_codegolf
After noticing all the fractal submissions/questions, I thought it would be fun to start a contest where everyone submits their favourite fractal. The Contest Generate a fractal in under 200 characters using any language. The output of the function can be an image, ascii art or any representation of a fractal you can t...
stackexchange_codegolf
We define \$a(n)\$ as the 1-indexed position of \$n\$ in the sequence of positive integers with the same binary weight, i.e. the same number of 1's in their binary representation. This is A263017. Given a positive integer \$n\$, your task is to determine how many positive integers \$k\$ satisfy: $$k-a(k)=n$$ For instan...
stackexchange_codegolf
Your task is to print the text Good morning, Green orb!, with every character repeated in place as many times as the most frequent byte in your source (the mode). A trailing newline is permitted and need not be repeated. For example if your source was print p Since p appears twice and every other byte appears once yo...
stackexchange_codegolf
Background You may be aware that periods in between letters in gmail addresses are ignored. Email sent to example@gmail.com, exam.ple@gmail.com, and e.x.a.m.p.l.e@gmail.com all end up in the same place! This is a great way to have multiple different emails addresses for things like signing up for free trails, or filter...
stackexchange_codegolf
In chess, fork means to target two pieces with just one piece, and one of the best pieces for forking is the knight. In this challenge, you will be given three coordinates in a to h and 1 to 8 (like a8 or e7) format. The first and second coordinates are for two other random pieces, and the third is the knight's coordin...
stackexchange_codegolf
A sculptor is tasked to creating icicle sculptures for the new museum in Greenland. He has been given specifications by his boss, which consists of two numbers: [s, m] or size and melt. Size must be an odd number. He was given some photos of real icicles: vvvvv [5, 0] vvv v vvvvvvv [7, 0] vvvvv vvv v vvv...
stackexchange_codegolf
This challenge is pretty simple: you need to alert / print / show to the user the text "beep boop bop" (or "beep\nboop\nbop", with newlines), but it needs to be obfuscated. (where you couldn't see anything saying "beep", "boop", or "bop"). Points are calculated where your point value is in characters (not bytes)
stackexchange_codegolf
Given three integers N,D,R write a program to output Rth digit after the decimal point in the decimal expansion for a given proper fraction N/D.
stackexchange_codegolf
Objective Use any editor or IDE (vim, emacs, IntelliJ, etc) to write a valid "Hello, World" program in any C-like language. The "!" is optional, but you get style points if you use it. You may use publicly available plugins, a publicly available vimrc, etc, but you may not write or make modifications to them specifical...
stackexchange_codegolf
What is the shortest way to secure a site with Javascript? I am new to Code Golfing, and this is what I've come up with so far. I bet that this could be improved though: Challenge: Make a script which redirects http:// to https:// with the least bytes of code Attempts: Original code (150ish BYTES!): if (window.locati...
stackexchange_codegolf
In the spirit of Patch the Image, here's a similar challenge but with text. Challenge Bit rot has afflicted your precious text! Given a paragraph composed of ASCII characters, with a rectangular hole somewhere in it, your program should try to fill in the hole with appropriate text, so that the paragraph blends as best...
stackexchange_codegolf
Our boolean operators are AND, OR, XOR, NAND, NOR, XNOR and, in conjunction with one of those operators, NOT. Our numbers are \$1\$ and \$0\$. The challenge is to write a program or function that calculates the results of the input. Input A string, array or other input format of your choice; containing alternating numb...
stackexchange_codegolf
Given two words and a list as input, your program must (in as few characters as possible, of course) find the shortest way to "chain" the first word to the last using the ones in the list. Two words are "chained" if their first and last letters are the same, e.g. "Food" and "Door". Your program will take input as a str...
stackexchange_codegolf
We all know about the Fibonacci sequence. We start with two 1s and keep getting the next element with the sum of previous two elements. n-bonacci sequence can be defined in similar way, we start with n 1s and take the sum of previous n elements to get the next element. Challenge Given a positive integer m > 1, output t...
stackexchange_codegolf
In this challenge, the goal is to find the values of some variables after a number of assignments are done. An example input: a = 5 b = 4 c = a = b a = 2 b = a This would result in: a = 2 b = 2 c = 4 Each statement will be one of the following: A variable name ([a-z_]+) A numeric value ([0-9]+) An assignment operati...
stackexchange_codegolf
AlienWar This game takes place in a very crowded planet where aliens are the superior race. Your task is to create your own alien and beat all other. The Board It is a 2 dimensional board. The length of one side of the board is Math.ceil(sqrt(species * 100 * 2.5)) = ~40% of board used. The board is a planet, so if you ...
stackexchange_codegolf
Minesweeper is a puzzle game where mines are hidden around a board of nondescript tiles with the goal of identifying the location of all mines. Clicking on a mine loses the game, but clicking on any other tile will reveal a number from 0-8 which signifies how many mines directly surround it. Given a number, you must di...
stackexchange_codegolf
The challenge Well, I think it is quite clear, isn't it? You have to make a function or a program that takes a string as an argument and outputs the corrispondent Yoda-speaking. This is code-golf, so least number of bytes wins. The input The input could be any string without linefeed. You can translate a string if it i...
stackexchange_codegolf
The height of a binary tree is the distance from the root node to the node child that is farthest from the root. Below is an example: 2 <-- root: Height 1 / \ 7 5 <-- Height 2 / \ \ 2 6 9 <-- Height 3 / \ / 5 11 4 <-- Height 4 Height of binary ...
stackexchange_codegolf
Background Variable declaration statement in C consists of three parts: the name of the variable, its base type, and the type modifier(s). There are three kinds of type modifiers: Pointer * (prefix) Array [N] (postfix) Function () (postfix) You can specify a list of function arguments inside the parens, but for the s...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. Related to AoC2020 Day 3. On the way to vacation, you're traveling through a forest on an airplane. For some biological and geological reasons, the trees in this forest grow only at the exact integer coordinates on a grid, and the entire for...
stackexchange_codegolf
Using our familiar mathematical symbols: +, x, parenthesis, and any rational number, it's easy to create expressions that evaluates to some desired number. For example: 1+(2x3)=7, (1+2)+(3x6.5)=22.5 and so on. Boring enough. In this challenge, we'll use a new operator: ±. The use of ± in an expression means you need to...
stackexchange_codegolf
There is a question on the site that asks to implement division without using division. In my case, I am asking you to do the same, but only using addition. What this means is basically: addition is the only operator or function allowed that operates on numbers and returns other numbers (i.e. no subtraction, multiplica...
stackexchange_codegolf
This is the robbers' thread. The cops' thread goes here. Write a code that has the same number of bytes as the cop post and where the revealed characters are identical. The code must produce 1 in its initial state, and produce the numbers 2, 3 .. when single alterations are made. The winner will be the robber that crac...
stackexchange_codegolf
Warning: Contains minor Deltarune Chapter 1 Spoilers Within the Forest section of the first chapter of Deltarune, there are a few puzzles that consist of entering playing-card suits in a certain order to move to the next section. Below is an example of such a puzzle: The way to solve the puzzle is to do any of the ...
stackexchange_codegolf
Robbers thread In this cops-and-robbers challenge, your task is to write a program h that outputs "Hello Shue!". Next, you have to choose a string i and also write a Shue program p, so that p(i)=h. Your score is len(p)+len(i). Your answer will contain the language of h, i and your score (please write the score as len(p...
stackexchange_codegolf
Robbers' Challenge Read the cops' challenge first. In this cops-and-robbers challenge, you (the robbers) must find the correct string of characters, which, when added into the cop's code, will make it produce the correct (case-sensitive) output (except that there may also be an extra trailing newline at the end). The n...
stackexchange_codegolf
Traveling with electronics is always fun, especially when you need an adapter to charge them. Your challenge is to make planning a trip a little easier by checking if a given plug will be compatible with a given socket. Challenge Given a plug type and a socket type, return a value that indicates whether they will work ...
stackexchange_codegolf
This challenge is inspired by the meme Men of Culture. The meme involves blanking out parts of the original caption, Ah, I see you're a man of culture as well. to make it appear as if the character is saying something else. Your challenge is to write a program that, given an input, show how the original sentence can ...
stackexchange_codegolf
Challenge Given a number, x where -1 ≤ x ≤ 1, and the integers a and b, where b > a, solve the equation sin(θ) = x for θ, giving all solutions in the range a° ≤ θ ≤ b°. Rules x will have a maximum of three decimal places of precision. The output, θ, must also be to three decimal places, no more, no less. Your output ma...
stackexchange_codegolf
The accepted winner is isaacg, with his 7-bit ASCII answer. However, the challenge isn't over yet - this bounty is awarded to the shortest answer. If, somehow, you get all the first characters of all the other answers down into 10 bytes, you will win the bounty. This includes all the characters from Round 2's GolfScrip...
stackexchange_codegolf
Landslides In this challenge, your job is to predict the extent of damage caused by a massive landslide. We use the following simplified two-dimensional model for it, parameterized by an initial height h >= 0 and a critical coefficient c > 0. You start with a cliff of height h, and it is assumed that the terrain is com...
stackexchange_codegolf
Inputs A list (array) of numbers, or numerical strings if that makes it easier. You can assume there will always be at least two elements in the list and every element will be a natural number (integer larger than zero). Outputs A single number, or again, a numerical string. Problem The idea is to reduce the list of nu...
stackexchange_codegolf
I really like times that follow certain patterns. In particular, I like times where all the digits are the same, or all of the digits increase arithmetically by one from left to right. Further, I viscerally hate when people put letters in my times, so all of that AM/PM nonsense is dead to me. Thus, my favorite times ar...
stackexchange_codegolf
Jarl Olaf lives in a beautiful village, Stackholm. In every year he is thinking about raiding a place to get some golden jewelery, food and programmers woman slaves. He is a good person but not the brightest one, so you need to help him decide the next target. He has three targets in his mind: Jarl Burg, England and Pa...
stackexchange_codegolf
Closely related: How high can you count? Challenge In your programming language of choice, write as many different identity programs/functions as possible, under the following constraints: Each program should be a function or full program that is one of the following: A function that takes a single positive integer ...
stackexchange_codegolf
You are given 6 numbers: 5 digits [0-9] and a target number. Your goal is to intersperse operators between the digits to get as close as you can to the target. You have to use each digit exactly once, and can use the following operators as many times as you want: + - * / () ^ sqrt sin cos tan. For example, if I'm give...
stackexchange_codegolf
This question will feature a mechanic from the game "Path Of Exile" in this game there are things called MAPS they are items that you can use to open high level areas, you can also combine 3 of them to get a upgraded one which will be the task of this challenge. The upgrade combinations are as follow: A Crypt Map 68 ->...
stackexchange_codegolf
It's Christmas in July, so what better way to celebrate than a virtual white elephant gift exchange! For this King of the Hill challenge, you must create a bot that plays in a White Elephant exchange simulation, trying to get the highest-valued present it can. Game Rules The game will be played over many rounds, each ...
stackexchange_codegolf
A problem I sometimes encounter is that when writing comments using LaTeX, the comment is too long. Today you will solve this, by writing code which, given a LaTeX math expression, will produce the shortest equivalent expression. To define equivalent expressions, we will need to specify a (simplified) parser for LaTeX:...
stackexchange_codegolf
Specifications Your program must can take in an integer n, then take in n more strings (containing only alphanumeric characters) in your preferred method (separated by whitespace, file input, hash table etc.). You must then find the permutation before the inputted strings when sorted in lexicographical order, and outpu...
stackexchange_codegolf
Your task is to write a full program or function that takes no input and runs any type of loop (while, for, foreach, do, do-while, do-loop, goto, recursion, etc) that will end in causing an error, which means that the program must stop itself running and exit. Rules: The error must be a run-time error, unhandled excep...
stackexchange_codegolf
Introduction Try to convert words to two different unicode fonts. Challenge Your task is to transform your input string into the and unicode characters. All uppercase words should become lowercase words. For Example: WORD -> All lowercase words should become words For example: other words -> All mixed ...
stackexchange_codegolf
From here. Every new game is the first day of the month, 12:00 PM UTC. The goal is to create the Stack Overflow logo using ASCII characters. It looks like this. The exact output should look like this: \\ \\ \= \\ \= \\ \= \\ \== \\ ¯¯¯ \== ¯¯¯...
stackexchange_codegolf
Today I installed MonoGame and ran the test application, which creates a basic colored window. I was surprised to see that the process was using 32.2 MiB of memory, and I thought it could be improved. Your challenge is to write a program that creates a 640 by 480 window displaying only black pixels. Whatever program u...
stackexchange_codegolf
RLE Brainfuck (related to BF-RLE) The hypothetical RLE (Run-Length Encoding) dialect of Brainfuck accepts the symbols for the 8 commands and also accepts digits. The digits are used to represent the number of successive repetitions of a command, thus allowing run-length encoding of the source code. 8> is equal to >>>>>...
stackexchange_codegolf
Given a sequence of integers and an integer N, output the number of contiguous subsequences that contain at least N distinct integers. Each integer in the sequence is non-negative and will not be larger than the size of the sequence. For example, with the sequence 1,2,2,3 and N=2, there are 5 contiguous subsequences t...
stackexchange_codegolf
Given a variable a (non array) or (any[]) convert to (any[]) function example(s: string | string[]) { const e = Array.isArray(s) ? s: [s] return e } Is Array.isArray(s) ? s: [s] the shortest way?
stackexchange_codegolf
Given required values for an expression with 2 variables, output a short expression which fulfill these values Input You may take the input in any reasonable format, e.g. f(x,y)=z, {(x, y): z}, [[[x,y],z]], but please write what format is your input is taken in Output Your output needs the be a valid infix expression f...
stackexchange_codegolf
Credit: Marco Verch CC BY 2.0 A two-cube calendar, as shown in the picture, uses two cubes with digits painted on the faces to display the date. For dates in the range 1-9, a leading zero is used ("01", "02", ..., "09"). Now, if you do the math, you might come to the conclusion that these calendars should be impossibl...
stackexchange_codegolf
This challenge is inspired by xkcd: Challenge: You'll simulate the copying a large file (1 Gigabyte). The transfer rate will vary between 10 kB/second to 100 MB/second. Your task is to output the time remaining of the file transfer. The output should look like: Time remaining: 03:12 (meaning it's 3 minutes and 12 s...
stackexchange_codegolf
Definition: a set is a datatype which allows testing of inclusion ("does set X contain element Y?") but does not have order. Its size is the number of distinct elements it contains. Define an efficiently invertible injection from sets of k integers in the range 0 to 1000 inclusive to sets of k+1 integers in the range 0...
stackexchange_codegolf
For the purpose of this challenge a rectangular piece of ASCII art is Mondrian if it looks the same upside down. What does "looks the same" mean? A feature is any orthogonally connected region of at last 5 characters. A Mondrian feature is any feature that appears in the same picture upside down. (This includes the pos...
stackexchange_codegolf
As in, the 5 speed transmission from the original VW Golf GTI. Print the transmission pattern in as few bytes as possible. Yes I know this isn't what it actually looks like but the GTI 5 speed shift knob pattern is a lot worse. 1 3 5 | | | |--|--| | | | 2 4 R
stackexchange_codegolf
This challenge is a riff on Dion's challenge "Is this a rectangle?". The goal of this challenge is to write a program to decide whether or not some collection of tuples of integers represents a hypercube of some dimension. Background A hypercube is a generalization of a square. A \$0\$-cube is a single point. A \$1\$...
stackexchange_codegolf
So glad I found this cool site. Wanted to try sharing a coding challenge a friend gave me, an interview question. Usually it is written in java, but you can use whatever language you want, just have fun! Challenge: write efficiently and securely a program that creates an array of n threads that communicate with each o...
stackexchange_codegolf
Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro. I am an evil farmer, and to drive up the price of wheat in my area, I've decided to burn the fields of all the farmers around me. I would really like to see the fields go up in flames (...
stackexchange_codegolf
Challenge: Given two inputs, x and y, round x to one less significant figure, then repeat until it has y number of unrounded digits left. (the decimal point does not count as a digit) Input & Output Input can be a combination of strings and integers, e.g. you can have the input as a string and the output as an int, o...
stackexchange_codegolf
Recently I had a Maths test and noticed that a certain number on the test matched an interesting pattern. The number (28384) matched a generic digit sequence that looks like this (n)(x)(n+1)(x)(n+2)(x)(n+3) etc... where n and x are single digit integers. The sequence can begin with either x or n and end with either x ...
stackexchange_codegolf
Write a function or program than can do simple arithmetic (addition, subtraction, multiplication and division) in both base 10 and base 2. The function will take a mathematical expression as input, and output the correct result in the correct base. The input will be n numbers separated by one or several operators (+ - ...
stackexchange_codegolf
Description The Caesar cipher is a cipher, where every letter in the alphabet will be rotated by a secret number. If the rotation is \$7\$, then a -> h, g -> n, v -> c and z -> g. Today, we're playing Caesar's Cipher with ASCII chars, (0-127 inclusive). So, with rotation \$7\$, b -> i, Z -> a, x -> DEL (127), But, even...
stackexchange_codegolf
NOTICE: This challenge is now closed: I will no longer be updating the leaderboard and will not change the accepted answer. However, you are free to run the controller and update the leaderboard yourself, if you wish. Join the chat! Introduction Good evening, traders! You are all traders for the golfing company PPCG....
stackexchange_codegolf
Given positive integer n and e, knowing that e<n and that n is the product of two different odd primes(but the primes are not directly given to you), find such a positive integer d smaller than n that, for each integer m, (me)d ≡ m (mod n). Your program should handle n up to 24096 in 1TB space, but not necessary reaso...
stackexchange_codegolf
Your mission is to build an algorithm (program or function) that can optimize packing fruit from a conveyor belt into bags to be sent off to retailers, optimizing for a largest number of bags. Each bag has to weight at least a certain amount, but any excess is lost profit since that weight could be used to fill another...
stackexchange_codegolf
Robbers thread Your task is to create a method for hiding information in an image. You will post three encoded messages of your choice (keep them classy), each with its associated image. Reveal the messages for the first two images and do not reveal the third. Robbers have the task of determining what your third hidden...
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
In R print(x, digits=n) does something a little complicated. It always shows all the digits to the left of the decimal point and then, if there are any digits to the right it rounds the whole number so that at most n digits are shown. However, leading 0s are not counted. Here are examples to show how the function work...
stackexchange_codegolf
The alternating factorial is an alternating sum of decreasing factorials. For example, we could calculate the alternating factorial of 4 as follows: First, calculate the factorials from 4 down to 1: $$ 4!\quad3!\quad2!\quad1!\quad = \\ 4\cdot3\cdot2\cdot1\qquad3\cdot2\cdot1\qquad2\cdot1\qquad1\quad= \\ 24\quad6\quad2...
stackexchange_codegolf