instruction stringlengths 34 53.1k |
|---|
What general tips do you have for golfing in Grass? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Grass (e.g. "remove no-op characters" is not an answer).
Please post one tip per answer.
|
This is perhaps one of the classical coding challenges that got some resonance in 1986, when columnist Jon Bentley asked Donald Knuth to write a program that would find k most frequent words in a file. Knuth implemented a fast solution using hash tries in an 8-pages-long program to illustrate his literate programming t... |
Jimmy has had a busy last week with all these platforms and ropes, and poor Jimmy doesn't even have legs or feet to stand on!
Your job is to take a string containing multiple Jimmys and give them legs and shoes!
Get input in the form of a Jimmy String
Jimmy String => /o\ /o\ /o\
containing only /o\ and
give each ... |
This is a Cops and Robbers challenge. This is the cop's thread. The robber's thread is here.
As a cop, you must pick any sequence from the OEIS, and write a program p that prints the first integer from that sequence. You must also find some string s. If you insert s somewhere into p, this program must print the second ... |
This is a Cops and Robbers challenge. This is the robber's thread. The cop's thread is here.
The cops will pick any sequence from the OEIS, and write a program p that prints the first integer from that sequence. They will also find some string s. If you insert s somewhere into p, this program must print the second inte... |
The task here is to write a program that takes an natural number, \$n\$, and produces the \$n\$th term of an OEIS sequence. That sequence should have an identifier in the form of A followed by 6 digits. Now when you take your source code and reverse the order of it's bytes to produce a new program, that program shoul... |
(we won't be finding a Find or catching a tryCatch, though)
This is part two of a multi-part series of implementing some interesting R functions. Part one can be found here.
The task:
You are to implement R's match function in as few bytes as possible.
Input:
x, a possibly empty list/array of integers
table, a possibl... |
In the tabletop RPG named Pathfinder, there is a feat that characters can take called Sacred Geometry, which allows a character who has it to buff their spells in exchange for doing some math: to use it, the character rolls a number of six-sided dice equal to their ranks in a particular skill, consults a table based on... |
Help! I seem to have an annoying echo in some of my arrays, and I'd like to get rid of it. When this occurs, the original array repeats itself somewhere in the middle causing the values to be added to each other.
For example, the array [ 422, 375, 527, 375, 859, 451, 754, 451 ] contains an echo of itself like so:
[ 4... |
Notice: This question originally had people write comments with a shorter program, rather than new answers. This has been changed so that people with shorter programs can get reputation too. Hopefully this doesn't become unmanageable...
There have been a couple of OEIS-related questions recently, so here's another:
Pic... |
Introduction
I began studying the Collatz Conjecture
And noticed these patterns;
0,1,2,2,3,3...A055086, and 0,1,2,0,3,1...A082375,
in the numbers that go to 1 in one odd step,
5,10,20,21,40,42...A062052
Related like so;
A062052()(n) = ( 16*2^A055086(n) - 2^A082375(n) ) /3
The formula for A055086 is $$\lfloor\sqrt{4... |
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... |
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 ... |
Rules
You will start with only two elements: Points \$A\$ and \$B\$ such that \$A \neq B\$. These points occupy a plane that is infinite in all directions.
At any step in the process you may do any of the three following actions:
Draw a line that passes through two points.
Draw a circle centered at one point such tha... |
...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... |
As you probably know, there have been multiple lovely Jimmy challenges recently popping up. In these challenges, you were challenged with our beloved friend's acrobatics skills. Now we've got a different challenge for you. Today you will be identifying different types of Jimmys!
Explanation
There are three varieties o... |
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... |
Given an input string, write a program that outputs the total number of lines and curves it has.
The Challenge
Take input from STDIN, or any other input method.
Output to STDOUT, or any other output method, the total number of lines and curves contained in the string, in that order, based on the below table in the cod... |
The idea for this code golf puzzle is from link: The Bridge and Torch Problem
The inspiration for this code golf puzzle is the Bridge and Torch
problem, in which d people at the start of a bridge must all cross it
in the least amount of time.
The catch is that at most two people can cross at once, otherwise the
... |
I'm sure you're all familiar with Z̃͗̇̚͟Ḁ̬̹̈̊̂̏̚L̜̼͊ͣ̈́̿̚G̱̮ͩ̃͑̆ͤ̂̚Õ̷͇͉̺̜̲ͩ́ͪͬͦ͐ ̪̀ͤͨ͛̍̈͢ĝ̭͇̻̊ͮ̾͂e̬̤͔̩̋ͮ̊̈ͭ̓̃n͖͎̘̭̯̳͎͒͂̏̃̾ͯe͕̖̋ͧ͑ͪ̑r̛ͩa̴͕̥̺̺̫̾ͭ͂ͥ̄ͧ͆t͍̻̘̆o͓̥ͤͫ̃̈̂r̹̤͇̰̻̯̐ͮ̈́ͦ͂͞. If not, you can play with the classical generator a bit. Zalgo text is unicode text that started as English text and had a bunch of combining ... |
Recamán's sequence (A005132) is a mathematical sequence, defined as such:
$$A(n) = \begin{cases}0 & \textrm{if } n = 0 \\
A(n-1) - n & \textrm{if } A(n-1) - n \textrm{ is positive and not already in the sequence} \\
% Seems more readable than
%A(n-1) - n & \textrm{if } A(n-1) > n \wedge \not\exists m < n: A(m) = A(n-1)... |
In the burial place of King Silo of Asturias there is an inscription that reads SILO PRINCEPS FECIT (King Silo made this).
The first letter is found in the very middle, and from there one reads by going in any non-diagonal direction radiating outward. The final letter is found on all four corners. In this challenge,... |
Modern regular expressions (regexes) have many features (\d, {n,m}, \1, etc.), but to define a regular language (modern regexes can define broader classes of languages, in their defense), all you need are three operators: concatenation (+), union (|), and the Kleene star (*). Here are some examples:
a - Matches the str... |
At work I've been acting as quality control on our public documents, to make sure that they are WCAG 2.0 compliant. Given the length of some of these documents there tend to be issues, and so I record the issues and the pages they occur on.
The challenge: Given a string input, output a count of all distinct pages with... |
/o\ Jimmy has been receiving a lot of attention on this site recently and it has caused Jimmy to get a little stressed. The bodybuilder Jimmys /-o-\ started bad mouthing the OG / acrobat /o\ Jimmys saying they are way cooler because they are bigger. But of course the acrobat Jimmys thinks they are way cooler since afte... |
The other day, our team went to an escape room. One of the puzzles involved a board of six mechanical switches where you had to find the correct combination of on and off in order to unlock a box, somewhat like this:
-v-v-v-
-v-v-v-
Being developers, we decided it would be more efficient to try every single one of 2^6... |
Like Brainfuck or JSFuck would be efficient in terms of number of characters needed, but what languages would have the highest amount of information per character?
I was thinking of APL and J but there has to be more.
My goal with this question is to find a program that would allow a person with theoretically infinite ... |
Let's define a sequence: The n digit summing sequence (n-DSS) is a sequence that starts with n. If the last number was k, then the next number is k + digit-sum(k). Here are the first few n-DSS:
1-DSS: 1, 2, 4, 8, 16, 23, 28, 38, 49, 62, 70...
2-DSS: 2, 4, 8, 16, 23, 28, 38, 49, 62, 70, 77...
3-DSS: 3, 6, 12, 15, 21, 24... |
Given a string of printable ASCII, output the frequency of each character in that string.
The Challenge
Input is given as a string of printable ASCII characters (decimal [32-126] inclusive).
Output the frequency of each character, in ASCII order.
The output must have a format similar to [character][separator][count]. ... |
Inspired by this challenge.
Goal:
Given a pre-configured switchboard and a list of indexes, invert the switches at the given indexes.
A switchboard is made up of some number of switches (v or ^) wrapped in -'s and arranged into rows of varying length. Here is an example switchboard:
-v-^-v-
-^-v-
-v-^-v-
To invert/fli... |
Inputs:
current hour: from 0 to 23 (inclusive)
delta of hours: [current hour] + [delta of hours] = withing the range of Integer
Output:
delta of days: the value which shows difference in days between day of current hour and day of sum [current hour] + [delta of hours]
Scoring
Answers will be scored in bytes with ... |
Given a two dimensional matrix of 0 and 1s. Find the number of island for 1s and 0s where neighbours are only in the horizontal and vertical.
Given input:
1 1 1 0
1 1 1 0
output = 1 1
Number of 1s island = 1
xxx-
xxx-
Number of 0s island = 1
---x
---x
------------------------------
Given input:
0 0 0 0
1 1 1 ... |
Let us say that we have a particular set of functions on strings. These functions are kind of like fill in the blanks or madlibs, except that they only take one input and use that to fill in all of their blanks. For example we might have a function that looks like
I went to the ____ store and bought ____ today.
If w... |
There is a rectangular 2D array containing viruses denoted by 'v', antidote1 denoted by 'a', and antidote2 denoted by 'b' (there are no values other than 'v', 'a' and 'b').
Antidote1 can kill neighboring viruses in horizontal and vertical directions only, but antidote2 can kill neighboring(if any) viruses in horizontal... |
Given an addition pyramid \$P\$, determine whether it can be solved. An addition pyramid consists of layers, each having one number less than the one below it. Layer \$i\$ is symbolized as \$P_i\$. \$P_1\$ is the base layer, and \$P_{i+1}\$ is the layer atop \$P_i\$. The \$j\$th number of \$P_i\$ is denoted as \$P_{i,j... |
It's simple, simply write the shortest code to raise a TypeError.
In Python you can do:
raise TypeError
However it should be shorter with a code that gives a TypeError without raising it.
|
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... |
Super simple challenge today, or is it?
I feel like we've heard a fair bit about double speak recently, well let's define it in a codable way...
Double speak is when each and every character in a string of text is immediately repeated. For example:
"DDoouubbllee ssppeeaakk!!"
The Rules
Write code which accepts one ... |
This challenge has ended. To see the final scores of the competitors, click here
In this challenge, each submission is one bot. Each bot should be a Javascript function. Bots will fight to obtain the highest total worth in gold. Gold can be farmed, or earned from killing other bots, and is used to upgrade healing, at... |
Introduction
Formula One is a complex sport and as with complex sports, strategy is very important.Some teams will manage better strategy than others and those teams will often win the races.
After last weekends' amazing German GP, which saw last years Champion Lewis Hamilton pit 6 times (in comparison, some races just... |
Challenge
I think everyone of us heard of URL encoding mechanism - it's basically everywhere.
Given an URLEncoded string on stdin, decode it, and output the decoded form to stdout.
The encoding is very simple, + or %20 is representing space. Every percent followed by two hex digits (uppercase or lowercase) has to be re... |
Create a quine that cannot be golfed. Your score is your byte count, where higher is better. If someone finds a shorter version, their score is your original byte count, and you lose points
Scoring example:
original submission, 34 bytes // score is 34
function(this){self.printquine();}
golfed, 31 bytes ... |
Write a regex that only matches valid country code top level domains (ccTLDs). Your regex must match both the domains with the dot and without the dot (it must match tv and .tv). Any domain that is not a ccTLD or does not exist (e.g. .info or .jobs or .xz) must not be matched.
Use Perl, POSIX, PCRE or Python.
For refer... |
A grid-filling meander is a closed path that visits every cell of a square \$N \times N\$ grid at least once, never crossing any edge between adjacent cells more than once and never crossing itself. For example:
Once filled, each cell of the grid can be represented by one of the following 8 tiles:
Numbered this way, ... |
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 ... |
Not to be confused with Find the factorial!
Introduction
The factorial of an integer n can be calculated by
$$n!=n\times(n-1)\times(n-2)\times(...)\times2\times1$$
This is relatively easy and nothing new. However, factorials can be extended to double factorials, such that
$$n!!=n\times(n-2)\times(n-4)\times(...)\times4... |
Given a black and white image with a white background and a set of black dots, paint a set of white pixels red, such that there is a path between each pair of black pixels.
Details
A path is a set of connected pixels (8-neighbourhood connectivity). Black pixels can be used as part of the paths. The goal is trying to ... |
(Inspired by the first problem solved in Stanford’s advanced data structures course.)
Despite the academicese-heavy name, the problem we're going to solve is almost unbearably simple.
We have a list of numbers.
[31, 41, 59, 26, 53, 58, 97]
We're going to cut some contiguous snippet out of that list of numbers.
[31, 41... |
For each node in a balanced binary tree, the maximum difference in the heights of the left child subtree and the right child subtree are at most 1.
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
... |
Task:
Consider the problem: "given a chessboard with one square missing, cut it into 21 L-triominoes". There is a well-known constructive proof that this can be done for any square chessboard size that is a power of two. It works by splitting the chessboard into a smaller chessboard with the hole in it and one big trio... |
Introduction
Given this visualization of a playing field:
(0,0)
+----------------------+(map_width, 0)
| A |
|-----+-----------+----|
| D | W | B |
|-----+-----------+----|
| C |
+----------------------+(map_width, map_height)
(0, map_height)
The entire map the game is ... |
In an earlier challenge I asked code golfers to produce strings which copy each character in a string. For example:
TThhiiss iiss ddoouubbllee ssppeeaakk!!
This challenge is simply to detect if some text meets the definition of a double speak string.
There is an even number of characters.
When split into pairs, ev... |
Introduction:
Beckett Grading Service (aka BGS), is a company which encapusulates and grades Trading Card Game (TCG) cards (i.e. sport cards, Magic The Gathering, Pokémon, Yu-Gi-Oh, etc. etc.). The TCG cards that come in for grading will be checked on four categories (which we will later refer to as subgrades): centeri... |
A variable-length quantity (also referred to as VLQ or uintvar) is a way to encode up to a 28 bit integer value using only as many bytes as necessary. This was used in MIDI file format as a way to minimize the size of certain event data.
The way it works is fairly simple. As a big-endian series of bytes, the most sign... |
Note: This is the radiation-hardening version of my previous challenge Pristine Bit Checking. This should be much more difficult than that one.
Write a program/function that takes two integers in the range \$0\$ to \$255\$ inclusive, and returns whether the binary forms of the numbers are exactly one bit different.
Fo... |
This puzzle is based on this Math.SE post. A more complex version of this problem can be found over here.
Assume I have some number of black shirts and some number of white shirts, both at least 1. Both colors of shirt have a non-zero durability. All shirts of a given color start with the same durability.
Every day, I ... |
This is a more complicated version of this puzzle. The premise is the same but a few rules differ in a few key places, making for a more complex problem.
Assume I have some number of black shirts and some number of white shirts, both at least 1. Both colors of shirt have a non-zero durability. All shirts of a given col... |
We've all done it, well, maybe not, but making your own alien language and numbering system is a staple of especially fantasy writing, but is mostly just a fun activity.
The task is simple, take two inputs:
An ordered list input of 10 [ten] unique 'numerals' (any printable
ASCII character) and interpret them, in order... |
This challenge is based on a video in which Andrew Huang discusses unusual time signatures...
https://www.youtube.com/watch?v=JQk-1IXRfew
In it, he advises that you can understand time signatures by dividing them into 3's and 2's. So you count to a small number a few times, instead of counting to a large number.
Here's... |
Create a function that takes in a generator function as its only parameter, and returns an object that can be used as both as a generator and a generator function for said generator. The idea is to be able to create an object that behaves like a generator (that is, it follows the iteration protocols) but also has the a... |
Determining whether a Turing machine halts is well known to be undecidable, but that's not necessarily true for simpler machines.
A Foo machine is a machine with a finite tape, where each cell on the tape has an integer or the halt symbol h, e.g.
2 h 1 -1
The instruction pointer starts by pointing to the first cell:
2 ... |
This is my first attempt at a Code Golf question. If it needs obvious edits, please feel free to make them.
Below is a description of the basic Dropsort algorithm.
Dropsort is run on a list of numbers by examining the numbers in sequence, beginning with the second number in the list. If the number being examined is l... |
The task is simple. Write an interpreter for the language *.
Here's a bigger link to the wiki.
There are only three valid * programs:
* Prints "Hello World"
* Prints a random number between 0 and 2,147,483,647
*+* Runs forever.
The third case must be an infinite loop according to the specifications in this question... |
Create a program that interprets the programming language Bucket.
Bucket works on two buckets: the first can hold A and the second can hold B units of liquid. The things you can do with these buckets are:
f: fill bucket A
F: fill bucket B
e: empty bucket A
E: empty bucket B
p: pour units of liquid from A to B until one... |
It's August 10th, 2019, but your task still involves Y2K. Weird, right?
Create a program that prints itself, with a two digit number appended to it. The first time you run it, it should append 00 to its output (its source code, because this is a quine variant). When you run that output, the original program without a t... |
At 1998, Brian Kernighan, while working on the book "The Practice of Programming", wanted to demonstrate realisation of regular expression engine. But struggled to find small engine, that cod could fit in the book.
So Brian Kernighan asked Rob Pike to write one for him, and Rob did it gracefully. Here is original sourc... |
Write a program that, for the numbers 1 through 255, prints out BF code that will produce the given number in some byte of the array, plus a newline.
For example, the first four lines of the output could (and most likely will) be:
+
++
+++
++++
The winner will be the smallest: source code + output (in bytes).
Clarific... |
Create a cat program, a.k.a a program that takes an input and prints it.
...Except, the program will randomly take characters away from your input and print that instead.
Each character in the input should have generally equal odds to be removed with the program, though, as it is hard to make that, the odds for each ch... |
Write a program that prints an associative array (key-value) to a table.
Requirements
Standard loopholes are forbidden
Please include a link to an online interpreter and the byte count in the answer
Use box drawing characters to draw the table.
You can write both a full program or a function.
Key or value can't cont... |
Inspired by Is it double speak?, I devised a harder challenge. Given a string, determine if the string is n-speak, for any \$n\geq 2\$.
N-speak is defined by repeating each letter \$n\$ times. With \$n = 4\$, the string Hello is transformed to HHHHeeeelllllllloooo. Your goal is to figure out if the input is a valid out... |
How, you can’t remember the 6 or 7-digit phone number that appeared on the TV screen for a second?! Using the special technique described below, you will turn into a walking phonebook!
Obviously, the number 402 is easier to remember than the number 110010010, and the number 337377 is easier to remember than the number ... |
Crossing Sequences
Given a list of positive integers A, call it an increasing sequence if each element is greater than or equal to the previous one; and call it a decreasing sequence if each element is less than or equal to the previous one.
Some increasing sequences:
[1,2,4,7]
[3,4,4,5]
[2,2,2]
[]
Some decreasing seq... |
Goal
Write a program or function that translates a numerical telephone number into text that makes it easy to say. When digits are repeated, they should be read as "double n" or "triple n".
Requirements
Input
A string of digits.
Assume all characters are digits from 0 to 9.
Assume the string contains at least one cha... |
"A picture is worth a thousand words"—so the old saying goes. The average word is about four characters long, so a picture conveys 4kB of information. But how much entropy, rather than information, can a picture convey?
Your task is to generate an image, exactly 4,000 bytes in size, with the highest entropy possible. Y... |
Língua do Pê, or P Language, is a language game spoken in Brazil and Portugal with Portuguese. It is also known in other languages, such as Dutch and Afrikaans. (Wikipedia)
There are some dialects in this language game. The different languages the game is played with even have their own unique dialects. Some people are... |
I have a list of decimal digits:
4, 4, 4, 7, 7, 9, 9, 9, 9, 2, 2, 2, 4, 4
The list of decimal digits are known as items. We can form "chunks" from these items by grouping together identical and adjacent numbers. I want to assign each chunk a unique number, starting from 1, and increasing by 1 in the order the chunks ap... |
Here is a relatively simple two dimensional array challenge.
Imagine a battlefield of 625 foot soldiers. You command the odd troops, but unfortunately the strength of the even troops overwhelms you. Thankfully, your soldiers have a secret power: If the power of each odd troop and the fellow odd allies surrounding them ... |
Instead of being a skillful warrior capable of slaying Hydras (see here and here), this time you are a warrior that has no prior knowledge on how to kill one or which weapons to use against the creature.
In this problem, whenever you cut a single head off, two will grow in the same place. Since you don't have the mech... |
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... |
A sentence of number theory (for our purposes) is a sequence of the following symbols:
0 and ' (successor) - successor means +1, so 0'''' = 0 + 1 + 1 + 1 + 1 = 4
+ (addition) and * (multiplication)
= (equal to)
( and ) (parentheses)
the logical operator nand (a nand b is not (a and b))
forall (the universal quant... |
You are given two integers between lets say 1 and 12, one and two
and a integer between lets say 0 and 4 which is called range. The challange is to decide if one is inside or equal the range from two ± range. The range is restarting with 1 after 12 and vise versa.
For example, if one = 2, two = 11 and range = 3, t... |
Any two separate nodes in a binary tree have a common ancestor, which is the root of a binary tree. The lowest common ancestor(LCA) is thus defined as the node that is furthest from the root and that is the ancestor of the two nodes.
The following are binary trees and the lowest common ancestors of the some of their n... |
Your task is to remove smallest amount elements from a list, so the most elements are on their corresponding place. The element is on it's corresponding place, when it's value is equal to it's position.
Let's look at this example list:
1 5 3 2 5
This list has three elements on their corresponding place (1 on position ... |
I was going through a bizarre thread on Reddit, and came across this:
( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°) ͡°)
It's representing a group of people smiling somewhat suspiciously.
(In the challenge below though, spaces to the left of the right eyes were dropped somehow while I was writing the challenge. Note the spec).
Your goa... |
A theorem in this paper1 states that every integral n-by-n matrix M over the integers with trace M = 0 is a commutator, that means there are two integral matrices A,B of the same size as M such that M = AB - BA.
Challenge
Given an integral matrix M with trace M = 0 find some integral matrices A,B such that M = AB - BA.... |
With challenges like Output with the same length as the code and Create output twice the length of the code, I thought of a separate, but similar challenge.
The task is to produce an output. It can either be a string, a list of characters, or whatever is the default output format of your program. However, your output ... |
There's a minigame in Super Mario 3D World known as the Lucky House. It consists of a slot machine with 4 blocks.
Each block may be one of 5 different icons (Flower, Leaf, Bell, Cherry or Boomerang) and the goal of the player is to get as many identical icons as possible (see a video).
The player is rewarded with coin... |
Most square numbers have at least 1 different square number with which their Levenshtein distance is exactly 1. For a given square \$x\$, each square that meets this condition is called a Levenshtein neighbour of \$x\$. For example, \$36\$ is a Levenshtein neighbour of \$16\$, as only 1 edit (\$1 \to 3\$) is required. ... |
Posted from here.
This challenge is highly "distilled" from this question. Special thanks to @Akababa!
In this task, you should insert an exclamation mark at the start of the string and after every character.
Rules
There will always be a non-empty-string input. The input will not contain tabs either. You can assume th... |
Background
Joe is working on his new Brainfuck answer on Codegolf. The algorithm he's using to solve the challenge is a bit complicated, so Joe came up with idea of simplifying his Brainfuck notation to make programming easier and faster.
The challenge
Let's look at snippet written by Joe a moment ago:
0+++++1+++++0[3+... |
The task is to write a radiation-hardened irradiator. What do I mean by that, exactly?
An irradiator is a program that, when given a string as input, will output all possible versions of the string with one character removed. For example, given the input Hello, world!, the program should output:
ello, world!
Hllo, worl... |
You’re given two \$r×c\$ grids. Each cell contains either 0 or 1. What are the minimum number of swaps (between horizontally and vertically adjacent cell elements, no wrapping i.e no swapping between last and first element of a row) are required in the first grid for it to match the second. If the matched arrangement c... |
Write a function or program that takes two words as input and outputs variants of the popular English tongue-twister "How much wood would a woodchuck chuck if a woodchuck could chuck wood?".
The output will use the first word four times
How much wood would a woodchuck chuck if a woodchuck could chuck wood?
and the se... |
Church booleans
A Church boolean is a function that returns x for true and y for false where x is the first argument to the function and y is the second argument to the function. Further functions can be composed from these functions which represent the and not or xor and implies logical operations.
Challenge
Construct... |
The Typical Way to Make an Acronym Out of a Phrase Is to Take the First Letter of Each Word: TTWMAOPITFLEW. howeveR, sometimEs, you can make an acronym of random leTters In a seNtence such As like this: RETINA. The only condition is that the letters have to be in the correct order. For instance:
LORD can be acronymise... |
The challenge
Given two strings, each of length up to 30, consisting of printable ASCII characters (codes \$[32, 126]\$), put them onto a balance scale in the fewest bytes of code! This consists of the following steps:
Calculate and compare the weights of the strings
Choose the appropriately tilted ASCII-art scale
Pla... |
let S, a and b each represent a string
Goal: Write a standard string replace function where the you replace all occurrences of a in a string S with b so long as a is not already part of an instance of b
for example, if we have the string S = My oh my that there is a big ol' that
and we wanted to do a fancy replace with... |
Given a strictly positive integer n, follow these steps:
Create an array A with n 1s.
If A only has one element, terminate. Otherwise, starting from the first element, replace each pair of A with its sum, leaving the last element as is if A's length is odd, and repeat this step.
The output should contain A's state af... |
Challenge
Write a program that takes as input a day from April 30, 1789 to August 21, 2019 and returns as output who was president of the USA that day.
Notes
For the list of US presidents, the format of their names, and the period of their presidency, see below:
April 30, 1789 - March 4, 1797 George Washington... |
Introduction
Recently, me and a couple of my friends decided to play some cards, and one of them suggested the game 'Irish Snap', which was the inspiration for this challenge. However, I later learnt that the game has a lot of different rules that you can play with, some of which are listed here. The rules that are in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.