instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Vim is a great text editor for unix systems, but it's notorious for being difficult to exit. Write a full program that will output :q to exit Vim. It should then read a single line of input, as it will then either be given a bash prompt, in which case the exit was successful, or an error, in which case there are unsave...
stackexchange_codegolf
What general tips do you have for golfing in MathGolf? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to MathGolf (for tips which can be applied to loads of programming languages, look at the general tips).
stackexchange_codegolf
I'm designing a new space station for generic super-villain purposes (something something megalaser), but I'm having trouble designing the solar panels. My genius team of scientists can calculate exactly how many square meters of paneling we need to power the station, but the problem is our solar panels only come in sq...
stackexchange_codegolf
I'm looking for a program such that, given a finite list of strings, can find short regexes to match exactly all of them and nothing else. Since there are multiple languages that express regexes differently, there can correspondingly be multiple regex generators. Each answer must discuss regex generation in one langaug...
stackexchange_codegolf
The subfactorial or rencontres numbers (A000166) are a sequence of numbers similar to the factorial numbers which show up in the combinatorics of permutations. In particular the nth subfactorial !n gives the number of derangements of a set of n elements. A derangement is a permutation in which no element remains in the...
stackexchange_codegolf
I saw a problem which asks you to print "Hello World" using the fewest characters, including spaces. How can I further shorten this code? Thank you in advance! #include<iostream> int main(){printf("Hello World");}
stackexchange_codegolf
In this challenge, players need to tamper with a time bomb as late as possible without getting blasted in the face. Mechanics Let N be the number of bots plus one. Each round, each bot receives the following arguments: numbers played by all bots last round in ascending order. number of points it received last round. N...
stackexchange_codegolf
Infinite Snake is just like the video game Snake, except for that the snake is infinitely long, there are no items to eat, and the Snake needs to move in a repeating n-step move pattern (e.g. right, up, right, up, right, down). The only constraint is that you can't crash back into yourself. Challenge Your goal is to wr...
stackexchange_codegolf
Task Given a square array of 0s and 1s, determine whether or not there exists a path of 1s connecting the leftmost and rightmost columns. A path can take steps of one unit up, down, left or right, but not diagonally. Every symbol on the path must be a 1, and it must start somewhere in the first column and end somewhe...
stackexchange_codegolf
Rövarspråket Rövarspråket is a word game played by Swedish children, from the books about Kalle Blomkvist by Astrid Lindgren. The basic rules are as follows (from Wikipedia): Every consonant (spelling matters, not pronunciation) is doubled, and an o is inserted in-between. Vowels are left intact. A few examples: "h...
stackexchange_codegolf
This is a code-shuffleboard answer-chaining challenge, where the answers will aim to, together, output the lyrics to this beloved 80s song. This is the full lyrics of the song, line by line. The first answer will contain a program that will output the first line of the song (We're no strangers to love). The second wil...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Santa and the Elves are secretly preparing for a new tourist train service, called "North Pole Railroads". The train will travel through various sightseeing spots near the North Pole. As a part of this project, they want to know how ma...
stackexchange_codegolf
In chemistry class, we were learning about titrations, and attempting one as a lab. We were using phenolphthalein as the indicator for the titration, so on top of grading the lab normally, my teacher held a little contest to see who had the lightest shade of pink, and thus the most accurate transition. Your task is to ...
stackexchange_codegolf
Introduction Each Unicode codepoint can be represented as a sequence of up to 4 bytes. Because of this, it is possible to interpret some 2, 3, or 4-byte characters as multiple 1-byte characters. (See here for a UTF-8 to bytes converter). Challenge Given a UTF-8 character, output it split into a sequence of 1-byte chara...
stackexchange_codegolf
Your task today is to implement a time limit for getting input, a task I've found rather annoying to achieve in most languages. You will create a program function which prompts the user for input. Immediatly after the user supplies input, print the message input received and end execution/return. However, if the user w...
stackexchange_codegolf
Two numbers are considered amicable if the proper divisor sum of the first is the same as the second number, the second number's proper divisor sum is equal to the first number, and the first and second numbers aren't equal. \$s(x)\$ represents the aliquot sum or proper divisor sum of \$x\$. 220 and 284 are amicable be...
stackexchange_codegolf
Consider a sorted array of positive floating point numbers such as: input = [0.22, 2.88, 6.35, 7.17, 9.15] For each integer \$i\$ from 1 up to the last value in input rounded up, output the mean of all values less than \$i\$. In this case the output should be: [0.22 0.22 1.55 1.55 1.55 1.55 3.15 4.155 4.155 5.154 ] I...
stackexchange_codegolf
Challenge: You are given a base 10 number. For each base from 10 counting down to base 2: Take the original input number as a base 10 string, and remove any digits of the number which are invalid for the base. Interpret the resulting number string in the that base. If this gives 1 or 0, terminate the whole process. O...
stackexchange_codegolf
Introduction Given an undirected graph G, we can construct a graph L(G) (called the line graph or conjugate graph) that represents the connections between edges in G. This is done by creating a new vertex in L(G) for every edge in G and connecting these vertices if the edges they represent have a vertex in common. Here...
stackexchange_codegolf
There are n people on a 2D plane. Using distances between them we're going to find their positions. To get a unique answer you must make four assumptions: There are at least 3 people. The first person is at position (0, 0). The second person is at position (x, 0) for some x > 0. The third person is at position (x, y) ...
stackexchange_codegolf
We often get restricted-source questions here on PPCG that favour submitting solutions using only a subset of characters (sufficiently so that there's a tag printable-ascii that identifies a particular subset of those challenges). Wouldn't it be nice if we could automatically cut languages down to a subset of their nor...
stackexchange_codegolf
I noticed that in Microsoft Word, single quotations are either ‘ or ’, but not in Notepad. Your task today is: given a string q, convert all the ' characters (only) to ‘ or ’, according to these rules, and then output it: If the character before the quote is a space, and after it comes a character, it becomes ‘ If the...
stackexchange_codegolf
Write a piece of JavaScript code that calls alert with an array containing the first 50 Fibonacci numbers in order. You may only use the following characters: +!()[]. As a reference, your code must be functionally equal to the following: var fib = [], a = 1, b = 1; for (var _ = 0; _ < 50; _++) { fib.push(a); va...
stackexchange_codegolf
Given a multidimensional, rectangular array of nonnegative integers, sort it at every depth (lexicographically), starting from the innermost. For example, with this array: [ [ [5, 1, 4], [10, 7, 21] ], [ [9, 20, 2], [4, 2, 19] ] ] You'd sort at the deepest first: [ [ [1, 4, 5], [7, 10, 21] ], [ [2,...
stackexchange_codegolf
Given a single digit integer and a three digit integer, output a mathematical formula that uses only the single digit and a given list of operators to equal the three digit integer. Input: A one digit positive integer (1-9) and a three digit integer (100-999) Output: A mathematical formula meeting the following requir...
stackexchange_codegolf
Your task is to make a program that takes in an integer n > 1, and outputs the roll of a single n-sided die. However, this dice follows the rules for exploding dice. When you roll the die, check what value you rolled. If you got the maximum for that kind of die (on a standard d4 that would be 4, or 6 on a d6, etc.), ro...
stackexchange_codegolf
A riffle shuffle is a type of shuffle where the deck is split into two partitions and the partitions are then spliced back together to create a new shuffled deck. The cards are spliced together in such a way that cards maintain their relative order within the partition they are a member of. For example, if card A is b...
stackexchange_codegolf
Inspired by and drawns from Is this number Loeschian? A positive integer \$k\$ is a Loeschian number if \$k\$ can be expressed as \$i^2 + j^2 + i\times j\$ for \$i\$, \$j\$ integers. For example, the first positive Loeschian numbers are: \$1\$ (\$i=1, j=0\$); \$3\$ (\$i=j=1\$); \$4\$ (\$i=2, j=0\$); \$7\$ (\$i=2, j=...
stackexchange_codegolf
The objective Given a Russian text, encrypt it with Caesar cipher with key 16. The basic Cyrillic alphabets The basic Cyrillic alphabets are: (U+0410 – U+042F) АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ By the Caesar cipher, they are mapped to: РСТУФХЦЧШЩЪЫЬЭЮЯАБВГДЕЖЗИЙКЛМНОП The small letters (U+0430 – U+044F) are also mappe...
stackexchange_codegolf
RPS 25 is a version of Rock Paper Scissors which has 25 hand symbols instead of just 3. Each symbol defeats 12 symbols, and is defeated by 12 others. Here's a link to a chart showing which symbols defeat which. The challenge here is simple: your program should take in two strings representing the symbols thrown by each...
stackexchange_codegolf
Write code to determine who wins a four-card trick in a game of Spades. Fewest bytes wins. The input is a string that lists the four cards played in sequence like TH QC JH 2H (Ten of Hearts, Queen of Clubs, Jack of Hearts, Two of Hearts). A card is given by two characters: a suit from CDHS and a value from 23456789TJQK...
stackexchange_codegolf
Pip is an imperative golfing language with infix operators. It also borrows some features from functional and array programming. What general tips do you have for golfing in Pip? I'm looking for approaches and tricks that are commonly useful for code golf and are specific to Pip (e.g. "remove comments" is not an answer...
stackexchange_codegolf
When playing the piano, I realized that to play a chord right, I usually need to remember just which tones of the chord are played on white and which on black keys. The rest is usually handled by the "autopilot". Let's write a program that given a 7th chord, it outputs which of its tones are to be played on black (char...
stackexchange_codegolf
Your program will control a mining robot searching underground for valuable minerals. Your robot will tell the controller where you want to move and dig, and the controller will provide feedback on your robot status. Initially your robot will be given an image map of the mine with some mining shafts already present, an...
stackexchange_codegolf
...so this is a challenge to make me a tree. Produce a program or function called tree which takes a single integer argument, N and draws a Pythagorean Tree N levels deep, where level 0 is just the trunk. Each junction of the tree should place the vertex of the triangle at a random point on the perimeter (this point sh...
stackexchange_codegolf
Warning: This challenge is only valid for languages with a compiler. Make a program (which is perfectly valid code) that outputs Hello, World, even before runtime. How? Let me explain. Many languages have a compiler. Some operations are made in the compile-time, and others, in runtime. You trick the compiler to outpu...
stackexchange_codegolf
You will be given as input an infinite stream of positive integers. Your task is to write a program which outputs an infinite sequence of lists with two requirements: All lists in the output are finite sub-lists of the input stream. Every sub-list must be output eventually by your program. Sub-lists are not necessari...
stackexchange_codegolf
Create a Pascal's Triangle that is a nested list and contains zeros in the unused spots. In the output array, the numbers of Pascal's Triangle are separated by zeroes and padded by zeroes on each side so that they are centered. For example, the bottom row (last sub-array) must have no zeroes on the left and the right; ...
stackexchange_codegolf
Objective Given two Chinese ideographs meaning basic colors, output the ideograph that means the color resulting from mixing them. Basic colors The basic colors are: 靑(U+9751; blue) 赤(U+8D64; red) 黃(U+9EC3; yellow) 白(U+767D; white) 黑(U+9ED1; black) Mixed colors Mixing 靑(blue) and 赤(red) yields 靘(U+9758; purple). Mix...
stackexchange_codegolf
Challenge Write a solver for the Chess Light puzzle game, in the smallest amount of code. The input will be a representation of a chessboard, how in yours is up to you. My examples below is textual, in which some squares may already be occupied by black peices. Some of the unoccupied squares are designated with a #, al...
stackexchange_codegolf
Cross posted from my anagolf post (note: may contain spoilers, post mortem). Output the following text exactly. You may have additional trailing whitespace on each line, and trailing newlines as well. Shortest code, in bytes, wins. ...
stackexchange_codegolf
This will be a bit of a different challenge. Back in 2023, I developed a 2D esolang called Electra, and looking back at my hello world program, (which is 582 bytes by the way) I see a lot of room for golfing. There are some topics that aren't covered in the spec, e.g. in which order the currents are generated/interpret...
stackexchange_codegolf
A space cleaner is a special character which removes all spaces between it and the first non space character to its left and it is represented by a '!' character. If it reaches the beginning of the string it stops. Given a string output the string in any reasonable format after the cleaning process. Trailing spaces at ...
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
In base-10, all perfect squares end in \$0\$, \$1\$, \$4\$, \$5\$, \$6\$, or \$9\$. In base-16, all perfect squares end in \$0\$, \$1\$, \$4\$, or \$9\$. Nilknarf describes why this is and how to work this out very well in this answer, but I'll also give a brief description here: When squaring a base-10 number, \$N\$, ...
stackexchange_codegolf
Shuffling a deck of cards is hard for kids, so they must figure out ways to get a reasonable well shuffled deck as simply as possible. One way to do this that gives reasonably good results is: Take the top card out and insert it a random place in the deck Take the bottom card out and insert it in a random place in the...
stackexchange_codegolf
Let us consider the following representation of the periodic table. __________________________________________________________________________ | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |--------------------------------------------------------------------------| |1| 1...
stackexchange_codegolf
Your input is an array of numbers: a permutation of \$\{1, 2 \dots n\}\$ for some integer \$n \geq 2\$. How many times must you repeat this list before you can "pick out" the numbers \$[1, 2 \dots n]\$ in order? That is: find the lowest \$t \geq 1\$ so that \$[1, 2 \dots n]\$ is a subsequence of \$\text{repeat}(\text{i...
stackexchange_codegolf
Challenge Taken from my university code challenge contest This is actually Day 0 but yesterdays' challenge was too easy and can be a dupe of another question here. Tetris is a video game that became popular in the 80s. It consists of placing a series of pieces with different shapes that fall on a board, so that they f...
stackexchange_codegolf
You are fighting an extensive network of enemy spies. You know that each spy has at least one (sometimes multiple) fake identities they like to use. You'd really like to know how many spies you're actually dealing with. Luckily, your counter-intelligence agents are doing their job and can sometimes figure out when two ...
stackexchange_codegolf
Write a program that outputs the contents of the first HTML <code>...</code> block of the answer to this question that is just above yours when the answers are sorted by votes. Output Top! if you are the top answer. Ignore answers that have negative votes or no <code>...</code> tags. The source of your program must app...
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
Sandboxed Given a set of closed non-overlapping 2d contours (separated by at least one space even on diagonals) with arrows oriented consistently in the same clockwise or counter-clockwise direction (each contour has its own direction) and a positive number n, move the arrows n steps along the contours in the respectiv...
stackexchange_codegolf
Let \$\sigma(n)\$ represent the divisor sum of \$n\$ and \$\sigma^m(n)\$ represent the repeated application of the divisor function \$m\$ times. Perfect numbers are numbers whose divisor sum equals their double or \$\sigma(n) = 2n\$. For example, \$\sigma(6) = 12 = 2\times6\$ Superperfect numbers are numbers whose twic...
stackexchange_codegolf
This is the follow up question to standard Sudoku solver. You are given a Sudoku grid where . represents an empty cell and the other cells are filled with numbers 0-8 (inclusive). Rules: All the numbers in Sudoku must appear exactly once in all left-top to right-bottom diagonals. All the numbers in Sudoku must appear ...
stackexchange_codegolf
Given 4096 16-bit integers, only four of which are unique and others appeared twice (so 2050 different integers exist). Find the four uniques. To time precisely and limit RAM usage, your program will be run on a 12MHz 8051(with 128B RAM). I'll test with a random case generated by some code to test, but we aim at the wo...
stackexchange_codegolf
Related: Read a crossword Task Given a completed Crossword puzzle, extract the words in it with their respective clue numbers, with "across" (horizontal) and "down" (vertical) words grouped and ordered like a real crossword puzzle. The words are numbered in the row-major order of their first letters. If an "across" wor...
stackexchange_codegolf
Introduction Our goal is to efficiently find the maximum of a large amount of (redundant) data. We define the outer product of vectors \$A\$ and \$B\$ as a matrix containing the products of all entries of \$A\$ with each entry of \$B\$. (see outer Product) $$ A\otimes B := A\cdot B^T = \left(\begin{array}{rrr} A(1)\cdo...
stackexchange_codegolf
Write a program in the shortest number of bytes possible that will parse any string given to it by input, and output that string with any and all numbers padded with leading zeroes to match the largest number's length. For example: Input: This 104 is an -8 example of 4.518 a string 50. The generated output should beco...
stackexchange_codegolf
using Prefixed Length Code We are going to implement a compression of text (string, array/list of characters/bytes) by simple substitution of each character by a binary code, based on the frequency of that character in the text. The characters that occur more frequently will be replaced by shorter codes. The resulting ...
stackexchange_codegolf
How many ways can one place (unlabelled) dominoes on a square chequerboard such that the number placed horizontally is equal to the number placed vertically? The dominoes must align with, and may not protrude, the chequerboard and may not overlap. This is OEIS sequence A330658, 1, 1, 1, 23, 1608, 371500, 328956227, 112...
stackexchange_codegolf
Quote notation is a way of expressing rational numbers based on the concept of \$p\$-adic numbers, written in the form \$x'y\$. The quote indicates that the number to it's left (\$x\$) is "repeated" infinitely to the left, then prefixed to the number on the right (\$y\$). For example \$3' = \: ...3333\$ and \$764'31 = ...
stackexchange_codegolf
The goal is, having taken a string as input, duplicate each latin letter and "toggle" its case (i.e. uppercase becomes lowercase and vice-versa). Example inputs & outputs: Input Output bad bBaAdD Nice NniIcCeE T e S t Tt eE Ss tT s E t sS Ee tT 1!1!1st! 1!1!1sStT! n00b nN00bB (e.g...
stackexchange_codegolf
TL;DR: Given an array of chars and a robot in a starting position of the array, write an algorithm than can read a string with movements (F for "go forward", R for "rotate 90 degrees right" and L for "rotate 90 degrees left") and calculate the ending position of the robot. More details in the complete text. We have a...
stackexchange_codegolf
This is a program I wrote in JavaScript to validate some inputted credentials, with an intentional vulnerability. The credentials_validator function takes an object as input, with usernames and passwords. It returns a function, which takes a username and password and returns true if the credentials are valid. Your chal...
stackexchange_codegolf
Introduction Nine-Ball is a popular pool game played casually and as a competitive sport. There is one of each numbered ball, with the numbers 1 to 9. The game starts with all 9 of the balls in a diamond shaped rack, like so: 1 2 3 4 9 6 5 7 8 The 1 ball is always at the front of the diamond, and the 9 ball is a...
stackexchange_codegolf
Sometimes, while golfing, one needs to represent large number(s) in their code. Writing them as is can significantly increase the byte-count. What general1 tips do you have for representing long numbers concisely in code? Please post one tip per answer. 1With general, I mean tips that can be applied to more than a sin...
stackexchange_codegolf
There is a site called "Return True to Win" with interesting tasks for Javascript programmers. The goal is to find arguments to a given function that force it to return true. The following is one of the tasks: function total(x) { return (x < x) && (x == x) && (x > x); } The users must find snippets for the value of ...
stackexchange_codegolf
Challenge Determine how many integer lattice points there are in an ellipse $$\frac{x^2}{a^2} + \frac{y^2}{b^2} \leq 1$$ centered at the origin with width \$2a\$ and height \$2b\$ where integers \$a, b > 0\$ . Input The Semi-major \$a\$ and Semi-minor \$b\$ axes. Output Number of interior and boundary points. Example E...
stackexchange_codegolf
Note: Bot Factory KoTH (2.0) is now posted; you're probably looking for that one instead! In this challenge, bots (consisting of JS functions) move around an infinite factory (playing field), collecting characters (UTF-16). These characters can be used to build worker bots, or droppedfor other bots to pick up. Results ...
stackexchange_codegolf
How long's left? Recently, I was making pizza using a 5-minute timer on my phone. When someone walked in and asked me how long was left, I was confused for a moment at first as to how to answer the question. You see, if the timer at the current moment was at 3:47, by the time I had read out 'Three minutes and forty sev...
stackexchange_codegolf
Like the previous SmokeDetector challenge? This one is for you too ;) Note: SmokeDetector is a bot that detects spam and offensive posts on the network and posts alerts to chat. What to implement Smokey's !!/coffee command uniformly at random picks one of these words (sorts of coffee): Espresso Macchiato Ristretto A...
stackexchange_codegolf
In: Enough memory and a positive integer N Out: N-dimensional N^N array filled with N, where N^N means N terms of N-by-N-by-N-by... Examples: 1: [1] which is a 1D array (a list) of length 1, containing a single 1 2: [[2,2],[2,2]] which is a 2D array (a table) with 2 rows and 2 columns, filled with 2s 3: [[[3,3,3],[3,3,...
stackexchange_codegolf
I'm looking to find the fastest racer around. Show me your fastest lap around this 18x14 track shown below. ______ / \ / \ / ____ \ / / \ \ / / \ \ | | | | | | | | | | | | | | | | \ \ / / \ \____/ / \ ...
stackexchange_codegolf
Getting the average of a list (e.g [2,6,7]) Get the length of the list: [2,6,7] -> 3 Sum the numbers in the list: 2 + 6 + 7 = 15. Divide the sum by their count: 15 / 3 = 5. You should compare the averages of two lists of positive integers N and M, by returning a value if N has a higher average, another value if M ha...
stackexchange_codegolf
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯. All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of one...
stackexchange_codegolf
We have a square 10x10 meter garden outside our house. We want to plant grass and make a terrace. We have decided how to divide the garden, but we haven't decided the ratio between amount of grass vs terrace. We need help visualizing it, and ASCII-art is clearly the best way to do so. Challenge: Take an integer in the...
stackexchange_codegolf
Textbattles Textbattles is is strategy game about, well, text. It consists of a 10x10 grid, where each player has a position on the grid. When it is a player's turn, they can decide whether to move a step in any direction on the grid, or just stay where they are. If a player moves into another player's spot, they are ...
stackexchange_codegolf
I think the Collatz Conjecture is already well-known. But what if we invert the rules? Start with an integer n >= 1. Repeat the following steps: If n is even, multiply it by 3 and add 1. If n is odd, subtract 1 and divide it by 2. Stop when it reaches 0 Print the iterated numbers. Test cases: 1 => 1, 0 2 ...
stackexchange_codegolf
Given an integer n as input, return a list containing n, repeated n times. For example, the program would take 5 and turn it into [5,5,5,5,5]. The elements need to be integers, not strings. No built-in functions that accomplish the task are allowed. This is code-golf, so standard rules apply.
stackexchange_codegolf
Task Take the (integer) number of human years that the dog has lived, \$n\$, as input and return its age in dog years, \$d\$, to two decimal places. The number of human years, \$n\$, will be between \$1\$ and \$122\$ inclusive: \$n \in [1,122], n \in \Bbb{N}\$. According to BBC's Science Focus Magazine, the correct fun...
stackexchange_codegolf
All bots at the battle arena suddenly got brainfucked and no one can explain why. But who cares as long as they are still able to fight - although Brainfuck is the only language they understand anymore. It's been a while since the last submission so I'll finally annouce the winner of BrainFuckedBotsForBattling: Congra...
stackexchange_codegolf
Given an image that has only black and white pixels and an (x,y) location that's a white pixel, color the white pixels based on their minimal Manhattan distance from (x,y) in a path that only involves traversing other white pixels. The hue of the colored pixels must be proportional to their distance from (x,y), so the ...
stackexchange_codegolf
You're writing your favorite language and you want to display the following string: abcdefghijklmnopqrstuvwxyz to your happy customer. Unfortunately, your keyboard is broken and you can now only type symbols !+-*/[](). You must submit a code that evaluates to be the string abcdefghijklmnopqrstuvwxyz or print the string...
stackexchange_codegolf
In this challenge you will be asked to implement any function (or full program) that fulfills two properties. Those properties are: Your function must be an injective (reversible) function from the polynomials with non-negative integer coeffecients to the non-negative integers. This means no two unequal inputs can m...
stackexchange_codegolf
This page is not for Visual Basic .NET Tips or VBA tips Visual Basic (VB or VB6) is an object-oriented and event-driven dialect of basic that was developed and released by Microsoft in 1991. The last release of Visual Basic came as Visual Basic 6.0 in 1998, and the language was declared a legacy language in 2008. Visu...
stackexchange_codegolf
Detect Duplicate Questions Once upon a time, there was a golfing site. It had a problem: people would post similar or identical questions again and again. You have been chosen selected forced conscripted blackmailed requested to automate the process of deciding whether a question is a duplicate of an existing one, by w...
stackexchange_codegolf
There's a lot of questions about Conway's Game of Life, but nothing about customization (Related: 2-Player Life). Given an input, determine the result on a 100x100 grid after some iterations. The input is given as a string. For example: Using the character #, follow the following rules: If there are 2 or 3 neighboring ...
stackexchange_codegolf
Robber's thread Your task as cops is to select three things: A programming language An OEIS sequence A byte set You are then to secretly write a program in that language that computes the nth term sequence using only the bytes in the set. You will reveal the three pieces of information so that robbers can try to f...
stackexchange_codegolf
Background Bilibili is a China-based video sharing platform, similar to Nico Nico Douga in Japan, and Youtube around the world. Since the establishment, Bilibili had been using the AV code to reference a video. An AV code is a string of 3 or more characters, starting with av and followed by a natural number, like av820...
stackexchange_codegolf
In this challenge you will receive a list of positive integers \$W\$ called a word, and a square symmetric matrix \$M\$. Your task is to determine if the word can be turned into the empty list by applying a series of valid moves. The valid moves are: If two consecutive values in the list are equal you may remove them ...
stackexchange_codegolf
Very related You're given a piece of ASCII art representing a piece of land, like so: /‾\ __/ ‾\_ \_/‾\ \ Since an overline (‾) is not ASCII, you can use a ~ or - instead. Your challenge is to determine if it is connected by the lines of the characters. For example, the above can be traced ...
stackexchange_codegolf
I just discovered this site and this is my first question, I hope I'm doing it correctly. The challenge is the following, you must write a code that prints all the prime numbers of \$n\$ digits. Since this problem is computationally complicated, I think that one way to simplify it is to give a number \$m\$ that will be...
stackexchange_codegolf
After the last Ludum Dare (LD) game programming contest a friend of mine made a nice mosaic of all the LD game thumbnails: After searching for my own game I quickly gave up and decided to solve it like a real programmer... by writing code that finds my game thumbnail. This is the thumbnail of my game: More examples c...
stackexchange_codegolf
Introduction Suppose you have a list of lists of integers (or any objects really, but let's stick to integers for simplicity). The lists may be of different lengths, and some of them may be empty. Let's write the lists in a tabular format: [[ 1, 2, 3, 4, 5], [ 6, 7], [ 8, 9, 10, 11], [], [12, 13, 14...
stackexchange_codegolf
yOu wiLl bE giVen A sTriNg wHich cOnsiSts oF pRintAble asCii cHarActErs. yOu iTeraTe tHrougH thE sTrIng tHen chAnge rAndOM(uNifoRm, 50% cHanCe uPPercAse) lEtteRs to uPPercAse aNd eVerytHing elSe tO lOwercAse. tHat'S iT. (sorry for the punctuation, it was for the concept of the question) Readable version: You wi...
stackexchange_codegolf
Your program should find the number of string pairs (pairs of 2) that contain all vowels (a e i o u), when given an integer N and N strings. There are easy ways to do this, but I'm looking for the quickest possible solution. Example: INPUT: 4 password unique orbiting ointmental OUTPUT: 2 EXPLANATION: password has a,o...
stackexchange_codegolf
The picture below shows a RLC circuit. A RLC circuit is an electrical circuit consisting of a resistor (R), an inductor (L), and a capacitor (C), connected in series or in parallel. (1) In order to simplify computations, it's common to work in the frequency (Laplace) domain instead of the time domain. Your task is: Ta...
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
Fluff After taking a look at deadfish, I decided it sucked, so I came up with a new (and easier) variant of it: imnotdeadfish. As with its predecessor, there are 4 commands and an accumulator which begins at 0: + # increment the accumulator - # decrement the accumulator s # square the accumulator o # output the accumul...
stackexchange_codegolf