instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
This was inspired by a function I recently added to my language Add++. Therefore I will submit an short answer in Add++ but I won't accept it if it wins (it wouldn't be fair) Don't you hate it when you can multiply numbers but not strings? So you should correct that, right? You are to write a function or full program...
stackexchange_codegolf
><>, or Fish, is a two-dimensional esoteric programming language where the instruction pointer (IP) toroidally moves around the codebox, wrapping when it hits an edge. ><> has four basic movement instructions - <, >, ^, and v, which respectively mean to change the IP's direction to left, right, up and down. It also has...
stackexchange_codegolf
Background (skip to definitions) Euler proved a beautiful theorem about the complex numbers: \$e^{ix} = \cos(x) + i \sin(x)\$. This makes de Moivre's theorem easy to prove: $$ (e^{ix})^n = e^{i(nx)} \\ (\cos(x) + i\sin(x))^n = \cos(nx) + i\sin(nx) $$ We can plot complex numbers using the two-dimensional Euclidean plane...
stackexchange_codegolf
Given an ASCII string, output the exploded suffixes of it. For example, if the string was abcde, there are 5 suffixes, ordered longest to shortest: abcde bcde cde de e Each suffix is then exploded, meaning each character is copied as many times as its one-indexed location in that suffix. For example, exploding the suf...
stackexchange_codegolf
Introduction This challenge is about producing a code to count the frequency of bigrams in a text. A bigram is two consecutive letters in a text. For instance 'aabbcd' contains the bigrams aa, ab, bb, bc, cd once each. Counting bigram frequencies is super useful in cryptography. In a brute force algorithm, this code ma...
stackexchange_codegolf
Introduction Remember the roaring 80's? I mean, you know, like 30 years ago? No cell phones, no internet, no ATM's, fluorescent clothing (what was that?!) and scrolling marqee's! No, no, no! Not the online ones, but real ones, With LED lights. Since I'm in a nostalgic mood, I'd like you to create a scrolling marquee. ...
stackexchange_codegolf
Your task is "simple" should you choose to accept it. Write an HQ9+ compiler in a language of your choice. HQ9+ has four commands (as you may be able to tell) H prints "Hello, World!" Q prints out the source code (this can either be the compiled source or HQ9+ source for the purpose of this challenge),9 prints out the...
stackexchange_codegolf
There was a prior question about golfing an HQ9+ compiler that translates HQ9+ code into the language it is written in, but that was closed as a duplicate of the interpreter challenge because converting an interpreter to a compiler is seen as trivial. This question is based on the closed one, but has some changes. Writ...
stackexchange_codegolf
Slimes are cube shaped enemies in Minecraft that break into multiple smaller versions of themselves when killed. For the purposes of this challenge we'll depict them as an 8×8 pixel image with 3 colors: ← True 8×8 version. The precise RGB colors are: 0, 0, 0 for the eyes and mouth 110, 170, 90 for the central, darke...
stackexchange_codegolf
Definition A vector a containing n elements is said to majorize or dominate a vector b with n elements iff for all values k such that 1 ≤ k ≤ n, the sum of the first element of a↓ through the kth element of a↓ is greater than or equal to the sum of the first through kth elements of b↓, where v↓ represents the vector v ...
stackexchange_codegolf
Input Your program will take in the integer coefficients of the equation \$ax^3+bx^2+cx+d=0\$ as inputs (a, b, c, and d). Output All real solutions of the input equation, with an accuracy of at least the thousandths place, sorted from smallest to largest. Rules Built-in equation solver are not allowed Native math ...
stackexchange_codegolf
After all assignments are submitted, a dictionary is created that maps student number to the hash of their file. This dictionary, or hashmap, or mapping (whatever your language calls it) will look as follows: {100: "aabb", 104: "43a", 52: "00ab", 430: "aabb", 332: "43a"} The key is the student number, and the value is ...
stackexchange_codegolf
Recently, I made a made a typo and I wrote unicorn instead of unicode, I did what any normal person would do and I made an esolang out of it. In this challenge you will be writing a Unicorn interpreter. Because Unicorn programs are horrible long, you'll have to write a short interpreter to compensate for this. Example ...
stackexchange_codegolf
Background Story Bob was handed the following assignment for his programming class. Please note: this is not the actual challenge. Homework assignment 11: Twin primes Input: an integer n ≥ 8, taken from STDIN. Output: a message to STDOUT, depending on n: If n is not a prime number, output Not prime. If n is a prime n...
stackexchange_codegolf
A prime number is a positive integer that has exactly two divisors 1 and the number itself. For example number 7 is a prime since it is divisible by 1 and 7. Number 1 is not a prime since it has only one divisor. Write a program or function that produces all even prime numbers. This is a code golf challenge, shortest a...
stackexchange_codegolf
Challenge Given two positive integers \$1 \le m \le 12\$ and \$1\le d \le 31\$, representing a month and days into the month, output the amount of days that have passed since January 1st, on a non-leap year. You can assume that the number of days passed will always be constrained by the number of days in the month (so ...
stackexchange_codegolf
The challenge Find the smallest feedforward neural network such that, given any 3-dimensional input vector \$(a,b,c)\$ with integer entries in \$[-10,10]\$, the network outputs the largest (i.e., "most positive") root of the polynomial \$x^3+ax^2+bx+c\$ with error strictly smaller than \$0.1\$. Admissibility The notion...
stackexchange_codegolf
Input A string that contains at most one of each of the letters A, B, and C. They may be in any order. The empty string is valid input. Note: A previous version of this challenge used the letters LEJ instead of ABC and they may still be used if desired. Output A string of the A, B, C letters that were not present in th...
stackexchange_codegolf
The challenge: compute the day of the week from a MM-DD representation of a day in this year (2021). However, you have to write your program in the following subset of Python: (I chose Python because it's popular and easy to understand even to the people who doesn't know the language. Obviously you can use another prog...
stackexchange_codegolf
Task You will be given a positive integer and you must output a "self-complementary graph" with that many nodes. If you don't know what a self-complementary graph is the wikipedia article wont help you much so below are two explanations, a technical and a non-technical one. Non-Technical A graph is a set of nodes that...
stackexchange_codegolf
I have a lot of java projects and I am often making new ones. I have a few helper classes (Vector, Logger, etc.) and it takes a lot of time correcting the first line to the correct package, I would really need a little program to help me fix it automatically. Your program will first take the name of the package the fi...
stackexchange_codegolf
...Ordinal numbers (or ordinal numerals) are words representing position or rank in a sequential order. From Wikipedia. Your task is, using 2 separate programs (of which can be made from 2 different languages), to output the ordinal sequence from first to nth. You will be outputting the full word second as opposed t...
stackexchange_codegolf
Create a program that generates a drum fill. Your program will output a pattern of L (left hand hits), 'R' (right hand hits), and K for kick drum hits. Rules The pattern must never have more than 2 of the same hits consecutively. The pattern must be loopable, so it mustn't have more than 2 of the same hits when it lo...
stackexchange_codegolf
I'd like to introduce a new? programming language I call Shue (Simplified Thue). It has very simple syntax. Here is a program that checks if an input is divisible by three: yes no 3=0 4=1 5=2 6=0 7=1 8=2 9=0 00=0 01=1 02=2 10=1 11=2 12=0 20=2 21=0 22=1 0=yes 1=no 2=no Try it online! At the top we can see two lines. Th...
stackexchange_codegolf
(The \$\mathbb{Q}\$ in the title means rational numbers.) Background Conway base 13 function is an example of a strongly Darboux function, a function that takes every real number on any open interval \$(a,b)\$. In other words, for any given real numbers \$a, b, y\$, you can find a value \$x\$ between \$a\$ and \$b\$ su...
stackexchange_codegolf
The day of the week and month of the year seem to get a lot of attention but no one seems to care about the week of the year. I believe it's time to change that, so your job is to write a program or function that when given a date outputs an integer between 1 and 53 corresponding to the current week of the year. For th...
stackexchange_codegolf
According to MDN, every WebSocket message is sent as one or more frames. Your job is to extract the payload given a (masked) client-to-server text frame. The steps to extract the payload is as follows: ignore byte 1; read byte 2 if it is 254, skip the next 2 bytes if it is 255, skip the next 8 bytes, otherwise, conti...
stackexchange_codegolf
You are given four numbers. The first three are \$a\$, \$b\$, and \$c\$ respectively, for the sequence: $$T_n=an^2+bn+c$$ You may take input of these four numbers in any way. The output should be one of two distinct outputs mentioned in your answer, one means that the fourth number is a term in the sequence (the above ...
stackexchange_codegolf
MD5 checksums are relatively easy to crack. For this challenge you will create two separate programs, the first one writing Hello, World! and the second one writing Goodbye Cruel World! but with the source code having identical MD5 hashes. The source code of both programs must not be identical. The programs can use th...
stackexchange_codegolf
Challenge You have a Chinese Checkers board looking like this: board = [ [''], ['', ''], ['', '', ''], ['', '', '', '', '', '', ''], ['', '', '', '', '', ''], ['', '', '', '', ''], ['', '', '', '', '', ''], ['', '', '', '', '', '', ''], ['', '', ''], ...
stackexchange_codegolf
Cosmic rays are bad for computers. They corrupt RAM, and that causes problems. Computer chips are shrinking, and that makes them more vulnerable to the cosmic rays. We will not give in to these high-energy particles. Turing-completeness shall live on! Task Your task is to write a Turing machine. But not just any Turing...
stackexchange_codegolf
Apparently, we really like printing the alphabet in different languages. How about the Russian Cyrillic alphabet? Print/output/return this exact text (trailing whitespace is permitted) АаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя This is the Russian Cyrillic alphabet with upper and lower case int...
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
Note This is the encryption challenge. The decryption challenge can be found here. Challenge The challenge is to encrypt a given string, using the rules as specified below. The string will only contain lowercase alphabets, digits, and/or blank spaces. Equivalent of a Character Now, firstly you would need to know how to...
stackexchange_codegolf
Task Given is a square matrix of any dimension and any integer n. Output all possible matrices(without duplicates) by removing columns and rows from the input matrix such that the determinant of these new matrices is n. Rules Output should include original if determinant of original is n. Output should be all the chopp...
stackexchange_codegolf
The task Given a folded and cut in places snowflake, "unwrap" it and output the result Input The base folded snowflake, without any cuts, looks like: |\ | \ | \ | \ | \ | \ | \ | \ |________\ And the input will always resemble this. No changed or added symbols will go out of the range of this tria...
stackexchange_codegolf
Task Your task is to write a program that will take input, and then output the lyrics to We Are Number One, changing specific words. The input will contain both the words to be changed, and the replacement word. Input The input will be in the following format: one, two\n net, villain\n (\n is a newline, it's not actua...
stackexchange_codegolf
I know there have been a lot of challenges about "the two best code-golfers in the world", but this one is a bit more unique, being Round 1 in a series of (future) challenges involving the two of them. Your task is to write a program or function that returns two different non-whitespace ASCII strings, corresponding to...
stackexchange_codegolf
Challenge Given an integer in 32-bit two's complement format, return the index of the second least-significant zero digit in the binary representation, where an index of 0 represents the least significant bit, and an index of 31 represents the most significant bit. If there is no second zero, you may return 0, any nega...
stackexchange_codegolf
What could be the shortest code for filtering the following array in Javascript without any library? My code is: filtered_obj = _.where(obj, { name: "Alpha" }); This uses a JS library called underscore. Test case: objs = [{'id':1,'name':'Alpha'},{'id':2,'name':'Beta'}, {'id':3,'name':'Gamma'},{'id':4,'name':'Eta'}, ...
stackexchange_codegolf
What general tips do you have for golfing in C++? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C++ (e.g. "remove comments" is not an answer). Please post one tip per answer. (Tips that apply to C as well can be found in Tips for golfing in C - but not...
stackexchange_codegolf
Objective Given a 2D array of any size, write a program or function to shift alternatively the columns and rows Example a b c d e f g h i j k l m n o All elements in the first column shift down one row, the second column shift up one row, the third shift down one row and so on, wrapping when they reach the edge. k g m...
stackexchange_codegolf
A triangular number is a number that is the sum of n natural numbers from 1 to n. For example 1 + 2 + 3 + 4 = 10 so 10 is a triangular number. Given a positive integer (0 < n <= 10000) as input (can be taken as an integer, or as a string), return the smallest possible triangular number that can be added to the input to...
stackexchange_codegolf
Goal You're playing a computerised chess game. The display is in black and white only and the pixels are chunky. White pixels use a lot power compared to black pixels and you're concerned about your carbon footprint. Given a square and a piece in chess notation, return the number of white pixels displayed in the squa...
stackexchange_codegolf
Iterated Function Systems An Iterated Function System (IFS) is a method of constructing self-similar fractals. Each fractal is defined recursively as the union of several copies of itself, with each copy obtained by applying a transformation function to the whole. The functions are usually affine transformations of the...
stackexchange_codegolf
Robber Thread here The Challenge Choose any numeric* formula, algorithm, or code challenge. Implement it in such a way that the math is correct, but at least one answer is wildly** wrong due to some defect in how computers/programs operate, e.g. floating point errors, uninitialized/corrupted memory, environment bugs, c...
stackexchange_codegolf
Your task today will be to take an existing file and append zeros to it until it reaches a certain size. You must write a program or function which takes the name of a file in the current directory f and a number of bytes b. While maintaining the original content of f, you must write zeroes (null bytes, not ascii 0s) ...
stackexchange_codegolf
Let's parse and process Key-Language! Given the input of a sequence of keyboard keypresses and/or special keys, write a program, function, etc. that outputs the product when all the actions are processed based on the following keyboard: +-------------------------------------------------------+ | ~ | ! | @ | # | $ | % |...
stackexchange_codegolf
Write a program or function which takes a string of text as input and outputs the number of non-alphabetical characters in it (standard I/O rules apply). A non-alphabetical character is any character not appearing in this string: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ In terms of ASCII character codes, t...
stackexchange_codegolf
Background As noted in the PPCG challenge Compress a maximal discrepancy-2 sequence – which inspired this challenge – the authors of the paper Computer-Aided Proof of Erdős Discrepancy Properties found a maximal discrepancy-2 sequence, namely -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, ...
stackexchange_codegolf
Given an integer \$N\$, print or return integers \$a\$, \$b\$, and \$c\$ that satisfy all of the following conditions, if such integers exist: \$a \times b + c = N\$ \$a\$, \$b\$, and \$c\$ are all prime \$a > b > c\$ If no valid combination of integers exist, you should return nothing, 0, None, an empty list, or rai...
stackexchange_codegolf
For example, given 3 sets of parenthesis, you have: ()()() ((())) ()(()) (())() (()()) = 5 possible combinations. Challenge Program must: • Take 1 number as an input • Return one output, the number of possible combinations of parenthesis sets Shortest number of bytes wins
stackexchange_codegolf
Barbrack Your task is to write a program or function that takes a non-negative integer (in decimal or any other convenient base for your language), and output a number in the numbering system Barbrack. What's that? Barbrack is a numbering system I made up that can represent non-negative integers. Zero is represented wi...
stackexchange_codegolf
A guess the word game The agreed dictionary. All words are 6 letters long with all letters distinct Rules: This is a game of two players and the task will be to implement Player 2. Player 1 chooses a word from the agreed dictionary Player 2 repeatedly guesses a word from the agreed dictionary. At each turn, Player 1 ...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. It's time to prepare an advent calendar, but I've only got a large sheet of rectangular paper, randomly colored red and green like this: GRRRGRRGRG GGRGGGRRGR GRRGRGRGRG GGRRGRGRGG GRGGRGRGGG RRGRGRGRRG RRRGRGRGGG RGGRGGRRRG RGGGRRRRRG...
stackexchange_codegolf
Your task is to write a program or function which takes a pure brainflak program as input (assume it contains only balanced ()[]{}<>), and output a visually mirrored copy of it. If you reversed a brainflak program as a string, say ({}()) (add one to an input), you would get ))(}{(, which is not valid. Instead, you shou...
stackexchange_codegolf
Mafia (also known as Werewolf) is a party game that plays roughly like this: The game begins on day 0. After every day n comes a night n. After every night n comes a day n+1. i.e. D0, N0, D1, N1, D2, N2... At the dawn of day 0, a host secretly chooses players to fill certain roles:   Some number of players become th...
stackexchange_codegolf
Your task is simple: given two integers \$a\$ and \$b\$, output \$\Pi[a,b]\$; that is, the product of the range between \$a\$ and \$b\$. You may take \$a\$ and \$b\$ in any reasonable format, whether that be arguments to a function, a list input, STDIN, et cetera. You may output in any reasonable format, such as a retu...
stackexchange_codegolf
Background: Jack is a pumpkin that enjoys spooking the citizens of the villages near his pumpkin patch every Halloween. However, every year after someone lights the candle inside of him, he has a limited amount of time to spook everyone before the candle burns out, thus being unable to spook any more villagers because...
stackexchange_codegolf
Background We all know about distributivity, i.e. \$a(b+c) = ab + ac\$. This is a property on 2 different operations, namely addition and multiplication. But indeed, nothing can stop us from studying distributivity of 1 operation. In this challenge, you will be studying a kind of left-distributive operation. Task Given...
stackexchange_codegolf
I tested the waters on this sort of question with python, but now I get to the real question I want to ask. restricted-source challenges are uniquely rewarding in Haskell because of Haskell's strict rule set. Type coercion which is the bread and butter for other languages in these sort of challenges is arguably non-ex...
stackexchange_codegolf
Monday, October 31st, is Halloween. And it got me thinking -- I wonder what other months have the last day of the month also be a Monday? Input A positive integer in any convenient format representing a year, 10000 > y > 0. The input can be padded with zeros (e.g., 0025 for year 25) if required. Output A list of the...
stackexchange_codegolf
The problem with the Caesar cipher is the resulting words are often unpronounceable. The problem with Pig Latin is that it is easy to decode. Why not combine them? Input A word consisting of the 26 english letters. Output First, change every consonant in the word to the next consonant in the alphabet. So, b goe...
stackexchange_codegolf
Interpret loose ranges ListSharp is an interpreted programming language that has many features, one of those features is a 1 index based range creator that works like this: You define a range as (INT) TO (INT) or just (INT) where both or the single int can go from min to max int32 value Then you can use those ranges to...
stackexchange_codegolf
Sandbox post here. Create a function or program that "Springifies" a string. Input will be a String in Stdin, or closest alternative Input will only contain printable ASCII and/or spaces Output will be to Stdout, or closest alternative A trailing newlines and spaces are acceptable How to springify a String Format th...
stackexchange_codegolf
The challenge: compute the day of the week from a MM-DD representation of a day in this year (2021). However, you have to write your program in the following subset of Python: (I chose Python because it's popular and easy to understand even to the people who doesn't know the language. Obviously you can use another prog...
stackexchange_codegolf
The following challenge is basically a simpler version of the one proposed by Dennis (Lossy ASCII art compression). I found the idea super interesting but a bit too convulted, and seeing as it didn't seem to be getting much attention I decided to modify it a little bit. You'll be downloading 5 ASCII art text files, eac...
stackexchange_codegolf
Input: A decimal Output: The input truncated How to truncate them? The integer part of the input will remain the same. The decimal part of the input will be truncated based on the lowest digit in consecutive order. The two step-by-step examples below should clarify what I mean by that: Example 1: Input: 17.46940822 Ste...
stackexchange_codegolf
Your program should take as input a number n that is greater than 0 and output a bar composed of n // 8 ▉ characters (U+2588), as well as a final character which should be one of ▉ ▊ ▋ ▌ ▍ ▎▏(U+2589 to U+258F) representing n % 8. If n % 8 is 0, your program should not output any additional characters. This is difficult...
stackexchange_codegolf
Challenge Given a positive integer, determine whether it is a triangular number, and accordingly output one of any two constant, distinct values. Definition A triangular number is a number that can be expressed as the sum of consecutive positive integers, starting at 1. They can also be expressed with the formula \$\fr...
stackexchange_codegolf
An office (let's call it "The Office") is going to cut down on wasted time in 2019 by consolidating office birthday parties. Any two people with a birthday between Monday and Friday (inclusive) of the same week will be celebrated with a Shared Birthday Party some time that week. People whose birthdays fall on a Saturda...
stackexchange_codegolf
The challenge You are given an integer n, and you have to use these operations to make it 1. Divide it by 3. Divide by 2. Subtract 1. Examples: Input Output 1 0 (Its already 1, guys) 5 3 (3->2->2 or 3->3->1) 10 3 (3->1->1) 255 10(3->3->3->1->1->2->2->3->1->2)
stackexchange_codegolf
Challenge We take three positive integers a, b, and c as input. Using these integers, first create a sequence in the range [0, c] (inclusive on both ends), in steps of b. For example, for a=4, b=2, c=100, the sequence would be [0,2,4,...,96,98,100]. For every number in this sequence which is divisible by a, replace it ...
stackexchange_codegolf
Roguelike pathfinding Your task will be, given a two-dimensional array of the elements described below, which represents a dungeon, to output or return a single number representing the amount of gold pieces the rogue can collect without waking up any monsters. The elements of the array are as follows: Empty spaces are...
stackexchange_codegolf
Write a program or function that takes in a positive integer N and recreates this pattern of circles scaled to fit an N×N pixel image: This image is a valid output example for N = 946. In case it's not clear, all the small light-blue circles have the same radius and are positioned in the four dark-blue circles in the ...
stackexchange_codegolf
The objective of this challenge is to take an array of positive integers, and enumerate its indices, grouping like elements. An enumeration without any duplicates is done by just outputting an array of pairs (value, index), for example, [3, 4, 13, 9, 2] => [[3,1],[4,2],[13,3],[9,4],[2,5]]. However, if a given element a...
stackexchange_codegolf
Awhile back I encountered a simple programming puzzle to determine whether a string was a pangram, or a perfect pangram. (Although it's worth noting that this particular challenge gave a different meaning than the standard definition of a "perfect pangram," to mean any sentence where every letter appears n times for so...
stackexchange_codegolf
Write code that takes a string as input, and outputs a truthy or falsey value depending on whether or not the string follows these rules: If you stack each character on top of each other, convert to binary and sums each column, then all the sums should be identical. You may assume the input string contains only printab...
stackexchange_codegolf
This challenge is based off of Helka Homba's question Programming a Pristine World. From that question, the definition of a pristine program is: Let's define a pristine program as a program that does not have any errors itself but will error if you modify it by removing any contiguous substring of N characters, where ...
stackexchange_codegolf
Write a function that calculates a row of the pascal triangle and returns the middle number, if there are 2 it should return their sum. Example: 5 would return 20 Example 2: 4 would return 6 EDIT: To be clear: a) if the number inputted is odd then find then return the middle number of a row on the pascal triangle. ...
stackexchange_codegolf
Adam West passed away, and I'd like to honor his memory here on PPCG, though I doubt he knew of our existence. While there are many, many different things that this man is known for, none are more prominent than his role as the original batman. I'll always remember my step-father still watching the old-school Batman an...
stackexchange_codegolf
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are n badge collectors, each has a known list ...
stackexchange_codegolf
Normally, challenges are scored in bytes, or sometimes Levenshtein distance, but for this one we're using keyboard distance -- the number of keys between the keys used to type the program (use the above keyboard as the definitive reference). For example, the distance between A and F is 3, because the path is A=>S=>D=>...
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
We have 3 dice in a square dish. The dish is 8 units wide and tall and each die is 3 units wide and tall. The dice are facing up each with a different number on their top face. 111..222 111..222 111..222 ........ ........ 333..... 333..... 333..... Then we play a game. At each step we can slide any 1 die in any card...
stackexchange_codegolf
Children are very good at classifying objects and counting them. Computers seem to have more trouble. This is a simplified version of this problem. Can you write a small program that can classify and count objects in an image? The problem: Given an image containing one or more circles and rectangles, return 2 integers ...
stackexchange_codegolf
The title is an homage of the Natural Number Game, which is a nice interactive tutorial into proving certain properties of natural numbers in Lean. The definitions used in Lv1 will be reused here. I've done some improvements: Now it starts with import tactic, which means you can freely use powerful mathlib tactics. I...
stackexchange_codegolf
Given two inputs, you should print or return whether the characters in the first string are - in order - inside the second string. For example, we want to check whether the string hello, taken as the first input, and the sample text (the second input) is abhcedddldddloallllll. This should output a truthy value, as the ...
stackexchange_codegolf
Think of a road as a number line, starting at 0 and continuing indefinitely: ................................................................. There are two cars on the road: C and R. C is the cop who is trying to catch R, the robber. C starts at 0, and R starts somewhere on the road: C.............................R.....
stackexchange_codegolf
The Cornu Spiral can be calculated using Feynman's method for path integrals of light propagation. We will approximate this integral using the following discretisation. Consider a mirror as in this image, where S is the light source and P the point where we collect light. We assume the light bounces in a straight ray f...
stackexchange_codegolf
For a given positive integer, try to find out the smallest possible rotation resulted by rotating it 0 or more bits. For example, when the given number is 177, whose binary representation is \$10110001_{(2)}\$: \$ 10110001_{(2)}=177 \$ \$ 01100011_{(2)}=99 \$ \$ 11000110_{(2)}=198 \$ \$ 10001101_{(2)}=141 \$ \$ 00011...
stackexchange_codegolf
This challenge will have give you a positive integer \$n\$ and ask you to output \$t(n)\$, the number of triangles (up to congruence) satisfying the three conditions: The triangles have perimeter of 1, the triangles have side lengths \$\displaystyle\frac{a_1}{b_1}, \frac{a_2}{b_2}\$, and \$\displaystyle\frac{a_3}{b_3}...
stackexchange_codegolf
Context: Gynvael Coldwind, a famous security researcher, published a contest in his blog post (that is now complete). The goal was similar to the one described here, but with certain restrictions depending on which of the three allowed programming languages was chosen. I found the exercise fun and wanted to extend the ...
stackexchange_codegolf
What all languages have a construct similar to python's eval, so you can write code during runtime and run it? A list would be helpful for certain programming challenges - ones where it is obvious an eval is either necessary or highly efficient.
stackexchange_codegolf
The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one. The challenge is to compute the average Levenshtein distance between two independent and uniformly random chosen binary strings of length n each. Your...
stackexchange_codegolf
We seem to never get tired of alphabet-related challenges... The recipe Given a string of letters S, and two positive integers M, N, produce an alphabet soup with the letters of S occupying random positions in a rectangular bowl of size M×N, framed by a non-alphabetic, non-space character to represent the rim of the...
stackexchange_codegolf
(This challenge exists to extend sequence A276272 in the On-Line Encyclopedia of Integer Sequences, and perhaps create a new OEIS sequence1.) This is a code-challenge, which will have you write code to compute as many terms of this sequence as possible. Background A polytet is a kind of polyform which is construct...
stackexchange_codegolf
Given an integer \$N>3\$, you have to find the minimum number of bits that need to be inverted in \$N\$ to turn it into a square number. You are only allowed to invert bits below the most significant one. Examples \$N=4\$ already is a square number (\$2^2\$), so the expected output is \$0\$. \$N=24\$ can be turned int...
stackexchange_codegolf
This task is a classic programming task: Implement a regular expression parser. That is, write a program or function which takes a string describing a regular expression and a candidate string, and test whether the complete candidate string matches the regular expression. You may assume that the regular expression pass...
stackexchange_codegolf
Input: A string (or the closest thing to that in your language) Output: The same string but converted to sentence case Rules: For this challenge, sentence case can be considered "The first letter of each sentence is capitalized. The rest are lowercase." (i.e. proper nouns do not have to be capitalized) If the input do...
stackexchange_codegolf