instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Jelly has an "untruth" atom: Ṭ. This takes a non-empty array of positive integers and returns a Boolean array with 1s at the indexes in the input. For example:
[1,3,5,6]Ṭ ⁼ [1,0,1,0,1,1]
[5]Ṭ ⁼ [0,0,0,0,1]
[2,1,1,2]Ṭ ⁼ [1,1]
[5,4,3]Ṭ ⁼ [0,0,1,1,1]
[1]Ṭ ⁼ [1]
Try it online!
Note that Jelly uses 1-indexing... | stackexchange_codegolf |
Your challenge is to write a program to translate (English) leetspeak/lolspeak/txtspk into normal English. Your program should read from standard input and output to standard output, unless your language does not support these.
You may use a file containing a list of words in the English language, separated by new line... | stackexchange_codegolf |
Suppose a new fairy chess piece named the Wazir is introduced to chess. Wazirs can move from a position (x, y) to:
(x+1, y)
(x, y+1)
(x-1, y)
(x, y-1)
That is, they move orthogonally like the rook, but only one step at a time like the king. How many such wazirs can be placed on an N×N chessboard so that no two wazi... | stackexchange_codegolf |
The task
Given an ascii string, output a program in my esolang MAWP that outputs the inputted string when run.
Useful functions in MAWP
Numbers from 0-9: Pushes the number to stack
M Takes the top two numbers off stack and pushes the sum to stack
A Takes the top two numbers off stack and... | stackexchange_codegolf |
As if this challenge could be any more Pythonesque in spirit... No prior knowledge of Markov chains or encryption techniques is required.
You are a spy who needs to obtain some crucial information from the British security service M1S. The agents of M1S are well aware that their Wi-Fi signals can be intercepted, their ... | stackexchange_codegolf |
Definition
Given some string return an integer whose digits are the number ocurrences of a-z (case insensitive, in alphabetical order) in that string. Any character with 0 instances is skipped. Characters with 10 or more instances will define 2 or more digits of the returned integer. For example, aaaaaaaaaaaaaaaaaaaaaa... | stackexchange_codegolf |
AWG (American Wire Gauge) is a common way of specifying wire sizes. Your task in this challenge is to convert from a given gauge to the diameter of the wire in inches.
The size in inches for the gauges from 4/0 to 40 are shown in the table below:
Gauge to inches table
| AWG | Diameter (Inches) |
|-----|----------------... | stackexchange_codegolf |
Given a positive number n, rotate its base-10 digits m positions rightward. That is, output the result of m steps of moving the last digit to the start. The rotation count m will be a non-negative integer.
You should remove leading zeroes in the final result, but not in any of the intermediate steps. For example, for t... | stackexchange_codegolf |
Sandbox
For the purposes of the current task, a cube of unit length is rendered in oblique projection with ASCII symbols as follows:
+-----+
/ /|
+-----+ |
| | +
| |/
+-----+
+ for the vertices.
- for the X edges. The unit length along X is represented by five - between two vertices.
| for the Y edges.... | stackexchange_codegolf |
One day in July 2020, I made the following C program:
#define A m]
a[9999],*m=a;main(){for(2[A=4[A=1;;){for(;4[A;putchar(6[m-=3]+48));
for(puts(a);7[A;2[A=4[A,4[A=1)if(4[A+=3[m+=3]-1,9<(3[A=2[A+=3[A))++
5[A,7[A=1,3[A-=10;}}
with three superfluous newlines removed, it's 167 bytes and it prints the fibonacci sequence (a... | stackexchange_codegolf |
Your task is to write the shortest algorithm in a language of your choosing that accomplishes the following:
Given two matrices it must return the euclidean distance matrix. The euclidean distance between two points in the same coordinate system can be described by the following equation:
\$D = \sqrt{ (x_2-x_1)^2 + (y_... | stackexchange_codegolf |
Write the shortest program that takes one input (n) from STDIN (or equivalent) and outputs a simple incrementing function with one argument (x) that returns x + n but the function must be in a different language. Pretty simple!
This is code-golf, normal rules apply, shortest program wins.
Example: ><> to Python (Ungolf... | stackexchange_codegolf |
A binary eye is an odd set of digits, with all of its digits except the center one set to 1 or 0, and the center one set to the opposite of the others. Thus, there are two binary eyes for a given odd number of digits:
x
eyes
1
1,0
3
101,010
5
11011,00100
7
1110111,0001000
9
111101111,000010000
Make ... | stackexchange_codegolf |
Golf a program or function which gives the \$n^{\text{th}}\$ location of the wildebeest who starts at square \$1\$ on an infinite chessboard which is numbered in an anti-clockwise square spiral, where the wildebeest always visits the lowest numbered square she can reach that she has not yet visited.
Inspiration: The Tr... | stackexchange_codegolf |
The problem
You just got a new job, hurray! You expect to be given various interesting tasks, and be able to learn a lot in the next few months.
Good news, your boss gave you your first work this morning. You are now in charge of... Writting adresses on envelopes. Yay.
Fortunatelly, you are not required to write everyt... | stackexchange_codegolf |
Below on the left is a picture of a sorting network that can sort 4 inputs. On the right you can see it sorting the input 3,2,4,1.
A sorting network of size n consists of a set of n horizontal wires where two wires can be connected by a vertical wire. The inputs to a sorting network move from the left to the right on ... | stackexchange_codegolf |
Today's challenge is simple: Without taking any input, output any valid sudoku board.
In case you are unfamiliar with sudoku, Wikipedia describes what a valid board should look like:
The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 subgrids that compose the grid (... | stackexchange_codegolf |
Introduction
We all love StackExchange, therefore it would be essential to download all gems hidden on Stack Overflow repositories in the simplest possible way.
Challenge/Task
Your task is to write a script or program which would:
Fetch the list of all (within current page) repositories under Stack Overflow GitHub acc... | stackexchange_codegolf |
You need to build a pyramid from cubes. Cubes can be viewed from 2 angles:
_____ _____
/\ \ / /\
/ \____\ /____/ \
\ / / \ \ /
\/____/ \____\/
This is an example for 2-size cubes from the 2 possible angles.
The height of the cubes is $size slashes (or back-slashes), and the w... | stackexchange_codegolf |
Context
We're at war! You need to transfer an important message to your general to inform them from an imminent assault. The thing is, your enemy knows a lot about cryptography : you will need to be more creative in order to encode your message...
Task
Create a program that accepts an ascii message as input, and output... | stackexchange_codegolf |
Challenge:
Given the input array l with a list of strings, only keep the elements in the sequence that have a letter that's repeated at least 3 times. Like 'lessons' has 3 s letters, so it should be kept in the sequence. But, 'lesson' has only two s letters, so it should be removed.
Notes:
l will always be a sequence,... | stackexchange_codegolf |
Introduction
In this challenge, your task is to correctly list the cases of two Finnish nouns.
The twist is that you may use one of the listings as a guide to produce the other.
The Nouns
We use the following two declination tables as our data.
They list the cases of two nouns, one case per line in the same order as in... | stackexchange_codegolf |
Pyth is in ongoing development, meaning that new features are being added all the time.
I want to make Pyth a better langauge, so I'd like to know what features people are looking for.
This is the place the post ideas you have for making Pyth better.
In your answer, please state:
What you'd like to see changed/added.
... | stackexchange_codegolf |
An alphadrome is a word in which each letter in the first half of the word "reflects" its alphabetical "opposite" in the second half of the word. Write a program or function that returns truthy if the given word is an alphadrome and falsey otherwise.
For example, BEEB is a palindrome. Its first letter B "reflects" its ... | stackexchange_codegolf |
Related: Clearly parenthesize APL trains
Background
In the most basic form, APL has two kinds of tokens: arrays and functions. For this challenge, we will use a lowercase letter a-z for an array, and an uppercase letter A-Z for a function. Furthermore, we will assume each character is a token of its own; Fx is equivale... | stackexchange_codegolf |
Challenge Taken with permission from my University Code Challenge Contest
For some years now, the number of students in my school has been growing steadily. First the number of students was increased by classroom, but then it was necessary to convert some spaces for some groups to give classes there, such as the gym s... | stackexchange_codegolf |
Given a matrix of integers, test if it's rank-one, meaning that every row is a multiple of the same vector. For example, in
2 0 -20 10
-3 0 30 -15
0 0 0 0
every row is a multiple of 1 0 -10 5.
The same definition also works with columns in place of rows. Alternatively, a matrix is rank-one if it's ... | stackexchange_codegolf |
The title says it all; Given a number in the binary (base-2) number system, output the same number expressed in unary (base-1).
You should take the binary number as a string (optionally with a separator), list, or equivalent structure of digits, using any number or digit you like for the digits. The unary output can us... | stackexchange_codegolf |
This is an answer-chaining challenge where every part of your answer should aim to be unique from every other answer.
This question will work in the following way:
I will post the first answer. The next answer will stem from that, and all other answers will originate from it.
In this answer I will include a program an... | stackexchange_codegolf |
Although on codingame.com, Objective C and C are two of the best golfing languages there, so I would like to know some of the best golfing methods (although I am a python person, I am currently trying to learn C++/C)
I am looking for general ways/tips to golf one's code (so please don't post tips such as "remove commen... | stackexchange_codegolf |
Integers in cosine
From trigonometry we know that
\$\sin(a) =-\cos(a + \frac{(4*m + 1)\pi}{2})\$
where \$a\$ is an angle and \$m\in\mathbb{Z}\$ (integer).
The task
For an input of a positive integer \$n\$ calculate the value of the integer \$k\$ with \$n\$ digits that minimizes the difference between \$\sin(a)\$ and \$... | stackexchange_codegolf |
Consider, for a given positive integer \$k\$, the sequence \$(a, a+1, a+2, ..., a+k)\$, where \$a\$ is some positive integer. Is there ever a pair \$a, k\$ such that for each element \$a+i\$ in the sequence, either \$\gcd(a, a+i)\$ or \$\gcd(a+i, a+k)\$ are greater than 1?
This was investigated by Alan R. Woods as part... | stackexchange_codegolf |
How can I shorten:
p=gets.to_i
a=gets
b=gets.to_i
If my input is an integer, followed by a string, followed by an integer?
| stackexchange_codegolf |
Following this question: Tut-tut-tut-tut-tut
Write a program that writes "tut-tut-tut" without using the characters "t", "u" or "-" in the code itself.
This is code golf, shortest code in bytes wins.
| stackexchange_codegolf |
The newest "nice" OEIS sequence, A328020, was just published a few minutes ago.
Number of distinct tilings of an n X n square with free n-polyominoes.
This sequence counts tilings up to symmetries of the square. The sequence has six terms, but I'd like to see if folks here can extend it further.
Example
For n=4 there... | stackexchange_codegolf |
Consider:
c=(a,b)=>(+a||0)+(+b||0)
Yes, it is not good to solve it like that. But I want to shorten it even more. If a is a string and b is a string, then return 0. If one is a number, return it (floats and intergers). And if both inputs are numbers, then return the sum (if either string can be cast to a number, treat... | stackexchange_codegolf |
Write a program or function with the following functionality:
The program/function first attempts to write the string Hello, world! to the standard output stream. (No other forms of output are acceptable for this challenge, as the focus is very much on the I/O rather than the trivial behaviour of the program itself.) ... | stackexchange_codegolf |
The barbells at my gym look like this:
=========[]-----------------------[]=========
They can hold plates of five different sizes, 2.5 pounds, five pounds, ten pounds, 25 pounds, and 45 pounds:
.
. ! |
. ! | | |
| | | | |
' ! | | |
' ! |
'... | stackexchange_codegolf |
Implement a function \$f\$ (as a function or complete program), such that
\$
\displaystyle\lim_{n\rightarrow \infty} f(n)
\$
converges to a number which is not a computable number.
Answers will be scored in bytes with fewer bytes being better.
IO formats
Your answer may be in any of the following formats
A program or ... | stackexchange_codegolf |
It is ancient knowledge that every non-negative integer can be rewritten as the sum of four squared integers. For example the number 1 can be expressed as \$0^2+0^2+0^2+1^2\$. Or, in general, for any non-negative integer \$n\$, there exist integers \$a,b,c,d\$ such that
$$n = a^2+b^2+c^2+d^2$$
Joseph-Louis Lagrange pro... | stackexchange_codegolf |
Input
A single positive integer \$ 10 \geq n \geq 2\$
Output
A list of strings, each of length \$2n\$, satisfying the following properties.
Each string will contain each of the first \$n\$ lowercase letters of the alphabet exactly twice.
No letter can occur twice consecutively. That is abbcac is not allowed.
No two st... | stackexchange_codegolf |
Motivation: Sometimes you need to know where you are in a string. You want to be able to look at any part of a string and know exactly where you are, as far as possible.
Challenge: write a program to output a tape measure string of a given length. A tape measure string self describes its length-so-far as often as possi... | stackexchange_codegolf |
Vim is a great text editor for unix systems, but it's notorious for being difficult to exit.
Write a full program that will output :q to exit Vim. It should then read a single line of input, as it will then either be given a bash prompt, in which case the exit was successful, or an error, in which case there are unsave... | stackexchange_codegolf |
Challenge
Imagine a hexagonal grid as shown below. Let's call such a grid has size \$n\$ if it has \$n\$ dots on one side. The following is one of size 3:
- - -
- - - -
- - - - -
- - - -
- - -
Then, pick as many dots as possible on the grid so that no two dots are adjacent. For size 3, the maximum is 7 dots:
-... | stackexchange_codegolf |
Output a random triple \$(x,y,z)\$ of real numbers such that
\$x+y+z=\frac{3}{2}\$
Each of \$x,y,z\$, taken alone, is uniformly distributed from \$0\$ to \$1\$.
Please explain in your answer what distribution your code produces and why it meets these conditions. In particular, please include a demonstration that with... | stackexchange_codegolf |
AWG (American Wire Gauge) is a common way of specifying wire sizes. Your task in this challenge is to convert from a given gauge to the diameter of the wire in inches.
The size in inches for the gauges from 4/0 to 40 are shown in the table below:
Gauge to inches table
| AWG | Diameter (Inches) |
|-----|----------------... | stackexchange_codegolf |
Write a function that takes two parameters: a positive integer n and a list of words.
Given a cube of n-by-n-by-n units, assign a random letter (A-Z) to each surface unit. (For a 3x3x3 cube, there would be 9 surface units on each face.)
Then determine whether it's possible for an ant walking along the surface (with th... | stackexchange_codegolf |
The Challenge
Given a string indicating the symbolic notation of UNIX permission of a file and its ownership (user ID and group ID), decide whether a given user A has permission to read / write / execute it.
Related.
Permissions in UNIX system
In UNIX, every file has three classes of permissions (user, group and others... | stackexchange_codegolf |
Use any programming language to generate two random digits between 1 and 9 (including both). Then your program should display:
in the first line: the first random digit,
in the second line: the second random digit,
in the third line: a number whose tens and units digits are the first and second random digits res... | stackexchange_codegolf |
Marching Squares is an algorithm from computer graphics, which is used to recover 2D isocontours from a grid of samples (see also, its big brother Marching Cubes for 3D settings). The idea is to process each cell of the grid independently, and determine the contours passing through that cell based on the values at its ... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Happy Hanukkah!
A beloved Hanukkah tradition for many, the game of Dreidel (s'vivon in Hebrew) is a betting game (for money or for chocolate gelt (coins)) centered on the titular spinning tops called dreidels. Dreidels have four sides:... | stackexchange_codegolf |
In 2009, Hannah Alpert described the "far-difference" representation, a novel way of representing integers as sums and differences of Fibonacci numbers according to the following rules:
every two terms of the same sign differ in index by at least 4, and
every two terms with different signs differ in index by at least ... | stackexchange_codegolf |
Inspiration
Conway's Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are:
Any live cell with 2 or 3 living neighbours (the 8 cells immediately aroun... | stackexchange_codegolf |
I came across an interesting tiling of the plane using squashed hexagons in a popular math book. All the six edges of the squashed hexagon are the same length. Two opposite corners are right angles and the rest four corners are 135 degrees each. This shape allows four squashed hexagons be arranged so that they meet at ... | stackexchange_codegolf |
Your task is to print this exact text:
z
yz
xyz
wxyz
vwxyz
uvwxyz
tuvwxyz
stuvwxyz
rstuvwxyz
qrstuvwxyz
pqrstuvwxyz
opqrstuvwxyz
nopqrstuvwxyz
mnopqrstuvwxyz
lmnopqrstuvwxyz
klmnopqrst... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
As we all know, Santa comes down the chimney to deliver presents to good kids. But chimneys are normally full of smoke, and the Elves are worried about Santa's health. So they decide to blow the smoke out using an electronic air blower... | stackexchange_codegolf |
Find a bijective function which maps integers to arbitrarily large tuples of integers. Given the input \$n\$, output the tuple it matches to.
Edit: The empty tuple is included in the mapping.
| stackexchange_codegolf |
Write a program that takes two integers as an input; the first can be any integer and the second is less than or equal to the number of digits in the first number. Let these numbers be a and b respectively.
The program will do the following
Concatenate a minimal number of 1s to the end of a so the number of digits in ... | stackexchange_codegolf |
Given two integer matrices a and b, your challenge is to replace any occurences of b in a with a matrix of the same size filled with 0s. For example:
Given:
a: [ [1, 2, 3],
[4, 3, 2],
[3, 5, 4] ]
b: [ [3],
[2] ]
b occurs once in a:
[ [1, 2, 3],
[4, 3, 2],
[3, 5, 4] ]
Fill that area with zeroes:
[ [1,... | stackexchange_codegolf |
In the popular (and essential) computer science book, An Introduction to Formal Languages and Automata by Peter Linz, the following formal language is frequently stated:
$$\large{L=\{a^n b^n:n\in\mathbb{Z}^+\}}$$
mainly because this language can not be processed with finite-state automata.
This expression mean "Languag... | stackexchange_codegolf |
disclaimer: the Mean mean is made up by me
Define the arithmetic mean of \$n\$ numbers as
$$M_1(x_1,...,x_n)=\frac{x_1+x_2+...+x_n}{n}$$
Define the geometric mean of \$n\$ numbers as
$$M_0(x_1,...,x_n)=\root{n}\of{x_1x_2...x_n}$$
Define the harmonic mean of \$n\$ numbers as
$$M_{-1}(x_1,...,x_n)=\frac{n}{\frac{1}{x_2} ... | stackexchange_codegolf |
In this challenge, Turing machines operate on a zero-initialized binary tape that is infinite in both directions.
You are given an integer \$N\$, where \$1 \le N \le 20000\$. Your program has to output a Turing machine that takes exactly \$N\$ steps to halt, including the final step. Alternatively, you can write a prog... | stackexchange_codegolf |
Write a program or function where a matrix A (maximum value of dimensions of the matrix is 100) is transformed to a new matrix B. Each element of the new matrix B is the sum of the positive neighbors of the corresponding element of the matrix A.
Only neighbors in the four orthogonal directions are considered, and the e... | stackexchange_codegolf |
Is there any javascript-like language? Something that can be interpreted by browsers?
| stackexchange_codegolf |
The Challenge
Given a string containing a random sequence of unique characters A to Z (all upper case, no duplicates), determine the cut-and-paste" sort and output the sort sequence to a specific format (detailed below).
Definition of Cut-And-Paste Sort, by Example
Example string:
AKJCFEGHDBI
This string contains 11 ch... | stackexchange_codegolf |
Inspired by one of many bugs I ran into while implementing selection sort in trilangle.
Given a non-empty list of non-negative integers, "sort" the list using the following procedure:
Find and output the smallest value in the list.
If the list only has one element, stop.
Recurse on a sublist:
If the last element in t... | 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 |
I often have to take character data and categorize it numerically at work. A common thing I do is to take character type variables and convert them to numeric type characters, keeping same categories according to the level of work I'm doing. (The longer the substring, the more in depth and specific, shorter substrings ... | stackexchange_codegolf |
(related)
Your challenge is to output the highest number you can. You can output as a number or as a string. You must output something that matches the regex ^\d+$, as in only 0-9.
The Twist
Your source code must be:
Same forwards and backwards
3 bytes long
The middle byte must be different from the other two
Exampl... | stackexchange_codegolf |
'---------'
'-'.repeat(9) // longer!
'------------'
(x='----')+x+x
'-'.repeat(12) // same length
Is there any cleverer way of generating strings of 12 repeated characters in JavaScript?
| stackexchange_codegolf |
We seem to never get tired of alphabet-related challenges...
The recipe
Given
a string of letters S, and
two positive integers M, N,
produce an alphabet soup with the letters of S occupying random positions in a rectangular bowl of size M×N, framed by a non-alphabetic, non-space character to represent the rim of the... | stackexchange_codegolf |
This is an endgame board of Settlers of Catan:
Background:
The roads (the long stick pieces) and the settlements (and cities) are rendered by the little huts. We encode the placement of these pieces by using the following scheme: From the top, we have a row horizontal vertices and edges where a road can be placed. The... | stackexchange_codegolf |
V1.1: Added criterion to help with tiebreakers, a bit overkill but still.
Task: Crack the scrambled code for calculating the argument of a complex number \$z=x+iy\$ given two inputs.
You must post a comment in the cops’ thread with a link to your working source, mentioning clearly that you have cracked it. In your ans... | stackexchange_codegolf |
Husk is a quite new golfing language, created by PPCG users Leo and Zgarb. It has begun being more and more competitive, often staying close or even beating languages known to be very terse, such as Jelly and 05AB1E.
Let's list some of the golfing techniques that are somewhat specific to Husk. As always, please post on... | stackexchange_codegolf |
How do I remove all duplicates from list and order it based on count?
s = ["foo", "this", "lem", "foo", "lem"]
s = ["foo", "ebh", "wosv", "wosv", "ebh", "4whcu"]
#should return
>>> ["foo", "lem", "this"]
>>> ["ebh", "wosv", "foo", "4whcu"]
Rules:
Must be shorter than the below code in terms of byte size.
Order must b... | stackexchange_codegolf |
Information
Create a diagonal line given its length (let’s call the variable, say, \$n\$ where \$n > 0\$)
The diagonal line starts from the top left and goes to the bottom right.
You must use the ASCII character \ for the line.
The input number can be given from STDIN or if your program doesn’t support that, use a har... | stackexchange_codegolf |
Output the provided table of English pronouns exactly, in as few bytes as possible.
Code rules
The code will take no input
The table is tab-delimited
Each line begins with a single tab \t if there is no row heading
Each line ends in a single newline \n (not \r\n), including the last line
There are four tabs between "P... | stackexchange_codegolf |
Inspired by this code review question, I am curious to see what happens if we turn that into a code-golf challenge!
The description is easy, the input is an array or any similar data structure with only unsigned integers, the output is a boolean if the number of odd numbers is equal to the number of even numbers inside... | stackexchange_codegolf |
Most computer keyboards feature a small integrated LED light,
indicating the current input mode, as controlled with the CAPS LOCK button.
Your task is to blink it:
Turn it on;
Wait for 0.5 (+/-0.1) seconds;
Turn it off again.
Video footage of the LED blinking is highly appreciated !
Rules
You can blink a different ... | 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 |
Robbers thread
Cops,
Choose two strings of code, one public and one secret. We will call them P and S. You will be writing a program using only repetitions of these strings.
For example: if you choose P=helloand S=world, valid programs would be hello, world, helloworld, worldhello, helloworldworldhello, hellohellohello... | stackexchange_codegolf |
Legendre's Conjecture is an unproven statement regarding the distribution of prime numbers; it asserts there is at least one prime number in the interval \$(n^2,(n+1)^2)\$ for all natural \$n\$.
The Challenge
Make a program which only halts if Legendre's conjecture is false. Equivalently, the program will halt if there... | stackexchange_codegolf |
Background
The Zundoko Kiyoshi function originates from this tweet by kumiromilk. Translated from Japanese, it reads roughly as follows:
The test for my Java lecture had a problem that said "Implement and describe your own function". I made it continuously output either "zun" or "doko" randomly; if the sequence "zun",... | stackexchange_codegolf |
A Fermi-Dirac Prime is a prime power of the form \$p^{2^k}\$, where \$p\$ is prime and \$k \geq 0\$, or in other words, a prime to the power of an integer power of two. They are listed as integer sequence A050376. While a normal prime factorization generally does not contain a set of distinct primes (for example \$24=2... | stackexchange_codegolf |
Background
A magic square is an n×n matrix consisting of one of each of the integers from \$1\$ to \$n^2\$ where every row, column, and diagonal sum to the same value. For example, a 3×3 magic square is as follows:
4 9 2
3 5 7
8 1 6
Here, each row, column, and diagonal sum to the magic sum of 15, which can be calculat... | stackexchange_codegolf |
Note: This challenge was inspired by Joe Z's many excellent questions surrounding NAND golfing.
Description
Your goal in this challenge, should you choose to accept it, is to implement a very simple ALU using just NAND gates. The ALU can only perform the the following four operations:
00, meaning increment (wrapping a... | stackexchange_codegolf |
The Secretary Problem is a famous problem described as thus:
You need a new secretary
You have N applicants that you can interview one at a time
You are able to score each applicant after the interview. Your scoring system will never give two applicants the same score
After you interview an applicant, you must give a... | stackexchange_codegolf |
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 ... | stackexchange_codegolf |
Challenge
This is a simple one: Given a positive integer up to 1,000,000, return the closest prime number.
If the number itself is prime, then you should return that number; if there are two primes equally close to the provided number, return the lower of the two.
Input is in the form of a single integer, and output sh... | stackexchange_codegolf |
Background
The computer game NetHack dates from 1987, before the use of graphics in computer games was widely established. There are lots of monsters in the game, and potentially a lot need to fit on screen at once, so monsters are drawn in a very minimal way: a monster is simply drawn as an ASCII character on screen.
... | stackexchange_codegolf |
Given an integer, output an upside-down tent.
The input determines both the size of the tent (absolute value) and whether the entrance is on the left side (negative numbers) or the right side (positive numbers).
If input = -1:
____
\/_/
If input = -2:
________
\ / /
\/___/
If input = -3:
____________
\ / /... | stackexchange_codegolf |
Challenge
I'm under attack by the larcenous Midnight Crew and I need to summon the Catenative Doomsday Dice Cascader in order to defend myself. Since I'm low on space, I need the code to be as short as possible.
The algorithm for the Catenative Doomsday Dice Cascader is as follows:
First, the six sided die in the Prime... | stackexchange_codegolf |
“Cut” a matrix of integers on the line where the sum of the absolute differences of “severed” neighbors is the least.
Example
Consider this matrix:
1 2 -4
5 -1 3
2 -2 0
It can be cut in 4 places, here shown by lines lettered A–D:
A B
╷ ╷
1 ╎ 2 ╎ -4
C ---╎----╎----
5 ╎ -1 ╎ 3
D ---╎----╎--... | stackexchange_codegolf |
For reference as to what the tower of Hanoi is, either Google it or look on the Wikipedia page.
Your code should be able to do 2 things, and they are the following:
Accept user input that specifies the number of discs at the starting point of the Hanoi tower
Create output in a fashion of your choosing (so long as it i... | stackexchange_codegolf |
Yet another blatant rip-off of a rip-off of a rip-off. Go upvote those!
Your task, if you wish to accept it, is to write a program/function that outputs/returns its string input/argument. The tricky part is that if I reverse your source code, the output must be reversed too.
For simplicity, you can assume that the inpu... | stackexchange_codegolf |
The challenge
Find the smallest feedforward neural network such that, given any 3-dimensional input vector \$(a,b,c)\$ with integer entries in \$[-10,10]\$, the network outputs the largest (i.e., "most positive") root of the polynomial \$x^3+ax^2+bx+c\$ with error strictly smaller than \$0.1\$.
Admissibility
The notion... | stackexchange_codegolf |
I've always wanted to surround some text with #s, but I have trouble figuring out what I surrounded so in this challenge you'll be writing a program to do just that
Examples
Input / Outputs are separated by a newline.
###
#a#
###
a
#
#a#
#
a
###
# a #
# b c #
#######
a
b c
ABCDHIJ
E####GK
F# M #L
# ... | stackexchange_codegolf |
I see from this SMBC comic that Zach Weinersmith is offering a generous 14 points to anybody who can find a way of generating the following series:
0, 1, 4, -13, -133, 52, 53, -155
Now, we all know that there are infinite ways of generating any given numeric series, so Zach is clearly just giving those points away. Bu... | 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 goal is to create a generator generator [...] generator generator comprehension.
The generator must be created via generator comprehension.
The following expression must be valid for any number of nestings: next(next(next(next(next(generator))))).
The winner is whoever achieves this with the fewest number of byte... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.