instruction stringlengths 34 53.1k |
|---|
You are to accept, on standard input, one number. You will then output the negation of that number. Your code will do nothing else. You may accept various formats if you wish (like "one" or ("uno+2.4e10i"). You may also output it how ever you wish. Note that these formats mush have existed somewhere on the internet bef... |
Your goal is to print (to the standard output) the largest number possible, using just ten characters of code.
You may use any features of your language, except built-in exponentiation functions.
Similarly, you may not use scientific notation to enter a number. (Thus, no 9e+99.)
The program must print the number wit... |
Introduction
After a day of drinking and watching the world cup, you sit down to play friendly game of boggle. Tempers rise as you are accused of wasting everyone's time with nonsense words that aren't even on the board! You may be seeing double, but surely you're thinking straight enough to write a program that will v... |
At Hackerrank.com, the love letter mystery is a simple programming problem, which I already solved.
My solution involved calculating the palindrome and counting the number of operations to do it. On Hackerrank, they have another approach, which I don't understand completely:
Given a string, you have to convert it int... |
The mission is to implement a cat-like program (copy all STDIN to STDOUT).
Rules:
You may only use standard libraries
Indentation must be either two spaces or a single tab (in languages which require indentation)
Scripts must use shebangs
The result of cat anything.txt | ./yourprogram | diff anything.txt - should be ... |
Write a program that encodes given text into its own text, provided as input, without disrupting its logic. The program must also work as a decoder, restoring the original message from its text. It must retain its encoding/decoding functions after transformation.
More formally speaking, the required program P must perf... |
Write a program which, given two positive integers n and x, will display the n-th root of x (which is also x1/n) in decimal to an accuracy of 0.00001. The program must output the resulting number in decimal, and it must work for any two numbers n and x. The variables may be defined in the program, or they may be inputt... |
Two prime numbers are defined as twin primes if they differ by two. For example, 3 and 5 are twin primes as are 29 and 31.
Write a program that finds the nth pair of twin primes (where n comes from STDIN) and prints them on STDOUT, separated by a comma and a space. This is code-golf, so the shortest code wins.
Sample i... |
Write a recursive function/program, to calculate either the Factorial or the Fibonacci number of a given non-negative integer, without explicitly implementing the base case(s).
Your program/function must return/output the correct value in a reasonable time.
You cannot
Use if statement anywhere in your program/function... |
As a little joke in the office someone wanted a script that randomly picks a name, and said person will make a round of drinks.
Let's call the people John, Jeff, Emma, Steve and Julie.
I thought it would be funny to make a script that seems random at a quick glance, but actually always gives the same person as the out... |
You are given, as a list or vector or whatever, a bunch of 3-tuples or whatever, where the first two things are strings, and the third thing is a number. The strings are cities, and the number is the distance between them. The order of the cities in the tuple is arbitrary (i.e. it doesn't matter which comes first and ... |
I could only find code-golf challenges for Mastermind, so here's a code-challenge version that I would have liked to take on myself.
An optimal strategy for the normal Mastermind game, MM(4,6), was found by Koyama and Lai in 1993, having an average # of guesses = 5625/1296 ~ 4.34. MM(5,8) is still unsolved, but is esti... |
I love programming and know every language, but I suck at math. Unfortunately, my school requires that computers students must take a year of calculus. There's a test next week, and I don't know any of the formulas for derivatives!
Please help me find the formulas. I need a cheat sheet - a program (as short as possible... |
When a number is shown on a calculator, it's possible to consider what various transformations of that number would look like. For example, on a seven-segment display, 2 is shown like this:
And when flipped horizontally it looks like this:
As such, the mirror image of 2 is 5.
The task in this challenge is to take a s... |
Your task is to calculate the square root of 2 using Newton's Method - with a slight twist. Your program is to calculate an iteration using Newton's Method, and output the source code for the following iteration (which must be able to do the same).
Newton's method is fairly exhaustively described on Wikipedia
To calcul... |
Introduction
You have recently accepted a job offer at a Pretty Good Software Company. You're pretty content with the size of your office, but do you have the biggest office? Its kinda hard to tell from just eyeballing your co-workers' offices when you stop by. The only way to figure this out is to examine the blueprin... |
It's been a rough few months at work and I feel like I just want to scream right to my boss' face. I am, however, not one to directly confront people I have a problem with. I also don't want to lose my job.
So here's an idea: I want to be able to insult him, without him ever finding out. And I realized the perfect way:... |
I'm not to sure about the title so feel free to suggest a better one.
Task/challenge
Create an overview for the World Cup tracking the cup from the group phase till the finals.
Group phase
There are 8 groups (Group A, B, C, .., H) which can be found >> here <<
Each group has 4 teams/countries.
There will be 6 matches... |
This question is inspired by the game Disco Zoo
Background
Disco Zoo is a game where you can go into the wild and rescue animals. Once you have found an animal you can put it in your zoo for your visitors to see.
To find animals you first select a field to search, and you get to see a 5x5 grid where the animals are hid... |
Summary
The task is to navigate the Mars rover and tell its final coordinates and direction.
Input:
First input:
First your program must take the input which will be in the following format:
[X-Coordinate],[Y-Coordinate],[Direction]
The direction must be: N or S or E or W (Starting letters of North, South, West, East)... |
Imagine bytes in memory for an RGB image--R and G and B represented by bytes in sequence. If an image is NxM then the memory layout will be M repetitions for vertical scanlines of 3*N bytes in sequence for the horizontal pixels. (As one might expect.)
A mandate has come down from on high that you need to be able to i... |
Calculate n modulo 12 for an unsigned 32 bit integer.
The Rules:
Must work for all n between 0 and 23. Other numbers optional.
Must only use any of the operators +-*, ~&^| or <<, >> as commonly defined on 32 bit uints.
May use arbitrary number of constant uints.
May not use any form of pointers, including arrays, or ... |
Input: you are given 2 integers, n and k. n is a positive (>= 1) integer, and k an integer, which is the number of times you are allowed to use n.
Output: output all of the non-negative integers that can be formed using at most k n's using these mathematical operations: +, -, *, /, and parentheses.
Edit: if your lang... |
The scenario
You live in a country that is having a presidential election. Each voter gets one vote, and therefore there is a firmly-entrenched two-party system. (Third parties exist, but get hardly any votes).
The latest opinion poll shows the race in a dead heat:
49%: Alberto Arbusto
49%: Jorge Sangre
2%: various ... |
for loops are useful in python in many ways, but one of the most common usages associated with a for loop is it's ability to repeat a certain amount of times. Like this:
for times in range(50):
print "I'm repeating this 50 times..."
The challenge I propose to you is to make a for repeat forever. If you can find a ... |
Your challenge is to create a clock that displays the time as a hex number, and the background color as the hex color code of the time.
Requirements: No input. In the center of your output you should display the number sign and the current time in 24 hour format as "#hhmmss". The program should update to the current t... |
I really hate looking up to the top right of the screen to look at the time on OS X's clock widget; I'd much rather keep my eyes at least somewhere near my workspace to check the time. I also hate other people using my clock to check the time as they walk by -- after all, it's called a personal computer, right? But we'... |
Winner: professorfish's bash answer! An entire 9 bytes! Wow!
You may continue to submit your answer, however you can no longer win. Original post kept for posterity:
Your goal is to convert a whole number between 1-9 into the word it represents.
You will not need to worry about decimals
The user will input a number. ... |
Let's discover1 some bugs...
Write the shortest complete program possible that, when run on a stable release of an implementation of a language, demonstrates a bug in that implementation. Please specify which release and platform was used. This is code golf, so the shortest code (in bytes) wins.
An implementation bug ... |
Make a function that increments a number using only bitwise, loops, and conditions.
Rules:
All entries must be as per the language spec defined below.
Scoring is not of code length, but of the points for each operation given below.
The entry point is inc(a), for "increment and return a".
Lowest score wins.
See the e... |
Represent poker cards as numbers from 0 to 51. 0 to 12 - all hearts from 2 to Ace, 13 to 25 all diamonds and so on.
Your goal is to write a function for each poker hand type which generates a random 7-card hand (as in Texas Holdem on the river), in which the best 5-card combination is of the target type. The output is ... |
This is one of my favourite poems I wanted to share. Especially because it looks good for compressing. Who cares about literature in the 21st century anyway.
Goal
Your goal is to write the shortest program possible that prints out the following poem: http://pastebin.com/aXV0C515
Rules
The HQ9Monkey++ language is prohi... |
You need to find the sum of minimum values of two list (same size) of small numbers. In a C like language, that could be expressed as:
v = min(a[0],b[0]) + min(a[1],b[1])+ min(a[2],b[2]) ...
The range of values is 0..7 and the 2 list can have up to 7 values. If you like, all the values in each list can be stored as a s... |
You've been hired to write some code for a dictation-taking app, which takes voice input from a spoken source, parses it as words, and writes it down on a screen.
The management doesn't really trust you with all that much powerin the project—you're known to sit around and golf code all day instead of doing your work, u... |
Write a function (or macro) that returns true if and only if at least one of its arguments contains a call to the function itself and false otherwise.
For example:
int a=function(); //a==false
int b=function(0); //b==false
int c=function(function(0)); //c==true
int d=function(3*function(1)+2); //d==true (weakly-typed l... |
Your goal is to determine if a number is divisible by 3 without using conditionals.
The input will be an unsigned 8 bit number from 0 to 255. Creativity encouraged!
You are ONLY allowed to use
Equality/Inequality (==, !=, >, <, >=, <=)
Arithmetic (+, -, x)
Logical Operators (! not, && and, || or)
Bitwise Operators ... |
Winner: Aditsu's CJam answer! A whopping 25 bytes! Nice!
You may continue to submit your answer, however you can no longer win. Original post kept for posterity:
The "Bzzt" game is a game where you must count to a number (in this case 500). However, if the number has a 3 in it, or is divisible by 3, you don't say the ... |
fastest relay time = lowest possible total integer value of
(a freestyle swimmers time) + (1 breastroke swimmers time) + (another backstroke swimmers time) + (another butterfly swimmers time)
Each swimmer must be unique to the relay (no duplicates)
Each stroke must be used once
Input Data: array of dictionaries, wh... |
The type 4 GUID is described by Wikipedia, quoth:
Version 4 UUIDs use a scheme relying only on random numbers. This algorithm sets the version number (4 bits) as well as two reserved bits. All other bits (the remaining 122 bits) are set using a random or pseudorandom data source. Version 4 UUIDs have the form xxxxxxxx... |
Write a program that takes R, G, and B values as command arguments and then displays that color some way. It doesn't matter how, as long as at least 100 pixels have the color. Shortest code wins.
|
The goal is to write a function or program which takes a set of integer arrays and returns a set of all possible arrays which meet the following criteria:
A valid array must contain at least one number from each of the input arrays.
A valid array cannot contain more than one number from a single input array.
A valid a... |
Short and sweet description of the challenge:
Based off the ideas of several other questions on this site, your challenge is to write the most creative code in any program that takes as input a number written out in English and converts it to integer form.
Really dry, long and thorough specifications:
Your program wil... |
Let's play some code golf!
Given a tic-tac-toe board state (Example:)
|x|x|o|
|x|o|x|
|o|o|x|
Determine whether a game is a win a lose or cat. Your code should output any of these options given a state. The above game should output lose
Just to be clear: a win is defined as any 3 xs in a row (diagonal, horizontal, ver... |
Given three number values - being the Red, Green, and Blue elements of a colour (eight bits per channel, 0 to 255) - your program must output the name of the given colour.
For example;
Input: 255, 0, 0
Output: Red
or;
Input: 80, 0, 0
Output: Dark Red
This is a popularity contest, so whichever answer has the most... |
You're a programmer. You always work everyday and don't have time with your lover.
One day, your lover was so angry with you that they cursed you into an ogre! Your fingers have grown big, and you can't type as before. And of course only your lover can lift your curse , but you only have 3 days! So, you decided to wri... |
So you are tasked with creating an open source password authentication system but you want to reveal as little about the implementation of the hash function as possible. Can you write a function that takes in a password string and a salt string and outputs a salted hash string without revealing the hashing function?
En... |
Write a program to find a number consisting of 9 digits in which each of the digits from 1 to 9 appears only once. This number must also satisfy these divisibility requirements:
The number should be divisible by 9.
If the rightmost digit is
removed, the remaining number should be divisible by 8.
If the
rightmost dig... |
Introduction
Consider the following example:
CODE
+ GOLF
——————
GREAT
This is an equation where each letter represents a decimal digit and the words represent natural numbers (similar letters represent similar digits and different letters represent different digits). The task is to match each letter with its digit ... |
This time around your goal is to find the maximum of 3 integers (from -(2^31) to 2^31 - 1 in binary 2's complement) without using branching or loops.
You are only allowed to use
Inequality/Equality (==, >, >=, <, <=, !=) These count as 2 tokens.
Arithmetic (+, -, *, /)
Logical Operators (! not, && and, || or)
Bitwi... |
Given a grid which contains these signs: 0..9, x, =, write the fastest code that outputs the longest string of connected (horizontally, vertically, and diagonally adjacent), distinct cells which is a mathematically valid expression formed on this grammar:
E := T '=' T
T := F 'x' T | F
F -> {0..9}+
More formally, a so... |
In investing, internal rate of return (IRR), the continuously compounded rate of return economically equivalent to a specified series of cashflows, is often a valuable concept.
Your challenge is to demonstrate how to compute IRR in the language of your choice in as few bytes as possible, subject to the following condit... |
Assume we have a string, and we want to find the maximum repeated sequence of every letter.
For example, given the sample input:
"acbaabbbaaaaacc"
Output for the sample input can be:
a=5
c=2
b=3
Rules:
Your code can be function or a program - for you to choose
Input can be by stdin, file or function parameter
The ou... |
Write a program that takes a binary tree as input, and outputs the deepest node and its depth. If there is a tie, print all involved nodes as well as their depths. Each node is represented as:
T(x,x)
T(x)
T
where T is the identifier of one or more alphanumeric characters and each x is another node.
Here's a simple defi... |
Description
Given a source path and a destination path, output the relative path to the destination with respect to the source.
Rules
The input can come from stdin or as arguments to the program/function.
Both Windows and Unix style paths must be supported.
The output path can use / and/or \ for the path separator (y... |
The challenge
The goal of this challenge is to create a chatbot that can run in the chatrooms of Stack Exchange. Your bot needs to be able to detect when specific commands are posted by a user and respond to it. This is the list of commands, and what your bot should do:
!!newest: output the title (no link, but the tit... |
The task is to find the number of characters in your source code up to the previous line.
You may do some addition of two integers, or whatever that comes to mind. But at the end of your logic, you need to calculate the number of characters written in your code up to the last line.
EDIT:
The goal is to find the number ... |
User CarpetPython posted a new take on this problem which puts a much bigger focus on heuristic solutions, due to an increased search space. I personally think that challenge is much nicer than mine, so consider giving that one a try!
Vector racing is an addictive game that can be played with a pen and a sheet of squ... |
Introduction
You're playing a matching game, in which coins are inserted at the top and fall to the bottom (onto the top coin) due to gravity.
So this
O <- inserting this coin
OO O
OOOOO
will become this
O
OO O
OOOOO
Now imagine someone rotates the board clockwise. The following will happen:
1. The board is rotated
... |
You dudes, the Most Excellent Adventure is a home brew roleplaying game system based on the Bill & Ted Films, plays gnarly air guitar riff.
In this game system, when you draw from your dice pool (you have between 1 and 12 ten-sided dice, with faces labelled 0-9) you need to connect the results as a phone number on you... |
Here's a simple one.
In the shortest code possible, given an arbitrary number such as 567421, print it out in words:
five
six
seven
four
two
one
You may assume the input is an integer that is already provided in a one-letter variable such as n.
|
As you know, the World Cup group stage is over, and from tomorrow the best 16 teams will commence the knockout stage:
Brazil (BRA)
Mexico (MEX)
Netherlands (NED)
Chile (CHI)
Colombia (COL)
Greece (GRE)
Costa Rica (CRC)
Uruguay (URU)
France (FRA)
Switzerland (SUI)
Argentina (ARG)
Nigeria (NGA)
Germany (GER)
United Stat... |
Write the shortest possible program that turns a binary search tree into an ordered doubly-linked list, by modifying the pointers to the left and the right children of each node.
Arguments: a pointer to the root of the binary tree.
Return value: a pointer to the head of the linked list.
The binary tree node has three f... |
This is a simple encryption method that uses PI digits to encode a message, the method is simple:
The key is just a positive integer that indicates where the window starts then:
Given a string to encrypt, containing only lowercase letters, no spaces, you take its length, then you find the Nth digit of PI and then proce... |
Write a program, in the language of your choice, that appears to successfully find a counterexample to Fermat's Last Theorem. That is, find integers a, b, c > 0 and n > 2 such that an + bn = cn.
Of course, you can't really do it, unless there's a flaw in Andrew Wiles' proof. I mean fake it, by relying on
integer ove... |
Short and sweet description of the challenge:
Based off ETAOIN SHRDLU, your challenge is to write the shortest program or function in any language that outputs the 26 letters of the English alphabet based on their frequency in the input.
Really long, dry and thorough specification:
Your program/function will receive a... |
The Scenario
You are a taxi driver in your city. You picked up a passenger from the airport and he told you the place he'd like to go.
To earn more money, you need to drive as much as you can. However, there are two problems:
He always looks around. Therefore, you cannot pass from the same district twice.
The passenge... |
AlienWar
This game takes place in a very crowded planet where aliens are the superior race. Your task is to create your own alien and beat all other.
The Board
It is a 2 dimensional board.
The length of one side of the board is Math.ceil(sqrt(species * 100 * 2.5)) = ~40% of board used.
The board is a planet, so if you ... |
What general tips do you have for golfing in T-SQL? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to T-SQL. Please post one tip per answer.
Thanks to Marcog for the original idea. :)
|
An airlines company has several planes of the same type.Each plane has a seating capacity of 24 X 3 rows and 8 seats in each row split has shown.
1 [a] [b] [c] [d] [e] [f] [g] [h]
2 [a] [b] [c] [d] [e] [f] [g] [h]
3 [a] [b] [c] [d] [e] [f] [g] [h]
If 4 people book-allocate 4 seats in middle row.Else 2 on the right ... |
Your task is to calculate the total number of key-presses required to enter a given text on an old cellphone.
The keymaps are:
1:1
2:abcABC2
3:defDEF3
4:ghiGHI4
5:jklJKL5
6:mnoMNO6
7:pqrsPQRS7
8:tuvTUV8
9:wxyzWXYZ9
0:<space><newline>0
To type exaMPle TExt 01 , you would press 33 99 2 6666 77777 555 33 0 8888 33333 99 ... |
Challenge
Detect the newest file in a specific folder and pass it as an argument to another process. The first argument to your program will be the folder, and the second argument will be the full path to the process.
Please specify the platform(s) your code works on.
Examples
Windows
newestfile "C:\Public_domain_movie... |
Given an input of a 2 dimensional array of integers, rotate the array 90 degrees clockwise.
It should work for rectangular arrays of all sizes and proportions.
The rotated array should be printed at the end of the program.
Example:
Input:
[[0,1,2,3,4,5],
[6,7,8,9,0,1],
[2,3,4,5,6,7],
[8,9,0,1,2,3]]
Output:
[[8,2... |
The objective of this question is to create a program that pushes your computer's internal fan speed to its maximum RPM. Upon exiting the program, your fan should return to the normal operating RPM.
Rules:
You may not perform a CPU intensive task in order to modify the
fan's speed.
Exiting the program may be via user... |
The Gray Code is a sequence of binary numbers of bitwidth n where successive numbers differ only in one bit (see example output).
Reference
Example input:
3
Example output:
000
001
011
010
110
111
101
100
Notes:
This question seems to have a dupe but it's not, for that question is not a code-golf, and it demands dif... |
Your goal is to determine whether a given 2D point X lies within the area of the triangle with given vertices A,B,C.
Write a function that takes in the coordinates of the test point X and the three triangle vertices (so that's 8 coordinates total) and returns True if the point lies inside that triangle, and False if it... |
Write a program that translates ASCII text to braille output. Requirements:
Input may come from stdin, command line, or some other external input source.
Output should be recognisable as braille, the form of output is up to you. An example would be o for a raised dot and . for a non-raised dot. Textual pattern represe... |
Two random numbers A and B have been generated to be either 1, 2, or 3
your job is to randomly pick a third number C that can also be 1, 2 or 3. But, C cannot equal A or B.
A can equal B.
If A = B, then C has only two numbers left it can be.
If A ≠ B, C has only one number it can be.
Assume A and B have already been c... |
Let's try to golf this piece of ascii-art representing a golfing man:
'\ . . |>18>>
\ . ' . |
O>> . 'o |
\ . |
/\ .... |
You are to make a program that can check the syntax of programs of its same language. For example, if you do it in python, it checks python syntax. Your program will receive a program on standard input, and verify whether or not its syntax is correct. If it is correct, output just "true" on standard output. If not, out... |
Almost every language has a built-in function that can split a string at a given position. However, as soon as you have html tags in the string, the built-in function will not work properly.
Your task is to write a program or function which splits a string at the nth character but does not count characters of html tags... |
I wrote some perl to sort by debian package version number (specification here). Whilst readable, it was disappointingly long (114 lines, 2042 characters) - shocking. So this challenge is to produce the shortest program (in perl or otherwise) which takes debian package version numbers on STDIN separated by \n, sorts th... |
Write a program in brainfuck that accepts input of 4 ASCII characters as numbers (from 32 to 126) and outputs the numbers or ASCII equivalent sorted in ascending order.
Requirements: Your program should prompt the user for 4 characters that will be sorted by their ASCII value. All the inputs will be distinct. Any sort... |
Aww, man, this expiry date doesn't write the months with letters! I can't tell if it's expiring on March 10th or October 3rd... Wait, no, never mind, the year says 2012. (alley-oops half-used brick of cheese into the trash can like a pro)
So let's suppose for a moment that you're too busy to try to reason out when this... |
I have come across an article where students used network traffic to draw their university on the country's IPv6 graph. [image]
Your goal is simple to tell, but hard to implement. Draw the text MAIL (as it is one of the few words that can be read on a 1D graph) on the CPU graph.
It should look something like this:
E... |
preface
In a very heated situation you have to go even further with golfing.
(e.g. in a challenge where your answer is 100 characters long and it is just embarrassing that you couldn't make it 99)
In that case, from now on you use the winner's algorithm of this challenge :)
goal
You have to write a program that takes ... |
The challenge is to write a fake infinite loop in any imperative programming language.
At first sight, the code should seem not to halt at all.
As a naive example:
int f(int x)
{
return f(4.0);
}
int f(double x)
{
return 0;
}
But remember
You're not allowed to use overflows:
int f(int x)
{
if(x < 0) retur... |
Your challenge is to write a program which will output a non-context-free language.
A Context-free Grammar is a series of replacement rules, describing which symbols can be replaced by which other symbols. It defines set of strings, known as a language, which is generated by performing all possible replacement rules on... |
Today's Daily WTF quotes the following line of code...
FailSafe==0?'No technical alarms':((FailSafe&1)!=0&&(FailSafe&2)!=0&&(FailSafe&4)!=0&&(FailSafe&8)!=0?'Detection zones staying in a given state; Bad visibility;
Initialization; Bad configuration':((FailSafe&1)!=0&&(FailSafe&2)!=0&&(FailSafe&4)!=0?'Detection zones s... |
Results - July 19, 2014
The current King of the Hill is Mercenary by user Fabigler! Keep submitting entries and knock him off of his throne!
Click here to view the Scoreboard.
Programs submitted on or before July 19, 2014 were included. All other submissions will be included in future trials. New results should be post... |
Challenge:
In the last stage of a two players Texas hold 'em, given a two-card hand and five cards on table, determine your probability to win versus an opponent by the standard ranking of poker hands.
Input:
Seven cards (sdtin or arguments). The first two cards are your hand while the last five are on the table. Each ... |
The title says it all. Your goal is to write a program that forms a w×h rectangle of characters that can be rotated and re-run to output the number of 90° Counter-Clockwise (CCW) rotations that have been done.
For example, if the 3×2 program
abc
def
solved the problem, it would initially output 0, and successive rotat... |
You are given two true color images, the Source and the Palette. They do not necessarily have the same dimensions but it is guaranteed that their areas are the same, i.e. they have the same number of pixels.
Your task is to create an algorithm that makes the most accurate looking copy of the Source by only using the pi... |
You have a library - a fully loaded 2014 Babylon.js.
You have a fragment shader - let's call it sample.fragment.fx.
You have a scene - loaded ahead of time, possibly from a .babylon JSON file.
Your goal is to assign the fragment shader to every textured object in the scene using a snippet of JavaScript or TypeScript co... |
I'm solving task, where:
Input:
A number as an integer.
Output:
The closest greater palindromic prime as an integer.
I would appreciate hints how to make my solution shorter. Or directions if change of approach would be beneficial.
golf=lambda l,r=range:next(x for x in r(10**6)if(x==int(`x`[::-1]))&all(x%d for d in r(2... |
A question similar to this has been asked a couple of years ago, but this one is even trickier.
The challenge is simple. Write a program (in your language of choice) that repeatedly executes code without using any repetition structures such as while, for, do while, foreach or goto (So for all you nitpickers, you can't... |
I want to compactly code positive integers x into bits, in a manner allowing decoding back into the original integers for a stateless decoder knowing the maximum value m of each x; it shall be possible to uniquely decode the concatenation of encodings, as is the case in Huffman coding.
[The above introduction motivates... |
Using the fewest Unicode characters, write a function that accepts three parameters:
Total number of dominoes
nth affected domino
Topple direction of the affected domino (0 or L for left, 1 or R for right)
Once a domino is toppled, it must also topple the remaining dominoes in the same direction.
You should output th... |
People sometimes make spelling eorrors. A lto. Your challenge is to write a program that can take a string with certain spelling errors, such as the switching of I and E, and correct those mistakes. This has to be able to make changes to any combination of characters in any string, and fix the spelling errors. This is ... |
Problem
I've got a GREAT new program that will change the way we think about math in computing, taking in strings of algebraic functions and doing AMAZING things with them! The only problem, is that I am only able to parse specific algebra, otherwise the universe folds into itself, which is bad. Fortunately, I only nee... |
There are a lot of challenges on this site regarding pi, but none that challenge you to calculate as many digits of pi as possible.
As you all may know, pi in its decimal form goes on for infinity, so calculating it in its entirety is near to impossible. However, I challenge you to write a program in your language of c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.