instruction stringlengths 34 53.1k |
|---|
This code-golf challenge will give you an integer n, and ask you to count the number of positive integer sequences \$S = (a_1, a_2, \dots, a_t)\$ such that
\$a_1 + a_2 + \cdots + a_t = n\$, and
\$\displaystyle
\sqrt{a_1+\sqrt{a_2 + \cdots + \stackrel{\vdots}{\sqrt{a_t}}}}
\$ is an integer.
Example
If n = 14, then the... |
We can read 13576870234289 digit-by-digit in English, and it makes a haiku:
one three five seven
six eight seven zero two
three four two eight nine
We say it's a "digit haiku", because when read out like this, it's 5+7+5 syllables long, and no word is broken across a line.
For example, 111171111101111 is not a digit ... |
Context
In APL, trains are tacit sequences of monadic/dyadic functions that can be called with one or two arguments. We'll code something to check if a given train follows the correct structure we need in order to have a sound train.
Task
Given the sequence of function arities in the train, determine if the train is va... |
Somehow, we don't yet have a challenge for finding the inverse of an arbitrarily-sized square matrix, despite having ones for 3x3 and 4x4, as well as a more complex version.
Your task is, given a square \$n\times n\$ non-singular matrix \$M\$, output the matrix \$M^{-1}\$ that satisfies
$$MM^{-1} = I_n$$
There are a nu... |
Inspired by this challenge, which got closed. This is meant to be an easier, but no less interesting version of that.
This is the cops thread of a cops-and-robbers challenge. For the robbers thread, see here.
Cops will provide a program/function and a flag. Robbers will try to guess a password such that, when the passw... |
Inspired by this challenge, which got closed. This is meant to be an easier, but no less interesting version of that.
This is the robbers thread of a cops-and-robbers challenge. For the cops thread, see here.
Cops will provide a program/function and a flag. Robbers will guess a password. When the password is given to t... |
Inspired in part by this
Mathologer video on gorgeous visual "shrink" proofs, and my general interest in the topic, this challenge will have you count regular polygons with integer coordinates in 3D.
You'll be provided an input n, which is a non-negative integer. Your program should find the number of subsets of \$\{0,... |
Introduction
We have 22 Collatz conjecture-related challenges as of October 2020, but none of which cares about the restrictions on counter-examples, if any exists, to the conjecture.
Considering a variant of the operation defined in the conjecture:
$$f(x)=
\cases{
\frac{x}{2}&for even x \cr
\frac{3x+1}{2}&for odd x
}... |
Background
The systematic chemical symbol is defined as such for \$ 118 < n < 1000 \$:
The first letter corresponds to the first digit, capitalized.
The second letter corresponds to the second digit.
The third letter corresponds to the third digit.
This can be generalized for all \$ n > 0\$:
For each digit, get the ... |
Note: SmokeDetector is a bot that detects spam and offensive posts on the network and posts alerts to chat.
What to implement
Smokey's !!/alive command uniformly at random picks one of these messages:
Yup
You doubt me?
Of course
... did I miss something?
plz send teh coffee
Watching this endless list of new question... |
The task is to find the smallest paper size on which it is possible to print a picture of the dimensions given in milimetres. The image will be printed without margins.
Input:
Two integers (bigger than zero) and a letter a, b, or c, for example:
290
200
A
Output:
Paper size, for example:
A4
Another examples:
218,297... |
Like the previous SmokeDetector challenge? This one is for you too ;)
Note: SmokeDetector is a bot that detects spam and offensive posts on the network and posts alerts to chat.
What to implement
Smokey's !!/coffee command uniformly at random picks one of these words (sorts of coffee):
Espresso
Macchiato
Ristretto
A... |
Your task is to write a program which implements a bijection \$\mathbb{N}^n\to\mathbb{N}\$ for \$n \ge 1\$. Your program should take \$n\$ natural numbers as input, in any acceptable method (including taking them as a single, \$n\$ element list/array) and output a unique natural number for all possible inputs.
In layma... |
This problem is based on non-terminating, repeating decimal points.
Let \$n\$ be any positive integer \$(n > 1 \text{ and } n < 10000)\$, say \$7\$. Then, \$1/n = 1/7 = 0.142857142857142857...\$
We see a pattern like, 0. 142857 142857 142857 ...
In this, the 142857 part is always repeating, which has length of \$6\$. ... |
(This challenge exists to extend sequence A276272 in the On-Line Encyclopedia of Integer Sequences, and perhaps create a new OEIS sequence1.)
This is a code-challenge, which will have you write code to compute as many terms of this sequence as possible.
Background
A polytet is a kind of polyform which is construct... |
It's election time, and your job is to beat your competitor in a head-on rivalry! You are both trying to win over a city of 256 people in a 16x16 grid. Right now, the city hasn't been divided into voting regions yet, but that's where your gerrymandering skills come in! You can also campaign in arbitrary areas of the ci... |
(The word frame in the following text does not mean an actual frame, it is used as a placeholder for an undefined time unit)
The task
Imagine you have a keyboard layout with only letters like so:
q w e r t y u i o p
a s d f g h j k l
z x c v b n m
Whenever you press a key, for example f, the keyboard lights up the ... |
using Prefixed Length Code
We are going to implement a compression of text (string, array/list of characters/bytes) by simple substitution of each character by a binary code, based on the frequency of that character in the text. The characters that occur more frequently will be replaced by shorter codes. The resulting ... |
Introduction
In Tennis, the server alternates serving on the left side or the right side of the court every point, starting on the right. It is possible to figure out which side to serve on for that point just based on the score; if there have been an even number of points you serve on the right, and after an odd numbe... |
History
There's a room on StackOverflow in Russian where you can see such an interesting discussion:
Just because there are not enough real discussing in that room, @Grundy "plays ping-pong" to keep it unfrozen.
Task
Implement a bot for StackExchange that posts "ping!" to the 115624 room if the previous message was ... |
You'll get a human-readable question matching one of the following syntaxes, and are expected to print/return the corresponding result. Finding similarities between the human-readable inputs and matching them with minimum size code is explicitly part of the task, so I won't give a formal definition.
"Will October begi... |
What is the Fibonacci Rectangular Prism Sequence?
The Fibonacci Rectangular Prism Sequence is a sequence derived from the Fibonacci sequence starting with one. The first 3 numbers of the Fibonacci sequence (starting with one) are 1, 1, and 2, so the first number of the Fibonacci Rectangular Prism Sequence is the square... |
Because the coronavirus is still at large, I thought it would be fitting to have a epidemic-themed challenge.
Challenge
You are given a 2D array of people, where 1 represents someone with the virus, and 0 represents someone without the virus. Every day, the people with the virus infect their neighbours. You must calcul... |
Bi-directional translator
The challenge is to create a translator that can translate a [a-zA-Z ] string into another string according to the mappings below. The translator should also be able to translate translated text back into its normal form (hence bi-directional). Case doesn't have to be maintained and can be eit... |
It is possible (Wikipedia reference) to compute the square root of any number in a digit by digit fashion using a simple (I had learned it in primary school) algorithm.
Challenge:
read a positive integer from the user, in base 10, no error check;
compute the square root of that integer using a digit-by-digit algorithm... |
Let's consider the sequence \$S\$ consisting of one \$1\$ and one \$0\$, followed by two \$1\$'s and two \$0\$'s, and so on:
$$1,0,1,1,0,0,1,1,1,0,0,0,1,1,1,1,0,0,0,0,...$$
(This is A118175: Binary representation of n-th iteration of the Rule 220 elementary cellular automaton starting with a single black cell.)
Given \... |
Inspiration
Given a positive integer \$1 \le n \le 9\$, output all positive \$n\$-digit integers \$i\$ for which the following is true:
Each digit from \$1\$ to \$n\$ appears exactly once in \$i\$. Therefore, \$i\$'s digits are a permutation of the digits from \$1\$ to \$n\$.
\$i\$ is divisible by \$n\$
Removing the r... |
This problem is based on, A337517, the most recent OEIS sequence with the keyword "nice".
\$a(n)\$ is the number of distinct resistances that can be produced from a circuit with exactly \$n\$ unit resistors.
The sequence begins 1, 2, 4, 9, 23, 57, 151, 427, 1263, 3823, 11724, 36048, 110953, 342079.
The goal of this c... |
Challenge:
The challenge is to determine whether or not a color, given it's name, is one of the colors in the rainbow.
When supplied with a color, your program should output a truthy value if it is a color in the rainbow, and a falsy one otherwise.
Rules:
The possible input options are exhaustive, and defined in the t... |
Edit 2020-11-06: This challenge has been edited with new provisions to encourage participation. The edits have been bolded for emphasis.
Welcome to a cops and robbers version of Find an Illegal String.
An illegal string is "a string of characters that cannot appear in any legal program in your programming language of... |
This is the robbers' thread for 'Almost Illegal Strings'.
See the cop's thread for information on participating. A section from the post is included here for convenience.
The Robbers' Challenge
Find an uncracked answer. Write a program in the language specified that contains as a contiguous substring the almost illega... |
Write the shortest possible code cause an error due to recursion too deep
Example error in python
RecursionError: maximum recursion depth exceeded
Example error in c
Segmentation fault
My Python version (15 bytes):
def f():f()
f()
|
Had my software final exams recently, one of the last questions had me thinking for a while after the exam had finished.
Background
IEEE754 numbers are according to the below layout
The exponent is stored as n + 127 so for an exponent of 20 the exponent in binary would be:
127 + 20 = 147 then
10010011
The Challange
Wr... |
In the US, clothing size sometimes has rough designations like M, L, XXL, etc. The US designation of the "men's jacket" category depends on the height of the person. So, in this challenge, you should implement this conversion, which is defined by the following table, taken from this site:
US size Body height (cm)
XXXS... |
A narcissistic number is a natural number which is equal to the sum of its digits when each digit is taken to the power of the number digits. For example \$8208 = 8^4 + 2^4 + 0^4 + 8^4\$, so is narcissistic.
We'll define a function \$f(x)\$ as the following, for a natural number \$x = d_1d_2\dots d_n\$, where \$d_i\$ i... |
Background
Wuxings(五行) are the five "elements" in Chinese philosophy. They are Fire(火), Water(水), Wood(木), Metal(金), and Soil(土). You can find them on East Asian calendar, where some days (Tuesday through Saturday) are named by the Wuxings.
Some Korean names are given according to Wuxings, so that father's name will ha... |
In an attempt to “liberate” their fellow birds, a group of highly intelligent hens are
attempting to compromise the zoo’s security system. To get access to the zoo’s mainframe,
the hens first need to guess the administrative password. The hens know that the password
is a string built from up to 62 possible characters: ... |
Magic the gathering has many unique names for colour combinations in decks, as an example when Blue and White appear together in a deck, the deck maye sometimes be named after the Ravnican Guild that features those colours, namely 'Azorius'. There are some exceptions, and oddities though.
Below is a list of colour lett... |
With the US election going on right now, I noticed that there is one (completely meaningless, but still) thing which Trump can still achieve and which is out of reach for Biden: Having the won states being connected.
Task: Given a list of strings of two-letter abbreviations (see below) for US states, determine whether ... |
Let's solve this user's homework; I think it's an interesting exercise!
Input
Two 3-digit natural numbers.
Outputs
Two 2-digit numbers. In each of the output numbers, one digit is taken from one input number, and the other from the other number. The choice is independent. The first output number should be the minimal p... |
Perhaps something like this is here already, but I couldn't find it.
It is not the same as Aligning Lines!.
Example:
Input:
98.6
$2,750.17
-$23
-86
3,120,487.19
Output:
98.6
$2,750.17
-$23
-86
3,120,487.19
Note that .6 isn't right-padded to .60 or .6 .
Input:
A list/array of strings (or lines fr... |
We do seem to have a fastest square root challenge, but it's very restrictive. In this challenge, your program (or function) will be given an arbitrarily sized nonnegative integer, which is the square of an integer.
Input
You may take input in any normally allowed way, including (but not limited to) an arbitrary sized ... |
This is a relatively simple question. I'm trying to golf a Snake game I've written, and I'm trying to work out if there's a way to golf the following conditional assignments which control x and y coordinates of the snake ensuring a wrap around of the play area:
if (P<0) {
P = T-1;
}
if (P>T-1) {
P = 0;
}
if (Q<0) {... |
I have a problem, which I haven't found a solution for. Solutions to the first part are well documented, but I have yet to find anyone who has solved the second part. I call this the "Dobble" challenge...
Challenge 1
Using the numbers 1 - 57, populate 57 arrays. Each array must have 8 numbers in it, with no duplicates.... |
\$723 = 3 \times 241\$ is a semi-prime (the product of two primes) whose prime factors include all digits from \$1\$ to \$n\$, where \$n\$ is the total number of digits between them. Another way to look at this is that the (sorted) digits in the factorisation of \$723\$ are all consecutive. The first 10 such semi-prime... |
This challenge is about the following variant of edit distance. Say we have a cost of 1 for inserts, deletes and substitutions as usual with one exception. A substitution for a given letter x for a letter y only costs 1 the first time. Any further substitutions of x for y cost 0.
As simple examples:
A = apppple
B = a... |
We all know scoring by characters is ripe for abuse. Let's prove this.
The Challenge
Output the following:
"m8V}G=D@7G1lAI,v08`
#(hNb0A8T!g;==SVaG5~
g"jUF!bmRY(3I@na?2S{
fJVzo/GQYU%ybpfUq3aG
Yza[jc,WJ$bP^7r};Da}
V-!Z+Nk:`/poc}d/X:G\
sWX{dbAUv6,i]%RG$hRp
),bd+?/{U1tU[;<;u.Nk
ZFPIOzJ/HimL!nexc,ls
HM%k3D$n2|R,8L?'eI_n
qs.... |
Fizz Buzz is a common challenge given during interviews. The challenge goes something like this:
Write a program that prints the numbers from 1 to n. If a number is
divisible by 3, write Fizz instead. If a number is divisible by 5,
write Buzz instead. However, if the number is divisible by both 3 and
5, write FizzBuzz... |
TLDR: Sort your input according to a new English alphabet somewhat based on Chinese stroke count methods.
Background: In a Chinese glossary/index, finding terms that are contained within the book is different from English because Chinese doesn't have an alphabet like English, instead they are sorted by stroke count. (一... |
A centered polygonal number is a positive integer given by the number of vertices when a point is surrounded by (increasingly larger) polygons with the same number of sides, as shown below. For example, \$p_5(3) = 1 + 5 + 10 + 15 = 31\$ is a centered pentagonal number formed by taking a vertex and adding three layers o... |
I saw a problem which asks you to print "Hello World" using the fewest characters, including spaces. How can I further shorten this code? Thank you in advance!
#include<iostream>
int main(){printf("Hello World");}
|
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... |
When studying numerology, you can say two words (strings consisting entirely of letters) are compatible if they produce the same number under the following operation (let's use the string hello as an example):
Map each letter to a number according to the following, ignoring case:
1 2 3 4 5 6 7 8 9
a b c d e f g h i
j ... |
Your task is to take \$n \ge 2\$ points in 3D space, represented as 3 floating point values, and output the Euclidean distance between the two closest points. For example
$$A = (0, 0, 0) \\ B = (1, 1, 1) \\ C = (4, 0, 2)$$
would output \$\sqrt3 = 1.7320508075688772...\$, the distance between \$A\$ and \$B\$.
The Euclid... |
Here's an easy one, with just enough complexity to make golfing non-trivial.
Input
A list of non-negative numbers representing people waiting in line for Thanksgiving dessert. The first (leftmost) number is first in line, and the list can contain repeats (think of each number as a person's first name):
Note: Pie not... |
The challenge given to me is comparatively easy, and specific to MySQL only. I'm given a table expressions which have mathematical calculations done by a kid. Basically, I've to select all the right calculations!
The table have the following properties,
a : an integer, the left operand.
b : an integer, the right opera... |
Here's a simple challenge, so hopefully lots of languages will be able to participate.
Given a positive integer \$n\$, output \$A076039(n)\$ from the OEIS.
That is, start with \$a(1)=1\$. Then for \$n>1\$:
$$a(n)=\left\{ \begin{array}{ll} n\cdot a(n-1), & \text{if } n>a(n-1) \\ \lfloor a(n-1)/n \rfloor, & \text{otherw... |
NPM's sloc is a moderately popular tool for counting source lines of code in a file. The tool will attempt to strip out both single and multiline comments and count the remaining lines in order to get an estimate of the 'true' number of lines of code.
However, the parser used is based on regular expressions and is quit... |
It is quite simple, any language, make output show the time in the HH:MM or HH:MM:SS while the numbers and the colons being ascii art(The output is ascii art not the program)
Sample output:
____________ ________ _____ .________ ________
/_ \_____ \ /\ \_____ \ / | | /\ | ____// _____/
| ... |
I have been going to puzzling.se, and people over there write stuff in rot13 a lot, sot this gave me an idea:
Write a program that takes 2 inputs, a string and integer:
the message to encode or decode
how far to shift
You can input in a function call, and output in any legal way
twist:
it must work with any printable... |
Introduction
This challenge appeared in the 2020 Estonian Open Informatics Olympiad and was created Sandra Schumann. I thought it was interesting because it involves symmetry and is quite hard even to brute force by hand.
The problem author said that it's ok for me to post it here:
Challenge
You may use a modified vers... |
Background:
A sequence of infinite naturals is a sequence that contains every natural number infinitely many times.
To clarify, every number must be printed multiple times!
The Challenge:
Output a sequence of infinite naturals with the shortest code.
Rules:
Each number must be separated by a (finite) amount of visible... |
Negadecimal, also known as base -10, is a non-standard positional numeral system.
Take the number \$1337_{10}\$. In decimal, this has the value one thousand three hundred thirty seven, and can be expanded to:
$$1\cdot10^3+3\cdot10^2+3\cdot10^1+7\cdot10^0$$
$$(1000)+(300)+(30)+(7)$$
In negadecimal, instead of \$10^n\$, ... |
Given a positive integer number \$n\$ output its perfect radical.
Definition
A perfect radical \$r\$ of a positive integer \$n\$ is the lowest integer root of \$n\$ of any index \$i\$:
$$r = \sqrt[i]{n}$$
where \$r\$ is an integer.
In other words \$i\$ is the maximum exponent such that \$r\$ raised to \$i\$ is \$n\$:
$... |
As of 27/12/20, the challenge is over as no new answers were posted on the 26th. With an astounding 55 points (and 21 answers), the winner is pppery!
A quick shout out to the top 5 scorers as well:
1st. pppery with 55 points across 21 answers
2nd. tsh with 50 points across 21 answers
3rd. SunnyMoon with 21 points acr... |
This code golf challenge is about making a rocket liftoff sequence.
Your output (STDOUT) should be equal to this:
Liftoff in T-10
Liftoff in T-9
Liftoff in T-8
Liftoff in T-7
Liftoff in T-6
Liftoff in T-5
Liftoff in T-4
Liftoff in T-3
Liftoff in T-2
Liftoff in T-1
LIFTOFF!
Rules:
Your output must print to STDOUT.
Yo... |
Given a non negative integer number \$n\$ output how many steps to reach zero using radicals, divisions or subtractions.
The algorithm
Get digits count ( \$d\$ ) of \$n\$.
Try the following operations in order:
$$\sqrt[d]{n}$$
$$n/d$$
$$n-d$$
Take the first integer result not equal to \$n\$.
Floating point errors ... |
We're getting markdown tables! I assume this is what they look like:
data
data data data
---------------------
| |
| |
| |
| |
Your task is to make a program or function to generate one of these tables. You'll be given input (string, list of ... |
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... |
Prompt:
You are given two sets of XY coordinates along with two angles (all are floats): X1 Y1 A1 X2 Y2 A2. The angles are relative to world coordinates: 0 being straight up or north and going clockwise.
Your program or function has to return a set of two floats of the XY coordinates the two angles cross at.
Example:
... |
Today, my girlfriend and I started with this year's Advent of Code to improve our Python. So far we only did Day 1 and the first part of Day 2. The latter, I found to be very fun, so, to spice it up a little, and with a tip o' the head to Eric Wastl, here's my attempt at turning it into a Code Golf challenge.
Task
Your... |
The Problem:
You receive a (section of) a Conway's Game of Life grid. Your task is to output whether it represents a still-life (subsequent generations are identical to the current grid), a oscillator of period up to 4 (every nth generation is identical to the current grid), or something else.
The remainder of the inf... |
I'm new to code golf challenges. My problem came up in Advent of Code 2020 Day 8
The input is an array of arrays. In part two of the problem one needs to run several trials to produce a result by changing an element in the input array. My current code is this (comments added to explain what's going on):
p input.each_wi... |
You have been hired by the American embassy in the UK to act as a translator. Being a programmer, you decide to write a program to do a bit of the work for you.
You've found out that often just doing the following things can satisfy Word's spellcheck, which has been set to "English (United States)", somewhat, so you do... |
The input:
As an example, take a list containing a number of bits (in this case, 32):
11000010000100111011000011001011
We can calculate a simple checksum of this data by dividing it into evenly sized blocks, and taking the XOR of each of them. For example, with eight bit blocks:
11000010
00010011
10110000
11001011
10... |
SE Sandbox Link, Codidact Sandbox Link
Inspired by this video.
Given a positive integer, draw its Cistercian representation as ascii art.
The Challenge
Cistercian numerals are a decimal-based number representation system which use simple line based drawings to represent 4-digit numerals. Their structure is as follows:... |
For this challenge, a linked list looks like this:
[1, 2, 4, 0, 6, 1, 3, 1]
You'll notice there's no data; each item in the list is just a reference to the index of the next one. Your task is to write a program or function which will follow a linked list like this forever, outputting each item as it is encountered. Fo... |
Background
In X11 (a windowing system used by a lot of Unix-like OS), what you would call the clipboard behave a bit differently than on other OSes like MacOS or Windows. While the "traditional" clipboard using ctrl+v/ctrl+c works, there is also another clipboard, called PRIMARY selection, that behave as following:
wh... |
When learning to factorise quadratics in the form \$x^2 + ax + b\$, a common technique is to find two numbers, \$p, q\$ such that
$$pq = b \\
p + q = a$$
as, for such numbers, \$x^2 + ax + b = (x + p)(x + q)\$
You are to take two integers \$a, b \in (-\infty, +\infty)\$ and output the two integers \$p, q\$ such that
$$... |
Scramble a Megaminx!
A megaminx is a dodecahedral version of the familiar Rubik's cube. Since 2008, the World Cube Association uses Stefan Pochmann's megaminx scrambler. The scrambles look like this:
R-- D++ R++ D-- R++ D-- R++ D++ R-- D-- U'
R++ D-- R++ D-- R-- D++ R-- D-- R-- D-- U'
R++ D++ R-- D++ R++ D++ R++ D++ R-... |
Input
A string S of length between 2 and 30. The only letters in the string will be a or b.
Output
All strings within Levenshtein distance 2 of S. You must output all the strings without duplicates but in any order you like.
Example
If S = aaa then the output would be (in any order):
aa
abab
ab
aabba
aaaa
abaa
bbaaa
ab... |
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... |
Inspired by this stack of little statues that are currently on my desk at work, given to me by my colleagues from Sri Lanka when they visited The Netherlands:
This is split into two different challenges due to popular demand:
Part 1) Determine the amount of statues
Part 2) Can the statues be stacked? (this challenge)
... |
This challenge is inspired by the AoC 2020, Day 14 - Part II, created by Eric Wastl and his team, which asks to output the possible binary values from a bitmask.
Let's say we've a bitmask like "10X0X0", then we've to find the possible binary values that can be generated by replacing an X with either 0 or 1. Here I've t... |
Inspired by this stack of little statues that are currently on my desk at work, given to me by my colleagues from Sri Lanka when they visited The Netherlands:
This is split into two different challenges due to popular demand:
Part 1) Determine the amount of statues (this challenge)
Part 2) Can the statues be stacked?
... |
You know how many and which kinds of chess pieces were murdered. Can you come up with any possibility for who killed whom and how?
Background
During the course of a game of chess, there are between 2 and 32 pieces on the board. Call the collection of all pieces on the board (both white and black), without regard to p... |
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 ... |
in my country we have a children's song which goes like this:
Priletela muha na zid, muha na zid, muha na zid.
Priletela muha na zid,
muha na zid.
Pralatala maha na zad, maha na zad, maha na zad.
Pralatala maha na zad,
maha na zad.
Preletele mehe ne zed, mehe ne zed, mehe ne zed.
Preletele mehe ne zed,
mehe ne zed.
... |
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... |
Your task is to write a program or function. Its output/return value must follow these rules:
The program outputs 1
The program repeated n times outputs n
The program backwards outputs -1
The program backwards and repeated n times outputs -n
A mix of forward and backward programs will output number_forward - number_ba... |
Ken Iverson, 1920–2020
Let's implement his favourite expression:
Given a row of Pascal's triangle, compute the next row.
This can for example be computed by taking the input padded with a zero on the left, and the input padded with a zero on the right, and then adding the two element-by-element.
Test cases... |
Inspired by what I'm doing at work right now.
Your program should take one parameter, the path to the file
It should convert all the windows style newlines (\r\n) to unix style (\n) and write the result back to the file
|
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.
|
I will preface this by saying that I made this for fun; I have absolutely no formal knowledge on cryptography or error correction. Do not use this algorithm in anything remotely important.
I was kind of bored a few days ago, so I decided to write a simple function to take some data and return an easily memorable (but n... |
It's a well-known fact that Fermat's Last Theorem is true. More specifically, that for any integer \$n \gt 2\$, there are no three integers \$a, b, c\$ such that
$$a^n + b^n = c^n$$
However, there are a number of near misses. For example,
$$6^3 + 8^3 = 9^3 - 1$$
We'll call a triple of integers \$(a, b, c)\$ a "Fermat n... |
The Animal-Alphabetical Sequence is an infinite string of letters built accordingly to the following procedure:
Start with the letter A;
Replace each letter with the name of the animal starting with such letter in the table below;
Go back to step 2.
For instance, the first four steps of the procedure give:
A
ADD... |
Create the shortest function, program, or expression that calculates a sequence of squarefree palindromic numbers.
A squarefree number is one which is not evenly divisible by a square number (i.e. does not contain a repeated prime factor). For example, \$44 = 2^2 \times 11\$ is not squarefree, whereas \$66 = 2\times3\t... |
Challenge:
Find the number of ways to climb some stairs with n steps and with some limitations. You should be able to run the tests below on TIO https://tio.run/ without timing out. – 60 seconds. (Typically a fraction of a second is well within reach for most languages if a good optimizing strategy is applied).
The in... |
A newspaper is made of several sheets; for the purposes of this question, each sheet of newsprint holds four pages of the final newspaper. Here is an example of three sheets of newsprint making up a newspaper with twelve pages:
___________
|2 | 11|
| ___|_____|_
| |4 | 9|
|_| ___|_____|_
| |6 | 7|... |
The Challenge
Given a list of integers, the "bittiest" number among them is the one with the most bits on - that is, the largest amount of bits set to 1 in its 32-bit two's complement representation.
Write a function (or a program) that takes as input a list of integers between \$ -2^{31} \$ and \$ 2^{31}-1 \$ (the ran... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.