instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Problem
You're a staircase engineer on a house and realize you only have n rectangles to create a staircase. So you are tasked with finding the number of ways to use n rectangles to tile a stairstep shape for the architects.
Your task is to write a program that takes a non-negative integer n as input and calculates the... | stackexchange_codegolf |
This is going to be relatively challenging code-golf challenge.
Input: Any URL, must have the protocol attached, e.g. http://codegolf.stackexchange.com (which will be our test case)
Output: A generated QR Code that represents this URL, which, when scanned by a smart device will take you to that URL on the smart device'... | stackexchange_codegolf |
Inspired by a tweet by Nathan W. Pyle
There is, now, a standard method of converting your boring, normal human name into a mysterious, ethereal Ghost Name™️. Ably described by Mr Pyle...
Use your first name:
a - add “t” after it
e - add “boo” after it
h - becomes “s”
n - add “oo” after it
r - add “eee” after it... | 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 |
Given an integer between 0 and 141 (inclusive), list all 24-hour times whose hour, minute, and second units add to that integer.
Rules of addition
Numbers are added by their time units, not by single digits.
For example, take 17:43:59
17+43+59=119
Remember, that is an example of digits being added. In reality, you wou... | stackexchange_codegolf |
Given a string input, your task is to write a program that prints a truthy value to STDOUT or equivalent if the input contains "2016" anywhere in it without using any built-in contains, match, replace, split or other functions that use patterns or regexes.
A truthy value also must be printed if the input contains "2016... | stackexchange_codegolf |
For this challenge, a slice of a string is defined as an upper and lower index that can "cut" a piece of a string. All characters from the string in the range [start, end) (or [start, end] if you don't speak practlang) are part of that slice. If the upper index exceeds the string's length, the overflow is ignored. For ... | stackexchange_codegolf |
Here is Minkowski's question mark function:
It is a strictly increasing and continuous function from the reals to themselves that, among other unusual properties, maps rational numbers to dyadic rationals (those with a power-of-two denominator). Specifically, suppose the continued fraction representation of a rational... | stackexchange_codegolf |
Our classic snake has developed an inbalance of growth hormones. To make matters worse, his tail is frozen in place! Given directional input as specified in Figure 1, write a program to determine where he will grow.
Figure 1. Directional input.
Program specifications
Read the input character by character on STDIN.
Af... | stackexchange_codegolf |
I'm surprised this hasn't come up in a challenge yet.
Output the IP address of the machine you're running on. You are required to output both the local and external IP addresses.
Local IP address, ie along the default format of 192.168.x.x
Public IP address can be verified by using google https://www.google.co.uk/searc... | stackexchange_codegolf |
The Premise:
You are writing a C driver for a screen for use on an embedded system. The screen uses a tortured version of SPI that requires data to be sent LSb (least-significant-bit) first, but MSB (most-significant-byte) first.
A fast way to do this (if you have the memory) is to use the integer value of each byte to... | stackexchange_codegolf |
Background
Lambda calculus is a model of computation using lambda terms.
A variable \$x\$ is a lambda term.
If \$E\$ is a lambda term, the lambda abstraction \$\lambda x. E\$ is a lambda term.
If \$E_1, E_2\$ are lambda terms, the lambda application \$E_1 E_2\$ is a lambda term.
The rule of computation is called \$\b... | stackexchange_codegolf |
Pipe a short stream to the following Java program run with accompanying command line options, such that it prints true.
class Code implements java.io.Serializable {
private static final long serialVersionUID = 0L;
private static long count;
@Override public int hashCode() {
++count;
return... | stackexchange_codegolf |
Some numbers like 64 can be expressed as a whole-number power in multiple ways:
64 ^ 1
8 ^ 2
4 ^ 3
2 ^ 6
Output a sorted array of all possible such powers (here, [1,2,3,6]) in as few bytes as possible.
Input
A positive whole number that's greater than 1 and less than 10000.
Output
An array of whole-number powers... | stackexchange_codegolf |
A pristine program is a program that does not have any errors itself but will error if you modify it by removing any contiguous substring other than the entire program.
A crystalline program is sort of the opposite. It is a program which doesn't have any errors itself but will error if you modify it by adding any 1 cha... | stackexchange_codegolf |
This challenge is one of the two challenges which were planned for Advent of Code Golf 2021, but didn't fit into the 25-day schedule.
Related to AoC2020 Day 22, Part 2.
Combat is a simple two-player card game played with a deck of cards. A unique positive integer is written on each card. The game proceeds as follows:
... | stackexchange_codegolf |
This is a rock:
*
Rocks can be stacked. Apart from the bottom-most layer, each rock must rest on two other rocks, like this:
*
* *
You have a pile of rocks, and your boss wants you to pile them symmetrically, taking up the least horizontal space possible.
Your challenge is to take a number of rocks as input, and out... | stackexchange_codegolf |
The challenge is to detect missing integer sequences of files or directories. You have a directory filled with files/directories that are named as integers.
The files/directories are generated from multiple threads yet the job did not complete - there are therefore gaps in the sequence.
The input is two integers a sta... | stackexchange_codegolf |
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... | stackexchange_codegolf |
The challenge
Write a function that returns the nth element of an array even if its out of bound.
function safeGet(index, arr) {
const safeIndex = ???
return arr[safeIndex]
}
const arr = ["a", "b", "c"];
safeGet(0, arr) // "a"
safeGet(1, arr) // "b"
safeGet(2, arr) // "c"
safeGet(3, arr) // "a" go back to the be... | stackexchange_codegolf |
The game shapez.io has a lot of shapes. In my previous challenge, the object was to generate a random code for a shape. Now, your challenge is to render a shape.
Specs
Shapes
Each shape has a unique shortcode, for example:
is CrWgRuSp - clockwise from top right, red circle, green wedge, uncolored rectangle, purple sta... | stackexchange_codegolf |
SE will be down/read only today 2017-05-04 at 00:00 UTC until 00:20 UTC.
Your challenge is to output a truthy value if SE is down/read only and a falsy value if SE is not. You may not have any input, and you must use date builtins to determine if SE is down/read only (no actually querying the SE api!) Example output:
1... | stackexchange_codegolf |
A followup to this challenge by Jeremy Collprav, inspired by DLosc solving this in Regenerate. Some sections copied from the linked challenge.
Linking chains
We define a chain to be a string containing exactly one or more of only the - character, or 1 or more of only the _ character, or two chains linked by a =. More f... | stackexchange_codegolf |
Write a program that outputs as many characters as possible, with two conditions:
The program must be 256 bytes or shorter
The program must almost surely eventually halt. In other words, the only thing not permitted in response to this question is an infinite loop.
For the purposes of this problem, any built-in psudo... | stackexchange_codegolf |
Suppose you have a grid of cells that is 6 wide and arbitrarily tall. In each cell is a word. Let the bottom row, which is row #1, be the last 6 words of sample.txt in order. Let the second to last row, which is row #2, be the 6 words before those in order. (etc.)
Then consider what happens when you remove some of the ... | 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. Given a binary string \$S\$ of length \$n\$, we are a interested in the number of different strings of length \$n\$ which have distance at most \$3\$ ... | stackexchange_codegolf |
Your challenge, should you choose to accept it, is simple:
Implement RFC 862, also known as the Echo Protocol:
The Echo protocol
An echo service simply sends back to the originating source any data it receives.
TCP Based Echo Service
One echo service is defined as a connection based application on TCP. A server listens... | stackexchange_codegolf |
Last month I borrowed a plenty of books from the library. They all were good books, packed with emotions and plot-twists. Unfortunately, at some points I got very angry/sad/disappointed, so I tore some pages out.
Now the library wants to know how many pages I have torn out for each book.
Your goal is to write a program... | stackexchange_codegolf |
Intro
Blur's song Girls & Boys featured the lines
girls who are boys who like boys to be girls
who do boys like they're girls, who do girls like they're boys
in the chorus. These lines have a pretty uniform structure: you have a subject, which is either girls or boys, a relative clause, either who are, who like, or wh... | stackexchange_codegolf |
This question is similar to Do the circles overlap?, except your program should return True if the circumference of one circle intersects the other, and false if they do not. If they touch, this is considered an intersection. Note that concentric circles only intersect when both radii are equal
Input is two x, y coordi... | stackexchange_codegolf |
Presented in honor of APL as an interactive tool turning 50 this year
Background
Ken [Iverson] presented his paper Formalism in Programming Languages in August 1963 at a Working Conference on Mechanical Language Structures, Princeton, N.J. The list of conferees is full of famous and soon-to-be famous names, and a few ... | stackexchange_codegolf |
Covalent bonding uses so-called "hybrid" orbitals to form tetrahedral, octahedral, etc. formations out of the s, p, and sometimes d orbitals. Their naming conventions are pretty much the concatenation of the component orbitals; for example, the hybridization of the s orbital and one p orbital would be the two sp orbita... | stackexchange_codegolf |
Consider a NxN pixel grid with up to M objects drawn on it, either squares or diamonds:
square
diamond
The objects may overlap, so recognition is hard. The task is to give the minimal possible numbers of objects per shape that can be "seen" in the picture and tell how many squares, how many diamonds, and how many ob... | stackexchange_codegolf |
Tic-Tac-Latin!
This is a true story, so names have been altered.
My latin teacher, Mr. Latin, created his own proprietary (no joke) tic tac toe variant. Let's call it tic-tac-latin. The game is simple, it is essentially tic tac toe played on a four by four grid.
Formal rule declaration
A line is either a row, column o... | stackexchange_codegolf |
A drug comes in 5mg, 2.5mg, and 1mg sized pills. The drug is taken once a day. The total daily dose will be only one of the following (all in mg):
1, 2, 3, ... 20, 22.5, 25, 27.5, 30, 32.5, 35, 37.5, 40, 42.5, 45, 47.5, 50
In words: any whole number less or equal to 20, then at 2.5mg increments up to 50.
Your task is t... | stackexchange_codegolf |
A magic square is an \$ n \times n \$ square grid, such that the sum of the integers on each row and column are equal. Note that the definition which will be used in this challenge is different than the one used by Wikipedia, since
diagonal sums are not accounted for
the numbers are not required to be distinct or in t... | stackexchange_codegolf |
Pipe a short stream to the following Java program run with accompanying command line options, such that it prints true.
class Code implements java.io.Serializable {
private static final long serialVersionUID = 0L;
private static long count;
@Override public int hashCode() {
++count;
return... | stackexchange_codegolf |
Goal
Given a deal result from Duplicate Contract Bridge, calculate the deal score.
Basically the same as iBug's question, which was deleted. I figured out this scoring system while trying to answer that question.
Input
Input is a deal result, and whether or not the declaring side is vulnerable.
The deal result is a str... | stackexchange_codegolf |
pylint has no lower bound on the scores it will give your code. It uses the following metric to score code, with the maximum score being 10:
10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
With python 3.6, try and write a program that:
Outputs "Hello World" when run from the command lin... | stackexchange_codegolf |
Saw this in a PHP challenge. The objective is to make a chessboard with 64 squares (8*8) with the minimum amount of code.
Simple enough, I made mine in PHP in 356 bytes (not impressive, I know) and I would like to see some other aproaches.
This can be made in a language of your choice, as long as you keep it vanilla, s... | stackexchange_codegolf |
A Shift matrix is a binary matrix with one superdiagonal or subdiagonal formed by only ones, everything else is a zero.
A superdiagonal/subdiagonal is a diagonal parallel to the main diagonal, which is not the main diagonal, i.e. all entries \$a_{ij}\$ where \$i=j+k\$ and \$k \neq 0\$.
The main diagonal is defined to b... | stackexchange_codegolf |
You are given two strings, each consisting of the English word for a number between 1 and 13:
one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen
Your program or function must find out whether it's possible to spell at least one other word from the same list without using any of the let... | stackexchange_codegolf |
Inspired by this comment chain...
I wanna enklact my way out of this challenge but I can't...
@ETHproductions to enklact (v): to implement a lookup table using a subsection consisting of unique elements.
Enklacting is a very useful way to compress a lookup table. For example, let's say you had the following list of ... | stackexchange_codegolf |
There have already been challenges about computing the exponential of a matrix , as well as computing the natural logarithm
of a number. This challenge is about finding the (natural) logarithm of matrix.
You task is to write a program of function that takes an invertible \$n \times n\$ matrix \$A\$ as input and returns... | stackexchange_codegolf |
In prefix notation, the operator comes before the arguments, so you can kind of imagine that the operator calls next() which is recursively called. In infix notation, the operator goes between the arguments, so you can imagine it simply as a parse tree. In postfix notation, the operator comes after the arguments, so yo... | stackexchange_codegolf |
As many of you will know, almost every programming language has a standard casing system; unfortunately, we have not been able to agree on a singular system to use and now must frequently switch between camelCase, snake_case, PascalCase and kebab-case.
Now I know what you're thinking... wouldn't it be nice if we had a ... | stackexchange_codegolf |
Given a unix timestamp as an input, give a datetime string, in a format like so: "YYMMDD.HHmm"
Rules
The input is a number (integer) of a millisecond-precise UNIX epoch time (milliseconds since 1970 January 1st 00:00:00.000 UTC).
The values must be padded with zeroes if they are 1 character instead of 2. (e.g.: for "D... | stackexchange_codegolf |
Goal
Write a full program that generates a map showing the local train stations and which train station is the closest to every point on the map.
Requirements
Input
A set of tuples. The first is the (Width,Height) dimensions of the map. The following tuples are the (X,Y) coordinates of each train station. Coordinate... | stackexchange_codegolf |
Challenge
You have a Chinese Checkers board looking like this:
board = [
[''],
['', ''],
['', '', ''],
['', '', '', '', '', '', ''],
['', '', '', '', '', ''],
['', '', '', '', ''],
['', '', '', '', '', ''],
['', '', '', '', '', '', ''],
['', '', ''],
... | stackexchange_codegolf |
Write a program that has at least one byte that, when run, does absolutely nothing.
I thought this would be done by now, but I can't find any other challenges like this.
How to tell if it does nothing:
No variables are declared
Nothing is returned
Input does nothing
You could run a program after it and it would run no... | stackexchange_codegolf |
N children, with no two sharing their exact size, are lined up in some order. Each can only compare heights with their immediate neighbours. When the teacher shouts "raise hands if you are the tallest", they do so if they are taller than both their neighbours, and they do so simultaneously. If only one raises their han... | stackexchange_codegolf |
Given two non-zero 16-bit integers a and b, decide the smallest number of shift operations needed to turn a into b. A shift is one of the following (big-endian) operations:
shl (shift left): move all bits to the left, adding a 0x0 bit to the right.
shr (shift right): move all bytes to the right, adding a 0x0 bit to th... | stackexchange_codegolf |
In elementary school, children learn about proper fractions, where the numerator is less than the denominator, and thus the value of the fraction is less than one. Later, they are taught about fractions where the value of the fraction is greater than one, and two different ways to express these fractions: mixed fractio... | stackexchange_codegolf |
You have a little robot with four distance sensors. It knows the layout of a room, but it has no sense of orientation other than being able to lock onto the grid orientation. You want to be able to find out where the robot is based on the readings, but it can be ambiguous because of the limited sensors.
Challenge Expla... | stackexchange_codegolf |
Challenge
Given a string of any length which contains only digits from 0 to 9, replace each consecutive run of the digit 0 with its length.
Test Cases
1234500362000440 → 1234523623441
123450036200044 → 123452362344
000000000000 → 12
0123456789 → 1123456789
1234567890 → 1234567891
123456789 → 123456789
010203004050 → 1... | stackexchange_codegolf |
Guidelines
Scenario
John has an important number, and he doesn't want others to see it.
He decided to encrypt the number, using the following steps:
His number is always a non-decreasing sequence (ie. "1123")
He converted each digit into English words. (ie. "123" -> "ONETWOTHREE")
And then, rearrange the letters random... | stackexchange_codegolf |
Inspired by a question (now closed) at Stack Overflow.
Given a square matrix, let its double trace be defined as the sum of the entries from its main diagonal and its anti-diagonal. These are marked with X in the following examples:
X · · X
· X X ·
· X X ·
X · · X
X · · · X
· X · X ·
· · X · ·
· X · X ·
X · · · X
No... | stackexchange_codegolf |
Oh no! There are a bunch of meteoroids on my way through the universe ... what am I and my space ship, the SP4C3, supposed to do?
I need to manoeuver my shuttle through these rocks or I am done for!
Your Task
Write a program that guides my shuttle through a map of asteroids, using as few bytes as possible since I don't... | stackexchange_codegolf |
Giuga numbers (A007850) are composite numbers \$n\$ such that, for each prime factor \$p_i\$ of \$n\$, \$p_i \mid \left( \frac n {p_i} -1 \right)\$. That is, that for each prime factor \$p_i\$, you can divide \$n\$ by the factor, decrement it and the result is divisible by \$p_i\$
For example, \$n = 30\$ is a Giuga num... | stackexchange_codegolf |
This is a really neat short challenge.
Write a function or a procedure that takes two parameters, x and y and returns the result of xy WITHOUT using loops, or built in power functions.
The winner is the most creative solution, and will be chosen based on the highest number of votes after 3 days.
| stackexchange_codegolf |
Task
Haskell's and Scala's standard libraries have an unfold function that builds a list from an initial state s and a function f. This is done with the following steps (explained in an imperative way to be simpler):
Apply f to s.
If the result
is empty, we're done building the list!
Otherwise, the result should cont... | stackexchange_codegolf |
This is my 12th question, so I thought of this idea.
Goal:
Output 12, with any preceding or trailing whitespace permitted
In as many languages as possible (where different versions or flags count as the same language)
Without using any numbers
The criteria for a valid programming language are the same as those of The ... | stackexchange_codegolf |
Alphabet Rain
The Task:
The basic premise is to print out the input string and then repeat each character vertically, based on it's (0-indexed) position in the (case-insensitive) alphabet A-Z. A is at location 0 so is not repeated, e is at position 4 so is repeated 4 times, P is at position 15 so is repeated 15 times, ... | stackexchange_codegolf |
Inspired by the problem with the same name on Puzzling SE by our very own Dmitry Kamenetsky.
You are to find the largest number that only uses every digit pair once, in a given base. For example, in ternary we have 2212011002.
Challenge: Given a base from 2-10, output the largest number in that base with no repeating d... | stackexchange_codegolf |
The Universal Crossword has a set of guidelines for crossword puzzle submissions.
In this challenge we are going to be concerned with their rules for hidden word themes. A hidden word clue consists of a clue and a word. It can either be a
"word break" or a "bookend".
For a word break the word must not appear as a cont... | stackexchange_codegolf |
Hex triplets such as #ffffff (white) or #3764ef (blueish) are often used to denote RGB colors. They consist of # followed by six hexadecimal digits (0-f), or sometimes three digits where the real color is obtained by doubling each digit. For example, #fff is #ffffff and #1a8 is #11aa88.
Sadly, that three digit shorthan... | stackexchange_codegolf |
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... | stackexchange_codegolf |
Note: this challenge has been posted on the sandbox.
Introduction
This challenge is inspired by 2009 Putnam B1, a problem in an undergraduate mathematics competition. The problem is as follows:
Show that every positive rational number can be written as a quotient of products of factorials of (not necessarily distinct... | stackexchange_codegolf |
(Inspired by this comment on an old question.)
Background
An error quine (also known as a "Kimian quine") is a program which, when compiled or run, causes the compiler/interpreter/runtime to print an error message that has identical text to the program itself, and nothing else. For the purposes of this challenge, we're... | stackexchange_codegolf |
Challenge
Create a function takes in two 2-dimensional arrays of characters (or strings if the programming language does not have characters as a datatype) as inputs: a and b. If your language does not support these inputs, you may use any other standard one-byte variable.
Your task is to determine if b contains a. If ... | stackexchange_codegolf |
Let's say you have some text, and you want it to send it to your friend, but you don't want anyone else to read it. That probably means you want to encrypt it so that only you and your friend can read it. But, there is a problem: you and your friend forgot to agree on an encryption method, so if you send them a messa... | stackexchange_codegolf |
We all know that whenever a rational number is written in decimal, the result is either terminating or (eventually) periodic. For example, when 41/42 is written in decimal, the result is
0.9 761904 761904 761904 761904 761904 761904 761904 ...
with an initial sequence of digits 0.9 followed by the sequence 761904 repe... | stackexchange_codegolf |
The sequence discussed in this challenge is a variant of the Descending Dungeons sequence family. Specifically, the sequence generation rules:
(A_b = A's base 10 representation read as a base b number, A = A_10)
A(0) = 10
A(n) = 10_(11_(12_(...(n+9)_(n+10))))
Your goal is to make a program which accepts a nonnegative ... | stackexchange_codegolf |
For today's task, we have two programs, P and Q, both in the same language. Each of them receives a single-character input.
If P receives character K, P says how many times K appeared in Q. (You can use any output format for P or Q; they need not be the same, the only requirement is that your format can represent any n... | stackexchange_codegolf |
Let's say you have some text, and you want it to send it to your friend, but you don't want anyone else to read it. That probably means you want to encrypt it so that only you and your friend can read it. But, there is a problem: you and your friend forgot to agree on an encryption method, so if you send them a messa... | stackexchange_codegolf |
Given some positive integer \$n\$ that is not a square, find the fundamental solution \$(x,y)\$ of the associated Pell equation
$$x^2 - n\cdot y^2 = 1$$
Details
The fundamental \$(x,y)\$ is a pair of integers \$x,y\$ satisfying the equation where \$x\$ is minimal, and positive. (There is always the trivial solution \$... | stackexchange_codegolf |
What is the best BrainFuck code (in terms of code size) to print 'A' 1000 times ?
My approach is:
set 'A' to p[0]
set 255 to p[1] to display 255 'A', 3 times
set 235 to p[1] to display 235 'A'
This is not effective but I cannot find a way to use tow counters simultaneously like a multiplication
Is there a better appr... | stackexchange_codegolf |
Gah! It's a shame that Pokémon Sword and Shield won't introduce a new eeveelution. Let's mourn them with a code golf.
The objective is to, when given a type name as the input, output the name of the corresponding eeveelution.
When given Water, output Vaporeon.
When given Electric, output Jolteon.
When given Fire, outp... | stackexchange_codegolf |
Starting at 1-TET, give equal temperaments that have better and better approximation of the perfect fifth(just ratio 3/2). (OEIS sequence A060528)
The formal description of the sequence, copied from the OEIS:
A list of equal temperaments (equal divisions of the octave) whose nearest scale steps are closer and closer a... | stackexchange_codegolf |
Objective
Find the most expensive path from the top-left of a square grid to the bottom-right such that its total cost is below a given threshold.
Scenario
You are given a square NxN grid.
You are given a maximum cost.
Every cell in the grid has a cost. The top-left cell has cost 0.
The cost of a path is the sum of th... | stackexchange_codegolf |
Challenge
You will be given a table as input, drawn with ASCII | and _. Your task is to set the chairs around it.
Example
Input:
____
| |
| |
| |
| |
|____|
Output:
_^_^_
< >
| |
< >
| |
<_ _ _>
v v
Those chairs are made of <> and v^.
Another example:
The line must have as many chairs ... | stackexchange_codegolf |
Your task is to write a program that calculates the amount of different ways to display any given whole positive number using the following rules:
Meet the 'advanced binary system':
Any whole positive number can be displayed in binary form, but each bit can have every number from 0 to 9. This means, a valid number migh... | stackexchange_codegolf |
Yes, really. Print it with a hardware printer to create a hard copy.
Send the necessary commands/data to your printer such that the following text is printed on a piece of paper:
Hello, World!
You may use any local- or network-connected printer that is available to you.
If your printer allows, you should use 8pt or... | stackexchange_codegolf |
Most tip calculator apps simply take a flat percentage of the meal price. So, for example, if your meal is $23.45, you can leave a 15% tip = $3.52, or a more generous 20% tip = $4.69.
Convenient enough for credit card users. But not so if you prefer to leave cash tips, in which case these oddball cent amounts get in ... | stackexchange_codegolf |
Output the Nth term of the Van Eck Sequence.
Van Eck Sequence is defined as:
Starts with 0.
If the last term is the first occurrence of that term the next term is 0.
If the last term has occurred previously the next term is how many steps back was the most recent occurrence.
https://oeis.org/A181391
https://www.you... | stackexchange_codegolf |
Given an integer \$N\$ consider a permutation \$p=p_1,p_2,p_3,\ldots\$ of \$1,\ldots,N-1\$. Let \$P = p_1 , p_1+p_2 \bmod N, p_1+p_2+p_3 \bmod N, \ldots\$ be its prefix sums modulo \$N\$. Sometimes \$P\$ will be a permutation of \$1,\ldots,N-1\$ itself.
For example, \$N=4: p=3,2,1 \rightarrow P=3,1,2\$
Negative example... | stackexchange_codegolf |
Task
Your task is to draw these beautiful oak trees:
1 ->
@@@
@@@@@
@|.|@
_|_|_
2 ->
@@
@@@@@@
@@@@@@@@
@@| .|@@
| |
__|__|__
3 ->
@@@@@
@@@@@@@@@
@@@@@@@@@@@
@@@| |@@@
@| .|@
| |
___|___|___
4 ->
@@
@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@@@
@@@@| |@@@@
@@| .|@@
| |
| ... | stackexchange_codegolf |
Task
Write a program/function that when given 3 positive integers \$a, b\$ and \$m\$ as input outputs a positive integer \$x\$ such that \$a^x\equiv b\ (\text{mod}\ m)\$ or that no such \$x\$ exists.
A reference implementation can be found here.
Constraints
You can expect \$a\$ and \$b\$ to be less than \$m\$.
Scoring
... | stackexchange_codegolf |
Given two numbers, the first is greater than the second, check whether the first number is divisible by the second without a remainder. If divisible, answer "yes"(or any other string), otherwise "no"(or any other string you like).
Conditions: You cannot use conditional operators, loops, arrays, bitwise operations, func... | stackexchange_codegolf |
Your challenge is to create the longest run of characters with incrementing Unicode codepoints in a pristine program as you can. To keep things simple, I'll abridge the definition for this challenge to be "any program which produces no errors but will error if any one character is removed".
Let's define a codepoint run... | stackexchange_codegolf |
I like anagrams. I like programs that reference their own source code. So this challenge combines them!
Input.
The input to the program could be anything, including letters, numbers, symbols, you name it.
Output.
A truthy value if the input's characters can be rearranged to give the source code, and a falsy value if th... | stackexchange_codegolf |
I have a bunch of ASCII art that I have recovered from a failed hard drive. Unfortunately, all of the newlines were stripped out, and I don't know the resolution of the original artwork. I do know that each one was originally rectangular, but to make matters worse, all the white space at the beginning and end was strip... | stackexchange_codegolf |
In Australian Football, goals are worth 6 points and behinds are worth 1 point. Scores may include the number of goals and behinds, as well as the total score. Given the number of goals and behinds for two different teams, determine which team won the game.
Take four integers g1, b1, g2, b2 as input, and output two dis... | stackexchange_codegolf |
What general tips do you have for golfing in LOLCODE? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to LOLCODE. (e.g. "remove comments" is not an answer). Please post one tip per answer.
| stackexchange_codegolf |
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... | stackexchange_codegolf |
Background
Countless generations of children have wondered where they would end up if they dug a hole directly downwards. It turns out that this would, unsurprisingly, be rather dangerous, but anyway...
Antipodes are points that are directly opposite each other on the Earth's surface. This means that if a line was draw... | stackexchange_codegolf |
An Almost Equilateral Heronian Triangle is a triangle with integer lengths of the form n-1, n, and n+1 and also has integer area. The first few are:
3, 4, 5 -> 6
13, 14, 15 -> 84
51, 52, 53 -> 1170
Quest: Generate the shortest program that outputs the nth such triple. (Hint: this is a known sequence).
Winner w... | stackexchange_codegolf |
Introduction
In the video the best way to count, binary is proposed as the best system of counting numbers. Along with this argument is a proposal on how to say numbers in this system. First, we give names to each "double power of two", \$2^{2^n}\$ for each \$n\$.
number = symbol = spoken
============================
2... | stackexchange_codegolf |
Black Box is a board game, Your task is to reveal all clues.
What is black box
Black box is a board game with hidden atoms, Your task is given input, All atoms, reveal all clues.
I/O
Input
The atoms can be any 1-char that is not newline (Used for separator) Like this.
O....
...O.
..O..
.....
....O
Output
When the code... | stackexchange_codegolf |
The goal of this challenge is given a finite directed acyclic graph (DAG), determine if the graph is a transitive reduction.
A brief explanation of what a DAG and transitive reductions are:
A DAG is a graph with directed edges (i.e. you can only travel in one direction on that edge) such that given any starting node on... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.