instruction stringlengths 34 53.1k |
|---|
Write a program that takes an input to STDIN and makes all of the lowercase letters (including accented letters) in the 2k-1th word uppercase and all the uppercase letters (also including accented letters) in the 2kth word lowercase (k is a positive integer). The program should not affect any other characters in any wo... |
Challenge
Your goal is to write a program which will output the 8 measurements of a rectangle, with only some measurements in the input. Your program should throw an error if it cant be done.
Here is what each measurement means:
| left
| | centerX
| | | right
| | ... |
I have read: Tips for golfing in Python
I would like to golf this code further. Any more tips?
x,y,q,w=[int(i) for i in raw_input().split()]
while 1:
a=int(input())
s=d=""
if q>x:
s="W"
q-=1
elif q<x:
s="E"
q+=1
if w>y:
d="N"
w-=1
elif w<y:
d="S"
w+=1
print d+s
The program:
You move on a map whi... |
Your task is to create a program that prints "Greetings, Planet!" exactly to the console. Seems simple enough, right? Well, here's the trick. The code must be a palindrome, meaning it reads from right to left the same as in left to right.
Standard loopholes are NOT allowed.
|
You have a number of polynomials who are lonely, so make them some companions (who won’t threaten to stab)!
For a polynomial of degree n, there is an n by n companion cube matrix for it. You need to make a function that accepts a list of coefficients for a polynomial in either ascending (a + bx +cx^2 + …) or descendin... |
Introduction
Suppose for a moment that the vipers and cliff are only two steps away, instead of three.
o
---
Hsss! |
';;' ___ /_\ ___ _
|
You are, unfortunately, a captive of a sadistic torturer. You must take a step either to the left or to the right every turn. ... |
Given a string consisting of printable ASCII chars, produce an output consisting of its unique chars in the original order. In other words, the output is the same as the input except that a char is removed if it has appeared previously.
No built-ins for finding unique elements in an array can be used (for example, MATL... |
Python's pickle module is used for serialisation, allowing one to dump an object in a way such that it can be later reconstructed. For this, pickle uses a simple stack-based language.
To keep things simple, we will be dealing with a small subset of this language:
( Push a mark to the stack
S'abc'\n P... |
I need to light some candles. In fact, I need to light an arbitrary amount of candles. But only the good ones.
OBJECTIVE Given a block of text (containing lit, valid, and invalid candles) and a number N as input, write a program or function that lights an amount exactly equal to N, minus the number of already-lit cand... |
In public-key cryptography, a public key fingerprint is a short sequence of bytes used to identify a longer public key.
In SSH in particular they can be used to verify that a server is in fact the server I'm expecting to communicate with and I'm not targeted by a man-in-the-middle attack.
They are usually represente... |
It's my 17th birthday and you're invited to my party!
And as always at parties, there will be cake.
One cake...
And you need as much of it as possible.
As this is a fair party, each of us will say how much of my cake we want and the person who said the smallest amount will get it. Then everyone else gets to repeat the... |
dog is a command-line utility that takes in an arbitrary number of arguments,
the first of which is the text to be written and the others are arbitrarily many files.
The dog utility will split the text in equal portions over these files. If there is a remainder n, the first n files get an additional byte
dog is the opp... |
Well, the librarian caught you cheating at your job by using your sorting algorithm, so now you're being punished. You've been ordered to create some code so the librarian can impress the object of their unrequited affection, the math teacher. So that's what "Other duties as assigned" means ...
Everyone is familiar wit... |
Challenge
Peter has risen again to save us from the duplicate challenges!
Peter Taylor is dead, and there's no doubt about it (well, apart from the huge amount of doubt we have... but just ignore that). In his memory, you must write a program which determines whether a given user is alive or dead.
Further Information
A... |
NB : Everything presented in the situation is totally fake and had just been put here to make the challenge a little more fun ;) ... Or maybe not ;)
=== === BEGINNING TRANSMISSION === ===
Hello,
I recently had a disk failure. I hopefully had backups and I now want my photos back. However, EVERY backup looks corrupted ... |
You are a web developer, and your boss has decided to update the company's website. He has decided that less color is better, but he wants the site to look the same. You justly decide that he has no idea what he's talking about, but you're going to try anyway, because you're bored. Since the company has thousands of we... |
Consider the following process:
Take some non-negative integer N.
e.g. N = 571
Express it in binary with no leading zeroes. (Zero itself is the only exception, becoming 0.)
e.g. 571 = 1000111011 in binary
Break apart consecutive runs of ones and zeroes in this binary representation.
e.g. 1000111011 → 1, 000, 111, 0,... |
Your task is to create an interpreter for a calculator. It has to parse commands like 5 + 5 and return the answer.
It has to be able to add, subtract, multiply, and divide. The interpreter only needs to accept two numbers (ex. 9 * 5 and 3 + 3)
The interpreter will take input from a console/whatever, not a file.
Eval is... |
Background
A few months ago, the adventure of your life was just about to start. Now, in this precise moment (yeah, now), after months of suffering and hard work, you and a group of friends are standing on the top of the world. Yes, you are right, you are on the summit of Sagarmāthā.
However, things aren't going as wel... |
It is a dry summer in the prairie. The four farmers in the area realize that they can corner the market on corn by burning their neighbors crops. But they need a strategy for doing so; that is where you come in.
Your task is to write a bot to tell the farmers what to burn. The goal is to finish the game with the larges... |
Quines have been around forever. It's a fun challenge: write a program that, when executed, generates its own source code as output. But how do you know it's actually producing its own source code? Generally, you have to look at it and compare it, but with quines generally being composed of tricky and intricate code... |
For golfing practice, I have been doing the assignments in my girlfriend's Intro to Python class. I found that for this assignment, there were multiple strategies that came very close in character count, and I'm sure people here can find even better ways. Although I am most interested in ways to do this in Python, I wo... |
Monday Mini-Golf: A series of short code-golf challenges, posted (hopefully!) every Monday.
(Sorry this one's a little late.)
I'm sure most of you folks have heard of Levenshtein distance, an algorithm for calculating the distance between two strings. Well, this challenge is about implementing a similar algorithm of my... |
Write a function which takes in a list of positive integers and returns a list of integers approximating the percent of total for the corresponding integer in the same position.
All integers in the return list must exactly add up to 100. You can assume the sum of integers passed in is greater than 0. How you want to r... |
This reminds me when a few years ago someone uploaded a torrent "Hacker tool: complete list of all IP addresses". This was, of course, just a generated list of the ~4 billion IPv4 addresses, but thousands of "h4xx0rz" downloaded it. Look mum, imahacker!
This was then, but nowadays everybody has switched to IPv6. (Rig... |
Have you ever wanted to ask the compiler "Why?" Most of us have been frustrated when the code isn't working as it should. Mathworks has therefore implemented a nice little function, why, that answers the question. To give a few examples from MATLAB:
why
The programmer suggested it.
why
To fool the tall good and smart ... |
I like to do programming challenges in my free time to teach myself and keep fresh, this one I can't seem to optimize though and it's driving me insane.
The goal is essentially, "Given a number, return the numbers leading up to it as a palindrome."
For example if you are given the input 5 the answer your program should... |
Background
A polyomino is called L-convex, if it's possible to travel from any tile to any other tile by an L-shaped path, that is, a path that goes in the cardinal directions and changes direction at most once.
For example, the polyomino of 1s in the figure
0 0 1 1 1 0
1 1 1 1 0 0
1 1 0 0 0 0
is not L-convex, since... |
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.
... |
Simply put, your goal is to create a complete program that modifies its own source code until every character of the source is different than what it started as.
Please include the beginning source as well as the ending source in your post, as well as a description. E.g. Describe what (else) your program does, the lang... |
mbomb007 asked us to make a self mutilating program. Its an interesting challenge, but I personally don't like to encourage my programs to be self-mutilating. I like to think that, at the heart of every program is a beautiful butterfly waiting to break out.
As such, for my first ever Code Golf challenge, I challenge ... |
Intro
In Objective-C (a superset of C and an object-oriented language), I can create an object called a UIWebView. There is a method for this object called loadHTMLString: in which I can load actual HTML into the UIWebView object itself. I can also inject Javascript into it using the method stringByEvaluatingJavaScript... |
Take a look at this chamomile flower:
Pretty, isn't it? Well, what if I told you that this wasn't actually one flower?
A lot of flowers (including sunflowers, chamomiles, daisies and others) actually consist of many very small flowers (the black dots on sunflowers) on a flower head. These miniature flowers are called ... |
QWERTY keyboard distance (QKD) is, in short, the distance between two letters/numbers/punctuation keys on a standard QWERTY keyboard (if you don't have one around, you can check this Wikipedia picture). Note that only characters without modifiers be considered for this challenge (so ; is valid, but ) is not).
Some exa... |
Challenge
Given a positive integer N that is 28 or above, output a list of numbers summing to N that uses each digit 1 through 7 exactly once. You can give as a program or function.
The digits can appear by themselves or concatenated, as long as you use each of them once without repeats. For example,[12, 34, 56, 7] is ... |
The program has an input of a and b, and outputs the sum of numbers from a to b, inclusive. Score is in bytes. As always, standard loopholes are disallowed.
If your input is in the format [a,b], +3 bytes
|
RTTTL, or Ring Tone Text Transfer Language is a music format that was invented by Nokia in the dawn of time when dinosaurs roamed the land. It allows for fairly crude pieces of music (no chords or anything), and the format is pretty simple which is why I think it's pretty cool. Take a look at this one:
DejaVu: d=8,o=5,... |
So, you're browsing Programming Puzzles & Code Golf, and you see a new challenge. The author (gasp) forgot to say "No standard Loopholes". You decide to take advantage of this situation, and you read the answer from a file/network. However, you need to make sure that your answer is actually shorter than the legitimate ... |
Let's say you've got a table of data:
meter_id date 0000 0600 1200 1800
0 030915 10 20 30 40
1 030915 15 7 49 2
where the last four columns are meter readings at different times. You want to output
meter_id date time reading
0 030915 0000 10
0 030915 0600 20
etc.
Your inpu... |
Background
The echo program is so neat. You can say anything to it, and it repeats your words perfectly, every time! How cool is that! Disappointingly, it repeats the input all at once, regardless of your typing speed, which is not very realistic. We'll have to fix that.
The Task
Your program shall take its input from ... |
Martin has created a nice snippet that can be used to keep track of the score for answers to challenges. That's great and all, but wouldn't it be better if you could keep track of it yourself?
Create a program that compares the byte counts in itself with the rest of the answers to this question, and returns "I'm answer... |
IUPAC in their insufferable wisdom have created a systematic element name for any newly created element. This is the temporary name of an element until they finally make up their minds about an actual name. It works like so: each digit of an element number is assigned a prefix based on its value. The prefixes are conca... |
In this challenge, you will be given the source code of a Java program. Your task is to write a function or full program that will remove the whitespace from this program. The whitespace-removed program should work exactly the same as the original program. Your program can be in any language. In this challenge, every s... |
In Python it is often necessary to use str.replace(a,b), however .replace is rather long and feels unnecessary. So is there a shorter alternative to str.replace.
Alternatively is there a similar trick to how you can use r=range for golfing for str.replace?
Example code for golfing
m=input()
f="hello"
print m.replace('t... |
Here goes a quick proof by Alan Turing that there is no program H that can solve the halting problem. If there was, you could make a program X such that X(n) = if H(n,n) == Halt then output X(n) else output ":-)". What is the value of H(X,X)?
Your job is to make a partial halting solver, such that when some X of your c... |
According to the Wikipedia page on the number 69, it is of note that \$69^2 = 4761\$ and \$69^3 = 328509\$ together use all decimal digits. The number 69 is in fact the lowest number that satisfies this property.
For a similar reason, \$32043\$ is remarkable: \$32043^2 = 1026753849\$ uses all decimal digits.
If we're g... |
Background
Last time, we counted groups of a given size, which is a non-trivial problem.
This time, we'll only count Abelian groups, i.e., groups with a commutative operation. Formally, a group (G, ∗) is Abelian if x ∗ y = y ∗ x for for all x, y in G.
The problem becomes much simpler this way, so we're going to count t... |
I created a programming language for manipulating strings called Stringy. It's very different from other programming languages, since you only have one string (for manipulation) and some variables. With the various commands you can manipulate that one string. I created it because it might be useful for some challenges ... |
Ulam's spiral is a truly fascinating, yet puzzling, topic in mathematics. How it works in detail can be found here, but a short summary can be explained as so:
I start off by writing a one, then I write a two to the right of it. Above the two, I write a three, and to the left of that I write four. I continue this patte... |
Everyone knows that the news is boring. Really boring. Unless if it's about Politicians and their scandals. That is fun! But alas, Politicians can commit only so many scandals. So, I am employing you to make the news more interesting.
Objective Given an HTML snippet, perform all the substitutions found here, that is, i... |
The robbers thread can be found here: The Mystery String Printer (Robbers)
Your challenge
Write a program, function, or REPL script that prints a string to STDOUT.
The robbers will try to create a program that prints the same string.
If they successfully can create the program within 7 days, your submission is cracked... |
The cops thread can be found here: The Mystery String Printer (Cops)
Your challenge
Choose a submission from the cops thread, and print out the string from an answer in that thread.
The submission that you choose must not be safe (it must be newer than 7 days).
Your program, function, or REPL script needs to follow th... |
The challenge involves printing the difference between ICMP originate and receive timestamps.
The idea is being able to determine which asymmetric internet path is responsible for packet delay.
One can use hping with --icmp-ts option to gain the raw data on ICMP_TSTAMP. The task is complicated by the fact that hping d... |
Portable Spec.
Iɴꜱᴘɪʀᴇᴅ ʙʏ @ConorO'Brien's ᴜꜱᴇʀɴᴀᴍᴇ.
Aʟꜱᴏ ᴛʜᴀɴᴋꜱ ᴛᴏ @Dᴏᴏʀᴋɴᴏʙ ꜰᴏʀ ꜱʜᴏᴡɪɴɢ ᴍᴇ ᴛʜᴇ ᴇxɪꜱᴛᴇɴᴄᴇ ᴏꜰ ǫ ᴀɴᴅ x.
Sᴍᴀʟʟ Cᴀᴘꜱ ᴀʀᴇ ᴘʀᴇᴛᴛʏ ᴄᴏᴏʟ. Tʜᴇʏ ᴀʀᴇ ᴜɴɪᴄᴏᴅᴇ ᴄʜᴀʀᴀᴄᴛᴇʀꜱ ᴛʜᴀᴛ ʀᴇᴘʟᴀᴄᴇ ꜱᴍᴀʟʟ ʟᴇᴛᴛᴇʀꜱ. Tʜᴇʏ ʟᴏᴏᴋ ᴊᴜꜱᴛ ʟɪᴋᴇ ᴛʜᴇ ᴄᴀᴘɪᴛᴀʟ ᴏɴᴇꜱ, ʙᴜᴛ ꜱᴍᴀʟʟᴇʀ, ᴀɴᴅ ʟᴏᴏᴋ ʀᴇᴀʟʟʏ ᴏꜰꜰɪᴄɪᴀʟ. Yᴏᴜʀ ᴛᴀꜱᴋ ɪꜱ ᴛᴏ ᴡʀɪᴛᴇ ᴀ ᴘʀᴏɢʀᴀᴍ ᴛʜᴀᴛ ᴄᴏɴ... |
Create program that counts the total number of letters common to two names, and finds the product of their lengths, to function as a "love tester."
Conditions: you may not get a 1:1 answer (being 3 out of 3, etc.) output.
Input
Two names from STDIN or closest alternative.
Output
Compute x as the total number of letters... |
Write a program that takes as input a string and an integer n, and outputs:
The string that was passed to the program n times ago;
A new program that will be used for the next invocation.
You cannot store any data outside of the program, and your program cannot call previous programs in the chain. If the string does ... |
Your boss just emailed you a list of 12 programming tasks he needs done as soon as possible. The tasks are simple enough but your boss, being a young software tycoon suckled by social networking, insists that your solutions be able to fit within a single Twitter tweet.
This means that you only have 140 bytes worth of c... |
Inspired by this badly received migrated post.
The head of security at your company is concerned about your PIN generating system after it gave him 12345. He also didn't really appreciate the Spaceballs joke you made at his expense, so you've been delegated to re-write the PIN generator. Since it has to fit on some spe... |
Story, or why we are doing this.
None. This exercise is completely pointless ... unless you are Stephen Hawking.
The Challenge
Given a list of angles, find the average of those angles. For example the average of 91 degrees and -91 degrees is 180 degrees. You can use a program or function to do this.
Input
A list of deg... |
My school has its Homecoming dance next week, and there's someone in mind I want to ask. But I don't want to ask her the normal way. I want to send her a program that prints "Rachel, will you go to Homecoming with me?" However, if I just send her print"Rachel, will you go to Homecoming with me?", it'll be way too obvio... |
What makes the ideal question? Perhaps it is merely the abstraction of a profound thought and the initialization of a dream, a hope, a thought, a (… 5,024.2 characters omitted). Therefore, I propose that we find such a factor to quantify questions. I propose also that this factor be called QF, or the Q-factor. I determ... |
Description
You, an armchair cryptanalyst, have noticed that the first letters of each word in your neighbor's mail (yes, you read it -- how else would you know if he's plotting something?) look very suspicious put together. To make sure that his mail is safe to send to its destination, you need to first decode these m... |
Palindromes are fun, but some of the other strings are starting to feel left out. We can turn those strings into chunky palindromes by splitting them up into palindromic arrays of chunks.
For example, the string "abcabca" isn't a palindrome if we read it character by character, but we have three different ways of makin... |
Write a program which finds the non-unique elements of an array of signed integers. The resulting array can be in any order.
Your answer may be a snippet which assumes the input to be stored in a variable (d, say) and evaluates to the correct result.
Test Cases
Each test case is a single line in the format input => out... |
Given the number of vertices n ≥ 3 and the "step size" 1 ≤ m < n/2 (indicating the distance between two connected vertices), output a graphical representation of the corresponding regular polygram. If the polygram consist of multiple closed loops, each loop must be rendered in a different line colour. (If this sounds ... |
On occasion I get a little blue and need a little music to cheer me up, but clicking the start button and finding my media player takes sooooooo long. I want a faster way to play a song.
The challenge:
Write a program that:
Choose a song from my home directory (so you don’t mix-up program sound
files with music) (thi... |
Whoa, whoa, whoa ... stop typing your program. No, I don't mean "print ABC...." I'm talking the capitals of the United States.
Specifically, print all the city/state combinations given in the following list
in any order
with your choice of delimiters (e.g., Baton Rouge`LA_Indianapolis`IN_... is acceptable), so long as... |
Given a square of text representing a spiral of characters, rotate it!
The spiral starts at the center and moves counterclockwise to the outer edge, starting to the left of center:
987
216
345
This translates to the string 123456789. Rotation is done to the left, so if you rotate it one position, it will be 234567891.... |
Home improvement for the Minotaur
The cretan labyrinth is quite easy to draw. Just start with a symmetric shape (here in red). Let us call all the endpoints of those lines 'nodes'. Then you begin drawing the arches (black): The first one alway begins in the top middle node and connects to the node next to it on the rig... |
Introduction
In this challenge, your task is to decide whether a given sequence of numbers can be separated into two subsequences, one of which is increasing, and the other decreasing.
As an example, consider the sequence 8 3 5 5 4 12 3.
It can be broken into two subsequences as follows:
3 5 5 12
8 4 3
Th... |
In chaos theory, the horseshoe map is an example of how chaos arises in a simple process of folding and squashing. It goes like this: take an imaginary piece of dough, fold it, and finally squash it to its original size. Chaos arises in the pattern of how the pieces of dough end up in the final arrangement after n iter... |
Imagine you have an infinite sequence of the alphabet repeated infinitely many times:
abcdefghijklmnopqrstuvwxyzabcd...
You start at index 0, which corresponds to the letter a, and the should_write boolean flag is False.
The input is a list or string of single-digit numbers. For each number n in the input, you should:... |
Given a pattern representing a list of lengths, and a string representing those lengths, do they match?
For those interested, this is question equivalent to verifying if a row or column of a Nonogram may be correct. However, I have omitted all language relating to Nonograms to make the question less confusing for those... |
Write a program or function that takes in a rectangular grid of text where every cell is either an A or a B. All the A cells will form a simply-connected shape, i.e. they will all be orthogonally connected with no holes (diagonally neighboring letters do not count as connected). Likewise, all the B cells will form anot... |
Monday Mini-Golf: A series of short code-golf questions, posted (hopefully!) every Monday.
(Sorry I'm late again; I was away from my computer basically all of yesterday and today.)
Us programmers (especially the code-golfers) sure love arbitrary integer sequences. We even have an entire site dedicated to these sequenc... |
Write a program or function that takes in an integer greater than 1 or less than -1. That is, the input won't be 0, 1, or -1.
If the input is 2, the output should be:
|\_/|
|___|
If the input is 3, the output should be:
|\_/\_/|
|______|
If the input is 4, the output should be:
|\_/\_/\_/|
|_________|
The pattern co... |
Note 2: I accepted @DigitalTrauma's 6-byte long answer. If anyone can beat that I will change the accepted answer. Thanks for playing!
Note: I will be accepting an answer at 6:00pm MST on 10/14/15. Thanks to all that participated!
I am very surprised that this has not been asked yet (or I didn't search hard enough). Ei... |
Write an algorithm to interpret a sequence of letters as a Roman numeral. (see roman numeral rules below)
Each distinct letter has a matching Arabic decimal value, no maximum. But you don't have the key beforehand, so {A=10, I=1, X=5, ... Z=1000000} is decided by your interpretation.
Challenge
Read input via STDI... |
The Alternating Harmonic Series is a well known convergent series.
"Clearly", it is obvious that it converges to the natural log of 2. Or does it?
Since the series is not absolutely convergent, by simply rearranging the terms, I can make it approach anything I want. Suppose I want the series to converge to e. All I'd ... |
Another easy challenge for you.
Your task
Write a program or function that takes the input, which contains 3 pairs of x- and y-coordinates and calculates the area of the triangle formed inside them. For those who can't remember how to calculate it, you can find it here.
Example:
1,2,4,2,3,7 # input as x1,y1,x2,y2... |
(This is a variation on Print a Negative of your Code, which I enjoyed a lot! Thanks to Martin Büttner♦ - almost all of this text is his.)
Let's consider the symbols to be the following printable ASCII characters (note that space is included):
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
And the alphanumerics to be these:
012345... |
Goal
Sometimes dinner menus can have long winded names. It's much easier for the waiter to write an abbreviation that unambiguously identifies the dish.
For example, given this list:
beef burger
chicken burger
chicken nuggets
The abbreviation c n matches chicken nuggets.
The abbreviation bur matches beef burger and c... |
(I'm not a chemist! I might be wrong at some stuff, I'm writing what I've learned in high-school)
Carbon atoms have a special attribute: They can bind to 4 other atoms (which is not that special) and they stay stable even in long chains, which is very unique. Because they can be chained and combined in a lot of differe... |
Challenge
Given a list of numbers, calculate the population standard deviation of the list.
Use the following equation to calculate population standard deviation:
Input
The input will a list of integers in any format (list, string, etc.). Some examples:
56,54,89,87
67,54,86,67
The numbers will always be integers.
Inp... |
Given a snippet of fizz buzz output with all numbers removed, fill in the correct numbers with the lowest possible values such that the fizz buzz snippet is correct. For the purposes of this challenge, fizz and buzz have their usual values of 3 and 5, respectively.
If the input is an invalid sequence of fizz, buzz and... |
I have come across a question on the Code Review site that seems interesting. I think OP is doing it wrong, but cannot be sure... So let's solve it for him! (write a program, not a function/procedure)
Input (stdin or similar):
An integer x in decimal notation. It is greater than 1 and less than 2^31.
Output (stdout or ... |
Write a program or function that takes in an eight byte string containing one of each of the characters ()[]{}<> arranged in any way such that the four respective bracket types match. For example, ]<([){}> is invalid input because the square brackets don't match (though all the others do).
Print or return an integer fr... |
This question is inspired by ongoing tournament of "the hooligan's game played by gentlemen", the Rugby World Cup, which has just completed the pool stage. There are 20 teams in the tournament, and they are divided into 4 pools of 5 teams each. During the pool stage each team plays against all the other teams in their ... |
Objective
The black pawn wants revenge. Plot out its last attack.
Rules
The black pawn (L) starts at the top row and moves downwards to the bottom row. Maximise points taken, indicating the path with X. Pawns (P) are 1, bishops (B) and knights (N) 3, rooks (R) 5, and queens (Q) 9. There won't be any kings in the input.... |
For many games played on a grid, hexagons are the Clearly Superior Choice™. Unfortunately, many free game art sites only have seamless tile sets for square maps. On a past project, I used some of these, and manually converted them to hexagons.
However, I've gotten lazy in my old age. It should be easy to automate the p... |
Introduction
In this challenge, your task is to simulate a certain type of elimination game.
In the game, the participants stand in a circle, and everyone is holding an integer.
On each round of the game, every participant points at the person n steps away, if n is the number they are holding. If n is positive, they co... |
The Challenge
You are the owner of an amazing service called Coyote Beta, which magically answers math questions its users send to it over the internet.
But it turns out, bandwidth is expensive. You have two choices, either create a "Coyote Beta Pro" or find some way to solve this. Just recently, someone queried (x +... |
Golf Me An OOP!
Two important components of object-oriented programming are inheritance and composition. Together, they allow for creating simple yet powerful class hierarchies to solve problems. Your task is to parse a series of statements about a class hierarchy, and answer questions about the hierarchy.
Input
A seri... |
In various Super Mario games green and red Koopa Troopa shells can slide frictionlessly on flat surfaces and destroy brick blocks that are in their way. When a shell hits a brick block the block breaks, turning it into empty space, and the Koopa shell reverses direction. As an example, watch the red shell here.
Suppose... |
Try to write some code in your language and make it not satisfying our criteria of being a programming language any more.
A language satisfies our criteria (simplified version for this challenge) of being a programming language if:
It can read user input representing tuples of positive integers in some way.
It can out... |
The Challenge
A bubble sort takes a list of non-repeating integers and sorts them in ascending order, with only the use of one operation: switching two numbers which are next to eachother.
However for this puzzle, you must take in two strings, which are both anagrams, and bubble sort the letters of the first string int... |
I've got some Java pseudocode that uses whitespace instead of curly braces, and I want you to convert it.
I/O
Your program should take an input file along with a number designating how many spaces are used to indent a block. Here's an example:
$ convert.lang input.p 4
// Convert using 4 spaces as the block delimiter
$... |
I'm sure everyone has seen before that cups can be stacked into pyramids (and other shapes):
A
A A A
A A A A A
A A A A A A A A
Yes, A is definitely an adequate character to represent a cup.
New cups could be added either on the ground, to the right of the structure, or on top of two ad... |
If you've ever tried adding labels to a really dense plot, then you'll realise that sometimes labels will overlap one another, making them hard to read. We're going to do something similar but in 1D.
Input will be a sequence of (label, x-coordinate) pairs, and output will be the result of drawing each point and label, ... |
The task is the following:
Program the shortest fully functional program that checks, if an 8-bit value contains a consecutive sequence of 2 or more ones in its binary form.
If it does contain such a sequence, the output shall be 0. If not: 1.
Examples:
Input: 1
Output: 1
Input: 3
Output: 0
Input: 72
Output: 1
Input: 7... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.