instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Introduction
Brainstract, a newly created dialect of Brainfuck adds a bit more elements to the syntax. In addition to the normal Brainfuck syntax, there are macros. To define a macro:
{macro_name ++++}
Then use it:
{macro_name} Adds 4 to the current cell
Challenge
Your challenge is to take a valid Brainstract progra... | stackexchange_codegolf |
Sometimes in chat, if someone says something you agree with, you'll send a message with an ^, which points at the message above:
Radvylf: Cats are far superior to JavaScript
You: ^
Sometimes you'll also add some text:
Radvylf: I sure do like integers
You: I mostly agree with ^ but floats are pretty neat too
You can a... | stackexchange_codegolf |
Introduction:
Pete likes doing word search puzzles. Despite that, he has trouble searching for words vertically, (anti-)diagonally, or reversed. Because of that, he'll always search for the words left-to-right, and rotates the entire puzzle in increments of 45 degrees clockwise.
In addition to that, he'll also always s... | stackexchange_codegolf |
Trigonometry has LOTS of identities. So many that you can expand most functions into sines and cosines of a few values. The task here is to do that in the fewest bytes possible.
Identity list
Well, the ones we're using here.
sin(-x)=-sin(x)
sin(π)=0
cos(-x)=cos(x)
cos(π)=-1
sin(a+b)=sin(a)*cos(b)+sin(b)*cos(a)
cos(a+b)... | stackexchange_codegolf |
Task
Given two integers \$d\$ and \$n\$, find the number of ways to express \$n\$ as a sum of \$d\$ squares. That is, \$n = r_1^2 + r_2^2 + ... + r_d^2\$, such that \$r_m\$ is an integer for all integers \$1 ≤ m ≤ d\$. Note that swapping two different values (e.g. \$r_1\$ and \$r_2\$) is considered different from the o... | stackexchange_codegolf |
Write a program or function that takes in three integers, a width w, a height h, and a step count s. You will be drawing a non-self-intersecting random walk s steps long on a 5*w by 5*h pixel image where every 5 by 5 pixel cell is either empty (pure beige) or one of these twelve simple "pipes":
The image above is enla... | stackexchange_codegolf |
Your task: Print or return a conversion table with every byte from 00 to ff's value as an unsigned integer, to its value as a signed one (using two's complement).
For example:
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
1... | stackexchange_codegolf |
Your goal is to determine whether a given number n is prime in the fewest bytes. But, your code must be a single Python 2 expression on numbers consisting of only
operators
the input variable n
integer constants
parentheses
No loops, no assignments, no built-in functions, only what's listed above. Yes, it's possible... | stackexchange_codegolf |
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 ... | stackexchange_codegolf |
Construct a full program which outputs Hello, World!. The score of your submission will be equal to the sum of all of the ASCII values of the distinct characters. The lowest score wins!
Rules
It must be a full program which takes no input
It must only print to STDOUT, nothing else
It must be strictly less than 1000 by... | stackexchange_codegolf |
NATO phonetic alphabet is a spelling alphabet that associate to each of the 26 letters of the English alphabet one word (table below) that is easy to understand over the radio or telephone. For example, if you want to communicate the word CAT over the telephone, you do the following spelling:
CHARLIE ALFA TANGO
But wha... | stackexchange_codegolf |
Background
As far as we can tell from trying everything (besides cheating with ZWSPs), you can't type
`\
in Stack Exchange chat. However, you can type
\`
by doing
`\\``.
So, if you want to tell someone in chat how to type backslash-backtick, you'd need to type out
`\`\\`\``
to format
`\\``
into a codeblock.
Challenge
Y... | stackexchange_codegolf |
Your task is to determine whether some arbitrary programming language has zero-indexed or one-indexed arrays based on sample inputs and outputs
Inputs
An array of integers with at least 2 elements
A positive integer index
The value of the array at that index
Output
One of four distinct values representing:
One-index... | stackexchange_codegolf |
Given an integer \$n \geq 2\$, print a triangle of height \$n\$ of (triangles of height \$n\$ of asterisks), as in this SO question.
For \$n=2\$, print:
*
***
* * *
*********
For \$n=3\$, print:
*
***
*****
* * *
*** *** ***
***************
* * ... | stackexchange_codegolf |
We don't have enough (semi-)easy challenges for beginners. More and more of the easy ones are already taken. So I tried to come up with something that might be achievable by beginners, but that isn't a duplicate.
Input:
A single string separated with your OS new-line (i.e. \r\n),
or an array with multiple strings.
Outp... | stackexchange_codegolf |
Given a list of case-insensitive ASCII letter strings ("words"), output whether the entire list can be found on some four-by-four configuration ("board") of letter squares, in which no square can be used more than once in a word, and in which words are formed by moving from any square to any adjacent square including d... | stackexchange_codegolf |
Introduction
Your goal is to find the least number of ones you need to add or multiply together to get the input value, this is A005245.
Input
One positive integer N.
Output
The smallest number of ones that must be added/multiplied to get N.
Sample Input
7
Sample Output
6
Explanation
(1 + 1 + 1) * (1 + 1) + 1 = 7
... | stackexchange_codegolf |
A common year is a year that is not a leap year and where the first and last day of the year are on the same day. A special common year is one that starts on a Monday and so ends on a Monday as well.
Your challenge is to create a program/function that when given a year as input finds the nearest special common year, o... | stackexchange_codegolf |
Introduction
The \$RADD(n)\$ operation is defined as the sum of \$n + [\$ the number whose decimal representation are the decimal digits of \$n\$ in reverse order \$]\$, see A004086. After reversal, trailing zeros are lost. See Reverse-Then-Add Sequence and A056964.
Not all numbers can be represented as the result of a... | stackexchange_codegolf |
Given a length N string of less-than and greater-than signs (<, >), insert the integers 0 through N at the start and end and in between each pair of signs such that all the inequalities are satisfied. Output the resulting string. If there are multiple valid outputs, output any one (and just one) of them.
For example
<<... | stackexchange_codegolf |
The challenge.
Make a program that produces a random series of 8 notes in the scale of E minor, and then harmonizes them.
Details.
Notes must be represented in output as a 1-2 char string, which designates the note and if it is sharped or not, followed by a number, which designates the octave. Examples would be C3, D#... | stackexchange_codegolf |
A jigsaw puzzle consists of (usually rectangular-ish) pieces. On each side of a piece, there is either an edge or a connector (a term I made up). A connector is either a tab sticking out (outie) or a slot facing inwards (innie). Two pieces can be joined if the outie tab can fit into the innie slot. The goal is to assem... | stackexchange_codegolf |
I'm golfing a program to sum two numbers in C++.
Example:
10 3
13
I found out that this problem can be solved in 54 symbols (without spaces and so on) using C++.
My code (63 symbols):
#include <iostream>
main() {
int a, b;
std::cin >> a >> b;
std::cout << a + b;
}
I have no idea how to make my program sho... | stackexchange_codegolf |
This time, we want render the count of bytes in a human readable way to user. Let's write a program (a full one or a function or other acceptable formats) to do this.
Input
An non-negative integer, in range \$0\leq n<2^{31}\$, which means n bytes.
Output
A string, the human friendly representation of n bytes.
Conventio... | stackexchange_codegolf |
While Rust is very, very rarely competitive in code golfing competitions (Java is often shorter), it can still be fun to golf in. What are some tricks for making Rust code shorter?
Please post only one tip in each answer.
| stackexchange_codegolf |
This challenge is inspired by a series of young children's books by Fiona Watt and Rachel Wells, which I've recently been enjoying with my daughter.
In each book a mouse (illustrated, but not part of the text) complains that a succession of 5 things of the same type are not its thing. It then backs this up by declarin... | stackexchange_codegolf |
Let's have string multiplication to take a string and a positive number and concatenate that string that many times. In Haskell:
0 * s = ""
n * s = s ++ ((n - 1) * s)
Your task is to write a program that outputs a number \$n > 0\$. When you double your program (with the described procedure) the new program should ou... | stackexchange_codegolf |
Now that we know how to properly square and triangle a number, we are going to learn how to parallelogram one. To parallelogram a number, we first arrange it as a parallelogram by stacking it on top of itself a number of times equal to the number of digits it has, and adding spaces to make it a parallelogram. So 123 ... | stackexchange_codegolf |
The incenter of a triangle is the intersection of the triangle's angle bisectors. This is somewhat complicated, but the coordinate formula for incenter is pretty simple (reference). The specifics of the formula do not matter much for this challenge.
The formula requires lengths of sides, so it can be very messy for mos... | stackexchange_codegolf |
If you throw an ASCII egg in a given direction, you end up with an ASCII splat of size n. It "starts" with one o (the yolk), and continues in a given direction with "lines" consisting of 2 up to n *'s. The *'s are separated by one "space", and the o and all the "lines" of *'s are separated by "lines" of "space".
The di... | stackexchange_codegolf |
Given a key, and an array of strings, shuffle the array so that it is sorted when each element is XOR'd with the key.
XOR'ing two strings
To XOR a string by a key, XOR each of the character values of the string by its pair in the key, assuming that the key repeats forever. For example, abcde^123 looks like:
a ... | 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 |
Yes, this is very similar to this question. However, that concerns infinite linked lists, and you do not need to handle out of bounds indexes in that question.
You are in a strange city, looking for the fabled Nineteenth Bakery, where it is said they sell the most delicious deleted posts. The order of shops here is s... | stackexchange_codegolf |
The fast growing hierarchy is a way of categorizing how fast functions are growing,
defined the following way (for finite indices):
\$ f_0(n)=n+1 \$
\$ f_k(n)=f_{k-1}^n(n)\$ with \$f^n\$ meaning repeated application of the function f
Examples
f0(5) = 6
f1(3) = f0(f0(f0(3))) = 3+1+1+1= 6
f2(4) = f1(f1(f1(f1(4)))) = 2*... | stackexchange_codegolf |
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... | stackexchange_codegolf |
This is similar to Making an acronym, but there are several key differences, including the method of fetching the acronym, and this challenge including flexible output.
Task
Given a string (list of chars/length 1 strings is allowed) containing only printable ASCII, output all capital letters in the input that are eithe... | stackexchange_codegolf |
Background
Boolean Algebra concerns representing values with letters and simplifying expressions. The following is a chart for the standard notation used:
Above is what actual boolean algebra looks like. For the purposes of this code golf, this is not the syntax that will be used.
Your Task
Given a string with three c... | stackexchange_codegolf |
The shortest reliable password testing code
Introduction
I started playing Empire of Code recently, and there was some challenge. The player is supposed to write a piece of Python or Javascript code to detect if the string passed to it is reliable password, that is, it contains at least one lowercase Latin letter, one ... | stackexchange_codegolf |
According to this site a general rule recommended by The U.S. Government Printing Office Style Manual is
Capitalize all words in titles of publications and documents, except
a, an, the, at, by, for, in, of, on, to, up, and, as, but, or, and
nor.
This might not be true as I'm unable to find such a recommendation i... | stackexchange_codegolf |
Disarium Dilemma
A Disarium is defined as a number whose:
sum of its digits powered with their respective position is equal to the original number
Your Task:
You have a strange obsession with numbers classified as being a disarium. The need to follow the ways of disarium is so great in you that you refuse to read a... | stackexchange_codegolf |
Challenge
To quote Wikipedia:
An octave-repeating scale can be represented as a circular arrangement
of pitch classes, ordered by increasing (or decreasing) pitch class. For instance, the increasing C major scale is C–D–E–F–G–A–B–[C], with the bracket indicating that the last note is an octave higher than the first no... | stackexchange_codegolf |
Develop a program to check if a given word is part of a language defined by the following rules:
The language has a set of rules.
The empty string is considered a valid word in the language.
Two words from the language can be concatenated to create a new word in the language.
If X is a word in the language, then "A" +... | stackexchange_codegolf |
Your objective is to take multiline ASCII like
| v |
* * * *
* * *
and have an array that includes everything that isn't a star changed to a star (except for [any-width] spaces) and the number of stars it included and the number of stars it now includes. So the output of my example would be:
['* * *
* * * *
* *... | stackexchange_codegolf |
Display the emoji of the eastern zodiac of given time, according to given country.
The eastern zodiac is a classification scheme that assigns an animal and its reputed attributes to each year in a repeating 12-year cycle. It is also assigned to hours.
Rules:
The country must be given as ISO 3166-1 alpha-3 code. The li... | stackexchange_codegolf |
A kitten is much like a cat. Some of the main differences are cuteness, lack of intelligence, and size. Similarly, the cat command is different from the kitten command. Fortunately, there is only one difference in this case. In the kitten command, all uppercase letters are replaced with lowercase letters.
Objective
To... | stackexchange_codegolf |
Monday Mini-Golf: A series of short code-golf challenges, posted (hopefully!) every Monday.
(Sorry this one's a little late.)
I'm sure most of you folks have heard of Levenshtein distance, an algorithm for calculating the distance between two strings. Well, this challenge is about implementing a similar algorithm of my... | stackexchange_codegolf |
inputs / outputs
your program/function/routine/... will be a predicate on two tuple sequences; call it relation ≡. for the purpose of simplicity we use natural numbers:
the input will be two list of pairs of numbers from ℕ (including 0); call them Xs and Ys
the output will be a "truthy" value
specification
≡ checks t... | stackexchange_codegolf |
Pascal's Rhombus (which is actually a triangle) is obtained by adding in the pattern:
*
***
x
instead of
* *
x
This means that each cell is the sum of the three cells on the row directly above it and one cell on the row 2 above it. Just like Pascal's triangle the zeroth row has a single 1 on it that generates... | stackexchange_codegolf |
You are on a plane filled with boxes, and you get a sequence of movements, say "up right right down left":
You move up, pushing all boxes in front of you away:
You move right, right and down, getting
and finally left. This time you only push one box rather than infinite boxes:
At the end, there are 4 spaces.
Given ... | stackexchange_codegolf |
To dynamically include a JavaScript file in a web page, you'd normally insert a <script> tag pointing to your script. For example:
var js_file= document.createElement("script");
js_file.src='http://example.com/js.js';
document.body.appendChild(js_file);
Write JavaScript code will load an external JavaScript file in th... | stackexchange_codegolf |
And in particular the second law: the entropy of an isolated system undergoing an irreversible process increases with time.
For this challenge,
An "isolated system" will be taken to be a program or function (abbreviated as "program" from now on);
The "irreversible process" will be execution of code;
The passing of "ti... | stackexchange_codegolf |
As we all know, meta is overflowing with complaints about scoring code-golf between languages (yes, each word is a separate link, and these may be just the tip of the iceberg).
With so much jealousy towards those who actually bothered to look up the Pyth documentation, I thought it would be nice to have a little bit mo... | stackexchange_codegolf |
Your task is simple: write a program that will replace random pixels in a black 16px * 8px rectangle (width by height) with a white pixel.
The holes must be uniformly random, and you should output the 16px by 8 px image with the white pixels inserted.
Replace only 1 pixel per column (16 total replaced pixels)
You don'... | stackexchange_codegolf |
Three positive integers A, B, C are ABC-triple if they are coprime,
with A < B and satisfying the relation : A + B = C
Examples :
1, 8, 9 is an ABC-triple since they are coprime, 1 < 8 and 1 + 8 = 9
6, 8, 14 is not because they are not coprime
7, 5, 12 is not because 7 > 5
You can see this Frits Beukers 2005 presenta... | stackexchange_codegolf |
Here's a very simple little problem that I don't believe has been asked before.
Challenge
Write a program or a function that takes in four positive integers that represents the lengths of movable but unbreakable and unbendable straight fences. Output the area of the largest rectangular yard that can be fully encompasse... | stackexchange_codegolf |
Given an integer N > 1, output all other numbers which prime decompositions have the same digits as the prime decomposition of N.
For example, if N = 117, then the output must be [279, 939, 993, 3313, 3331], because
117 = 3 × 3 × 13
therefore, the available digits are 1, 3, 3 and 3 and we have
279 = 3 × 3 × 31
939 =... | stackexchange_codegolf |
Test Driver • Challenge Discussion • Submit Adventurer
(Image Source)
Several rival adventurers are raiding the ruins for treasure, but they can only carry so much at a time and have their limits of endurance. They want to get the most valuable treasure and get out before they become too tired to continue. They are tr... | stackexchange_codegolf |
Cops' challenge
This cops-and-robbers challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when reversed, produces some non-empty output in language B. The program may produce any output to STDERR when run in either language, but may not take input... | stackexchange_codegolf |
A paragraph of text has numbers and alphabetic letters mixed. Your task is to separate the numbers to the left side and the alphabetic letters to the right side in the same order of each line.
Rules:
Numbers are plain integers; so no decimal point, and no negative/positive signs.
Numbers may or may not be contiguous,... | stackexchange_codegolf |
The Challenge
Write a program or function that takes no input and outputs a 3-dimensional vector of length \$1\$ in a theoretically uniform random direction.
This is equivalent to a random point on the sphere described by $$x^2+y^2+z^2=1$$
resulting in a distribution like such
Output
Three floats from a theoretically ... | stackexchange_codegolf |
Your task is to write a RegEx that matches everything inside strings.
A string is defined as everything surrounded by (but not including) two unescaped ".
A " can be escaped by \, which can also be escaped again.
Testcases
string: ab\c"defg\\\"hi"jkl"mn\\\\"opqrst""
matches: ^^^^^^^^^^ ^^^^^^ ^ (the em... | stackexchange_codegolf |
Write a program or function that takes an input greater than or equal to 2. It should output a truthy or falsy value corresponding to whether the input is a Lucas number or not. You may take input from STDIN, or whichever source is most suitable to you.
This question is different to this one because this question is sp... | stackexchange_codegolf |
You will be given a string s. It is guaranteed that the string has equal and at least one [s and ]s. It is also guaranteed that the brackets are balanced. The string can also have other characters.
The objective is to output/return a list of tuples or a list of lists containing indices of each [ and ] pair.
note: The s... | stackexchange_codegolf |
Not entirely sure if this one or a similar challenge has already been posted, but here it goes anyway.
Write a program that takes a string as input and writes its trucated/summarized output form such that a specific sep (separator) is placed in the middle, removing the necessary characters of the original string so tha... | stackexchange_codegolf |
Let's make a little stupid program that simulates the meme "Mr. incredible becoming uncanny", but in this case, our little ASCII friend is going to react to our code length.
Objective:
Create a program that takes anything (preferably a program) as input and outputs this:
Pov:
<face> you score X on codegolf
Where X ... | stackexchange_codegolf |
Write a program or a function that accepts the list of outputs from a logic function and outputs the LaTeX code for its truth table.
The inputs should be labeled as lowercase letters a-z, and the output should be labelled as F. The length of list of inputs will always be shorter than 2^25, which means that number of in... | stackexchange_codegolf |
Consider an \$n \times n\$ grid of integers. The task is to draw a straight line across the grid so that the part that includes the top left corner sums to the largest number possible. Here is a picture of an optimal solution with score 45:
We include a square in the part that is to be summed if its middle is above o... | stackexchange_codegolf |
In honor of how much rep I had several hours ago, when I first thought of this challenge:
Numbers like this that are made up of a single digit repeating are called repdigits. Repdigits are fun! Every body would be more happy if the amount of rep they had was a repdigit¹, but I am impatient, so you need to help me find... | stackexchange_codegolf |
NDos' Numeral System
NDos' numeral system is a numeral system invented by me. It represents every nonnegative integer by a binary tree. Given a nonnegative integer \$n\$:
If \$n=0\$, it is represented as the empty tree.
Otherwise, the tree has a root. With the binary expansion of \$n\$:
The left sub-tree of the root... | stackexchange_codegolf |
I am quite proficient in C++ and Java and want to learn competitive programming to participate in contests like Google codejam and other online contests held on sites like CodeChef and Codeforces. I would like to get information about any free resources including websites and courses to learn the "sport". Book suggesti... | stackexchange_codegolf |
Objective
Given a dimension of an SI unit, convert the Lorentz-Heaviside version of a Planck unit \$1\$ into SI metric.
What is a Planck unit?
Planck units are a set of units of measurement. It defines five fundamental constants of the universe as dimensionless \$1\$.
What is a dimension?
There are five types of fundam... | stackexchange_codegolf |
In Conway's Game of Life, there is an infinite square grid of cells, each of which is alive or dead. The pattern changes each "generation". A dead cell with exactly 3 live neighbors (orthogonal or diagonal) becomes a live cell. A live cell only lives to the next generation if it has 2 or 3 live neighbors. These simple ... | stackexchange_codegolf |
The title pretty much describes it all. Given as input a \$n \times m\$ matrix and an integer \$i\$ create a complete function/program that returns the matrix \$i\$ times clockwise rotated by \$90^\circ\$.
Rules:
as matrix you can use any convenient representation you like e.g. a list of lists etc...
matrix values can... | stackexchange_codegolf |
The gravitational binding energy of a planet is the amount of energy required to separate every tiny piece of it so that no piece will orbit or collide with another piece. For a uniform sphere, Wikipedia gives this formula:
$$E = \frac{3GM^2}{5R}$$
Where G is the gravitational constant (6.672e-11 m3•kg-1•s-2), M is mas... | stackexchange_codegolf |
They say that hate is a strong word. I wanted to find out why, so I had a good look at the word.
I noticed that every consonant had a vowel after it. That made it look quite strong to me, so I decided that that's what makes a word strong.
I want to find more strong words, so I'll need a program for it!
Finding strong w... | stackexchange_codegolf |
Objective
Given two Chinese ideographs meaning basic colors, output the ideograph that means the color resulting from mixing them.
Basic colors
The basic colors are:
靑(U+9751; blue)
赤(U+8D64; red)
黃(U+9EC3; yellow)
白(U+767D; white)
黑(U+9ED1; black)
Mixed colors
Mixing 靑(blue) and 赤(red) yields 靘(U+9758; purple).
Mix... | stackexchange_codegolf |
The aim of this post is to gather all the tips that can often be applied to radiation-hardening challenges.
Please only post answers which can apply to a large number of languages, and one tip per answer.
| stackexchange_codegolf |
Challenge
Generate \$n-1\$ consecutive composite numbers using this prime gap formula
$$n!+2,n!+3,...,n!+n$$
Input
An integer \$n\$ such that \$3 \leq n \leq 50 \$.
Output
Sequence of \$n-1\$ consecutive composite numbers.
Example
Input
3
Output
8
9
Rules
Output should be in integer format.
Test Cases
For \$n > 20\... | stackexchange_codegolf |
Gimbap(김밥) is Korean food, somewhat looks like sushi roll.
Here is Korean emoticon represent Gimbap : @))))))))))
Your quest is make ASCII Gimbap cutter.
Rule
Input is string made with only @ and ).
Output cuts every valid Gimbap with ), and then add @ between them. So for example @)) to @) @).
Valid Gimbap starts wi... | stackexchange_codegolf |
The text of the children's book Polar Bear, Polar Bear, What Do You Hear? has a very simple pattern. You might use the text to teach introductory programming concepts.
My son was quickly bored by this idea, so I decided to play some golf with it instead.
The Challenge
In your programming language of choice, write the... | stackexchange_codegolf |
Background
The United States has a unique love of gerrymandering––the deliberate manipulation of an electoral district to predict certain voting results. Just recently there was a gerrymandering case brought before the Supreme Court. Gerrymandering, especially when related to race, is ruled illegal and results in the r... | stackexchange_codegolf |
You will be given a point (x,y) relative to the center of the Ulam spiral (the center being the point which represents one), and length z. The task is to check whether there exists a path from (0,0) to (x,y) of length z, assuming prime numbers are obstacles and each turn in path has an angle of 90 degrees. Path may not... | stackexchange_codegolf |
I have the code:
marks = tuple(tuple((input("Enter subject: "), input("Enter marks: "))) for _ in range(int(input("Enter number of tuples: "))))
print(tuple((s[:3].upper(), max(int(m) for t, m in marks if t == s)) for s in set(t for t, m in marks)))
#INPUT
(("Physics",131),("Chemistry",30),("Physics",100),("Computers"... | stackexchange_codegolf |
Your input is a ragged list of possibly empty lists of non-negative integers. For example, [[2,0],[[]],[[[],[1],[]],[]]] is a valid input. This input is a "compressed" ragged list. What this means is that when we have a list of numbers, we interpret those as a list of indices, indexing the output.
For example, if I=[[2... | stackexchange_codegolf |
Given two inputs, a string \$s\$ and a decimal number \$n\$, output the string multiplied by that number.
The catch is that the number can be a float or an integer.
You should output the string \$\lfloor n \rfloor\$ times and then the first \$\lfloor (n - \lfloor n \rfloor) \cdot |\,s\,|)\rfloor\$ characters again.
Oth... | stackexchange_codegolf |
Consider a sequence of natural numbers for which N appears as a substring in N^2. A018834
Output the nth element of this sequence.
Rules
Program takes only n as input and outputs just one number - N.
The sequence can be 0-indexed or 1-indexed.
Sequence: 1 5 6 10 25 50 60 76 100 250 376 500 600 625 760 ...
Squares: 1 2... | stackexchange_codegolf |
Your task today is to write a program or function that takes an array of integers, and counts the number of times, reading it left to right, that the value changes. This is easier to show with an example: [1 1 1 2 2 5 5 5 5 17 3] => [1 1 1 **2** 2 **5** 5 5 5 **17** **3**] => 4
Test case:
Input | Output
[] ... | stackexchange_codegolf |
Introduction
In the field of mathematics known as topology, there are things called separation axioms.
Intuitively, you have a set X and a collection of subsets of X, which we can think of as properties.
The system is well separated, if one can distinguish between all items of X based on their properties.
The separatio... | stackexchange_codegolf |
Write a code that runs or compiles in as many programming languages as possible and prints a newline separated list of names of previous and current programming languages.
Every used language must have 1 character longer name than previous; ex. C#, C++, Ruby, Jelly, Python...
Each language must output a list of langua... | stackexchange_codegolf |
Let's play code golf... by playing golf.
Input
Your input will be a string consisting of #'s, an o, an @, and .'s. For example:
......@..
.....##..
.........
......o..
. - playable golf course (all shots must end on one of these)
# - a barrier (shots cannot go through this)
o - the starting position of your golf ball
... | stackexchange_codegolf |
Write a program that precisely clones GNU cat version 8.32, which is
installed on my computer.
In any case, if called with the same arguments, same stdin, and same files,
your program's output to both stdout and stderr must by byte-for-byte identical
to that of GNU cat, and the exit code must be the same. This applies ... | stackexchange_codegolf |
You are trying to guess my emotion.
I will give you an adjective, as the input to the function/program.
Your task is to output the state of my eyes, either O_O for open, or ._. for closed.
Details
For these adjectives, you must output open eyes O_O
animated
breezy
brisk
driving
enterprising
fresh
indefatigable
industri... | stackexchange_codegolf |
It's all in the title...
Take as input a positive integer n>=12 and... do what the title says.
Yes, this is on OEIS A187924.
Some test cases
12 -> 912
13 -> 11713
14 -> 6314
15 -> 915
16 -> 3616
17 -> 15317
18 -> 918
19 -> 17119
20 -> 9920
40 -> 1999840
100-> 99999999999100
This is code-golf. Short... | stackexchange_codegolf |
Choose a challenge from the Cops thread, determine the third hidden message, and describe how the system works.
Keep in mind limitations and possibilities available to Cops:
You are not expected to guess any cryptographic secrets or additional information required to extract the hidden messages, as they should have al... | stackexchange_codegolf |
You have been given the charge to calculate the current balance as of the day that you perform the calculation for 330,000 individuals who worked for an average of 30 years spanning 300 years where the initial principal was 1 with an addition of 1 per day and interest rate set at 3%.
You initially tried to use online ... | stackexchange_codegolf |
An ant starts on an edge of a dodecahedron, facing parallel to it. At each step, it walks forward to the next vertex and turns either left or right to continue onto one of the other two edges that meet there. A sequence of left/right choices that returns the ant to its initial state (edge and direction) is called a rou... | stackexchange_codegolf |
Fermat's Last Theorem, mod n
It is a well known fact that for all integers \$p>2\$, there exist no integers \$x, y, z>0\$ such that \$x^p+y^p=z^p\$. However, this statement is not true in general if we consider the integers modulo \$n\$.
You will be given \$n\$ and \$p\$, which are two positive integers with \$n>1\$. Y... | stackexchange_codegolf |
Input: binary string
Output: binary string that represents the binary input + 1
Example: Given 10111 as an input, output 11000
Limitations: Can't use arithmetic operators or functions (like + - * /)
Criterion: code-golf, the shortest code wins the big imaginary award.
| stackexchange_codegolf |
Your challenge is to output the number of twisted corners given a 2x2 Rubik's Cube scramble.
For the purpose of this challenge, twisted corners are defined as corners where the colour of the top/bottom face before (usually white or yellow) is not facing the top/bottom after the scramble.
Eg. if the cube were to be orie... | stackexchange_codegolf |
Challenge
Here's a simple one.
Write a function or program when given a number in base 10 as input, it will return or print that number's value in Hexadecimal.
Examples
15 -> F
1000 -> 3E8
256 -> 100
Rules
No built-in Hexadecimal functions whatsoever
Letters may be lowercase or uppercase
You will only need to worry a... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.