instruction
stringlengths
34
53.1k
Write a program or function which will provably print all integers exactly once given infinite time and memory. Possible outputs could be: 0, 1, -1, 2, -2, 3, -3, 4, -4, … 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -3, -4, -5, -6, -7, -8, -9, 10, 11, … This is not a valid output, as this would never enumerate negative num...
Briefing Aliens have settled on earth and strangely enough, their alphabet is the exact same as ours. Their language is also very similar to ours with some very distinct and easy to compute differences. Challenge Take a string and output the alien's language equivalent. The translation works as such: Swap all the vowel...
This challenge is inspired from this answer at the Ask Ubuntu Stack Exchange. Intro Remember the Windows ME screensaver with the pipes? Time to bring the nostalgia back! Challenge You should write a program or function which will output an ASCII representation of the screensaver. In the screensaver there should be a...
Intro In J. R. R. Tolkien's Lord of the Rings, this phrase is on the cover of each book. Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone, Nine for Mortal Men doomed to die, One for the Dark Lord on his dark throne In the Land of Mordor where the Shadows lie. One Ring to...
Challenge Given a number x and a number n, round number x to n significant figures and output the result. Significant figures The significant figures of a number are digits that carry meaning contributing to its measurement resolution. This includes all numbers except leading zeroes. Bear in mind that leading zeroes af...
There exists an equation, assuming n and x are positive, that expresses the relationship between two monomials, one being a common misrepresentation of the other. Many people make the simple mistake of equating these (i.e. 3x^2 and (3x)^2). Challenge Given a positive integer, i, determine and return the solution n and...
Challenge Given an input n, print an ASCII art cake n layers tall, viewed from the side, with two candles on top. Refer to the examples below for details. Output >> cake(1) _|_|_ | | +-----+ >> cake(3) _|_|_ | | +---------+ | | +-------------+ | | +-------------+ ...and so ...
Challenge Given an input of an all-lowercase string [a-z], output the total distance between the letters. Example Input: golf Distance from g to o : 8 Distance from o to l : 3 Distance from l to f : 6 Output: 17 Rules Standard loopholes forbidden This is code-golf - shortest answer in bytes wins. The alphabet can b...
This challenge is the first in a two-challenge series about Repetition. The second will be up soon. In a language called Repetition (something I just made up), there consists an infinite string of 12345678901234567890..., with 1234567890 repeating forever. The following syntax is available to output numbers: +-*/: Thi...
The House of Santa Claus Note: This is the first challenge that I have attempted to set. It has been through the Sandbox however if you find something wrong with it please do not just downvote but leave a comment so that I can improve it. Background There is a old childrens puzzle where the challenge is to draw a box w...
Write a program or function that prints or outputs this exact text (consisting of 142 characters): ()()()()()() |\3.1415926| |:\53589793| \::\2384626| \::\433832| \::\79502| \::\8841| \::\971| \::\69| \::\3| \__\| Your program must take no input (except in languages where this is impossible...
One of the cool features introduced in the C++11 standard is the ability to declare a template parameter as being variadic; i.e. that parameter represents a sequence of an arbitrary number of arguments (including zero!). For example, suppose the parameter pack args expands contains the sequence A0, A1, A2. To expand th...
I was looking at my previous challenge and thought I could make a better version, but I didn't want to modify that one, so here it is! Challenge Given an input n, print an ASCII art cake n layers tall, viewed from the side, with two candles on top, using box drawing characters. First layer is thinner than the other...
Inpsired by a youtube video from a fellow PPCG user... You challenge is to use ASCII-art draw a Minecraft castle wall of Andesite and Diorite. The shape of the wall is the Cantor Set. For reference, the Cantor Set is made by repeating the following N times: Triple the current step Replace the middle one with blank spa...
Challenge The challenge is to write a function that prints the number of repeats a given array of integers has. What are repeats? Repeats of a slice (as in a section of an array) [ a1, a2, a3, ..., an] are any other non-overlapping slices of the forms [ a1+an, a2+an, a3+an, ..., an+an], [ a1+2an, a2+2an, a3+2an, ..., a...
Take two lists of non-negative integers, and output an ASCII-box as it's defined below. Corners and intersections are pluses: + (ASCII-code 43) Vertical lines are bars | (ASCII-code 124) Horizontal lines are minuses - (ASCII-code 45) The first input list specifies the number of minuses between each plus sign, in the ...
Given two integers as input in an array, draw a rectangle, using the first integer as width and second as height. Or, if your language supports it, the two integers can be given as separate inputs. Assume the width and height will never be less than 3, and they will always be given. Example Outputs: [3, 3] |-| | | |-| ...
What general tips do you have for golfing in Haxe? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Haxe (e.g. "remove comments" is not an answer). Please post one tip per answer. Haxe can be run online here!
Task description In number theory, the Carmichael function λ takes a positive integer n and returns the least positive integer k so that the k-th power of each integer coprime to n equals 1 modulo n. Given a positive integer n, your solution must compute λ(n). The shortest code in bytes wins. Your program should theore...
The challenge Your program or function will accept a single string input from STDIN or a function parameter. You can assume the input will contain only alphabetic characters (a-zA-Z), spaces, and full stops. Input is case insensitive, so you should treat 'a' exactly the same as you would treat 'A'. For each character i...
I know you've always thought about the trials and tribulations of experiencing the joys of life as a web proxy. Honestly, who hasn't? Today you're tasked with realizing this goal (at least a part of it). Website X gets a lot of traffic on the daily and is looking for a PaaS (clearly this refers to Proxy as a Service) b...
Given a text like this: # #### ## # ## # ## # #### ## Output the same text but by connecting the pixels with the characters ─│┌┐└┘├┤┬┴┼. If a pixel doesn't have any neighbours, don't change it. So the output of the last text is: │ ─┬── ┌─ │ └─ │ ┌┘ │ └──┘ ─┘ You can take input as a boolean array. The inp...
Introduction According to Rand Al'Thor's post in the Puzzling SE, a close-knit word is any word that contains three alphabetically consecutive letters (in any order). Words like education, foghorn and cabaret are all considered close-knit words whereas words like learning, klaxon and perform are not close-knit words. C...
Given an integer N > 1, output all other numbers which prime decompositions have the same digits as the prime decomposition of N. For example, if N = 117, then the output must be [279, 939, 993, 3313, 3331], because 117 = 3 × 3 × 13 therefore, the available digits are 1, 3, 3 and 3 and we have 279 = 3 × 3 × 31 939 =...
Challenge Given a single word as input, determine if the word is odd or even. Odd and Even words Assume the general rules: odd + odd = even even + odd = odd odd + even = odd even + even = even In the alphabet, the odd letters are: aeiou And the even letters are: bcdfghjklmnpqrstvwxyz The same applies to capital lett...
It's strange that I haven't seen this, as Excel seems to be a valid language for code golfing (despite its 'compiler' not being free). Excel is somewhat of a wildcard in golfing, being good at golfing challenges of medium complexity, and sometimes simpler challenges as well. More often than not, Excel is good at challe...
Introduction For this example, let's take the string Hello, World! and the array [3, 2, 3]. To find the substring chain, we go through the following process: The first number of the array is 3, so we get the substring [0 - 3], which is Hel. After that, we remove the first 3 characters from the initial string, which lea...
I was wondering if there are any esoteric or golfing languages which specifically target text output and ASCII art? For example, 05AB1E at least started by targeting base conversions. Are there any golfing languages targeting text output and text output art? If so, do they have tip pages here, and are they in common ...
My coworker, Jimmy is kinda new to C/C++. He's also kind of a slow learner. Now, to be fair, his code always compiles, but he has some really sloppy habits. For example, everybody knows that you can define an array like this: int spam[] = {4, 8, 15, 16, 23, 42}; Everybody that is, except for Jimmy. He is convinced tha...
The Challenge Given two strings containing only lowercase letters and no spaces, the result should be the shorter string, followed by an underscore, followed by the longer string with the first instance of a character removed for each character it contains that is in the shorter string. You can assume the strings will...
Challenge: Take a vector / list of integers as input, and output the largest number that's adjacent to a zero. Specifications: As always, optional input and output format You may assume that there will be at least one zero, and at least one non-zero element. Test cases: 1 4 3 6 0 3 7 0 7 9 4 9 0 9 0 9 15 -2 9 -4 -6...
Background In 1870 Émile Baudot invented Baudot Code, a fixed-length character encoding for telegraphy. He designed the code to be entered from a manual keyboard with just five keys; two operated with the left hand and three with the right: The right index, middle and ring fingers operate the I, II, and III keys, res...
My Precalc teacher has one of his favorite problems that he made up (or more likely stole inspired by xkcd) that involves a row of n urinals. "Checkmate" is a situation in which every urinal is already occupied OR has an occupied urinal next to them. For instance, if a person is an X, then X-X--X is considered checkmat...
Hey guys, first time poster here. I went on Coderoulette recently and some guy posted this question. I looked around online but it doesn't seem to be anywhere. I figured I would post it here for anyone who is a fan of these types of problems. Enjoy! Alexa is a druid who loves Mathematics! She lives in the land of Alfa...
A sequel to this question. Task Given an array of positive integers, find the largest element k for which: There exists some positive integer distance n, so that the element in the array located n places to the left or right from k equals n. The array is guaranteed to contain at least one element satisfying this cond...
Poker has etiquette in how you arrange your chips, often enforced in tournaments - your chips may not be "hidden" from your opponents by being behind others, mostly to not hide some large denomination chip(s). The Challenge We are going to be playing poker in ASCII, so we need to write a function or program that will ...
The challenge is to list all ordered partitions (composition (combinatorics)) of a given positive integer n. These are the lists of numbers from 1 to n whose sum is n. For example, given input n = 4, the result should be: 4 1, 3 3, 1 2, 2 2, 1, 1 1, 2, 1 1, 1, 2 1, 1, 1, 1 The result can be in any order...
You're a mouse. Your mouse friends have all been captured, and are unconscious and trapped in a maze that has only one entrance/exit. You happen to have a perfect map of the maze, so you can plot a solution to rush in and carry them all to safety. However, the maze is guarded with a security system that will trigger an...
A pyramidal matrix is a square matrix where all numbers increase or decrease from the center point, like the two matrices below: 1 1 1 1 1 1 2 2 2 1 1 2 3 2 1 1 2 2 2 1 1 1 1 1 1 Or: 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 2 3 3 3 3 3 3 Given a non-zero integer n, create a pyramida...
Given N decanters (0 < N < 10) with that can hold C0 ... CN-1 liters (0 < C < 50) and a goal G liters, please determine if it is possible to reach that goal using only the following actions: Fill a decanter Empty a decanter Pour from one decanter to another until the one being poured to is full or the one being poured...
Tab completion is a useful feature that auto-completes partially written commands. You're going to be implementing it. For example, if the available commands were ['apply','apple','apple pie','eat'], then a would complete to appl, as all of the commands that start with a also start with appl. Input/Output You need to...
A string is called a "prime string" if it can't be written as a concatenation of more than one of the same string. Your task is to write a program that, given a sequence of letters of length N (5 < N < 100), determines if it is prime or not. Examples Input: AABBAA Output: not prime, false, 0, etc. Input: FDFJKEHKLJHD...
Input: A list/array of integers for which each item is in the range of 2-36. Output: The sum of the integers (as base 10), where each next integer is in the base of the previous value (starting with a regular base 10). Example: Let's say we have an input like this: [4, 12, 34, 20, 14, 6, 25, 13, 33] Then we have a sum ...
A number is balanced if the sum of the digits on each half of the number is equal, so: 1423 is balanced because 1+4 = 2+3, so is: 42615 because 4+2=1+5. Note that the middle digit is not included on either side (or it's included on both sides) if there's an odd number of digits. Challenge: Take a positive integer as in...
We'll define the ASCII Odd/Even Cipher via the below pseudocode: Define 'neighbor' as the characters adjacent to the current letter in the string If the one of the neighbors is out of bounds of the string, treat it as \0 or null Take an input string For each letter in the string, do If the 0-based index of the cur...
Introduction The Prime Counting Function, also known as the Pi function \$\pi(x)\$, returns the amount of primes less than or equal to x. Challenge Your program will take an integer x which you can assume to be positive, and output a single integer equal to the amount of primes less than or equal to x. This is a code-g...
Tic-Tac-Latin! This is a true story, so names have been altered. My latin teacher, Mr. Latin, created his own proprietary (no joke) tic tac toe variant. Let's call it tic-tac-latin. The game is simple, it is essentially tic tac toe played on a four by four grid. Formal rule declaration A line is either a row, column o...
Ok, so the input here is going to be a .csv file and so is the output. Now, given a .csv file/input like so "apple","banana","apple,banana","orange" "grape","orange","grape,orange","sprout" # 0 1 2 3 strip out all commas for a given nth column's entries (index starts at 0). So, for the input ...
(Inspired by this challenge.) Let's say we have a string ABBCBA. We can say that there is a rise between A and B, for B follows A; we can say that there is a run between B and B, for nothing changes; and finally we can say there is a fall between C and B. We can draw a graph like this: A B B C B ...
What general tips do you have for golfing in S.I.L.O.S? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to S.I.L.O.S (e.g. "remove comments" is not an answer). Please post one tip per answer. S.I.L.O.S can be run here.
This is sequel to this challenge by Adnan. If you like this challenge, chances are you'll like the other one too. Check it out! A multiple choice test with 8 questions each with 4 choices might have the answers: BCADBADA. Converted to four different arrays, with true and false if the current letter is the answer, it w...
What general tips do you have for golfing in Emotinomicon? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Emotinomicon (e.g. "remove comments" is not an answer). Please post one tip per answer.
Your task is to write a program or function that takes a string as input, and prints Hello (input), I'm (language name). Examples Python: Input: Oliver Output: Hello Oliver, I'm Python C++: Input: Jacob Output: Hello Jacob, I'm C++ etc. Remember, this is code-golf, so the code with the lowest number of bytes wins. Lead...
Task Given the pre-order and post-order traversals of a full binary tree, return its in-order traversal. The traversals will be represented as two lists, both containing n distinct positive integers, each uniquely identifying a node. Your program may take these lists, and output the resulting in-order traversal, using ...
Challenge Given a string such as Hello World!, break it down into its character values: 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33. Then calculate the difference between each consecutive pair of characters: 29, 7, 0, 3, -79, 55, 24, 3, -6, -8, -67. Finally, sum them and print the final result: -39. Rules ...
Credit My thanks to Rand Al'Thor's letter-based question for the inspiration for this code-golf challenge. Background The nature of this challenge is based off the algorithm mentioned by Rand in his "A Triangle Formed of Three Letters": Start with a sequence of 10 letters each of which is X, Y, or Z. Under each row, ...
Ever fancied creating cool twitter hashtags such as #brexit or #brangelina? this golf is for you. Write a program that accepts two strings A & B as input and merges them according to the following algorithm: let n be the number of vowels groups in A (e.g. britain has 2 vowels groups : i in position 3 and ai in positi...
The challenge is simple: write a program or function that, when given a finite non-negative integer, outputs a nested array. The rules Your code must produce a unique valid nested array for every integer 0 ‌≤ n ‌< 231. Every possible nested array with up to 16 open brackets must be outputted within this range. (This d...
The Challenge Given a non-empty string containing only lowercase or uppercase letters and no spaces: Sum up the ASCII values for each character instance in the input string. The sum will be converted to binary. And, the result will be the number of ones in the binary value. Input example: abcDeFAaB Sum up the ASCII...
Challenge: Given a checkerboard, output the smallest amount of moves it would take (assuming black does not move at all) to king a red piece, if possible. Rules: Red's side will always be on the bottom, however their pieces may start in any row (even the king's row they need to get to). Black pieces are stationary, me...
A guitar fretboard diagram looks like this: 0 1 2 3 4 5 6 7 8 9 10 11 12 <- Fret number (0 means it's open) |-E--F--F#-G--G#-A--A#-B--C--C#-D--D#-E |-B--C--C#-D--D#-E--F--F#-G--G#-A--A#-B |-G--G#-A--A#-B--C--C#-D--D#-E--F--F#-G |-D--D#-E--F--F#-G--G#-A--A#-B--C--C#-D |-A--A#-B--C--C#-D--D#-E--F--F#-G--G#-...
Having spend some time on this site I have come to enjoy things being as short as possible. That may be the reason why I'm recently kind of offended by strings containing the same characters more than once. Your job is to write a function or program which condenses a given string according to the following rules: Star...
The Challenge: Consider the function F(N) = 2^N + 1 where N is a positive integer less than 31. The sequence defined by this function is: 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153, 4194305, 8388609, 16777217, 33554433, 67108865, 134217729, ...
Things to know: First, lucky numbers. Lucky numbers are generated like so: Take all the natural numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20... Then, remove each second number. 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39... Now, 3 is safe. Remove every 3...
XKCD #99, with the title "Binary Heart" shows a simple image of ones and zeros, with some digits colored red. The red heart is visible to the naked eye, but the message hidden in the binary sequence is not. If you remove all the spaces and newlines and interpret the binary sequence as 8 bit ASCII-code, you'll end up ...
Recently I read the novel "The Solitude of Prime Numbers" where the main characters are somewhat compared to twin prime numbers ("always together, but never touching"). A twin prime is a prime number that is either \$\require{cancel}2\$ less or \$2\$ more than another prime number —for example, the twin prime pair \$(...
Crash Course on DST Dempster–Shafer theory (DST) provides a method to combine various sources of evidence to form a belief. Given a list of possible statement (one of which is the true answer), each possible combination of statements is assigned a "mass" indicating the degree of supporting evidence. The total mass of...
Prologue After installing an anti-XSS browser extension, Stack Snippets suddenly stopped working all across the Stack Exchange network. I could no longer learn from Stack Overflow, see working demos on User Experience and, worst of all, could not test JavaScript answers on Programming Puzzles and Code Golf! Desperately...
Given a atomic number, print how many electrons are in each shell of the element that the atomic number corresponds to. Expected input/output: Input -> Output 1 -> 1 2 -> 2 3 -> 2, 1 4 -> 2, 2 5 -> 2, 3 6 -> 2, 4 7 -> 2, 5 8 -> 2, 6 9 -> 2, 7 10 -> 2, 8 11 -> 2, 8, 1 12 -> 2, 8, 2 13 -> 2, 8, 3 14 -> 2, 8, 4 15 -> 2, 8...
Your challenge is simple. You need to write a program that prints to either STDOUT or a file the year the language it is written in was released. Because this is such a simple task, the twist is that it must be written in as many different languages as possible. Your score is the total number of different years that ar...
This thinking exercise is inspired from Super Chafouin's question "Just Repeat Yourself" in which the phrase "Do not repeat yourself!" had to be outputted using code that was basically a series of doubled characters, inclusive of newlines, so code like: ((zz==0011))&&((mm++&&mm++&&mm++&&mm++&&mm++&&nn--&&nn--&&nn--&&n...
Given a positive integer n, compute the value of the Mertens function \$M(n)\$ where: $$M(n) = \Sigma_{k=1}^{n}\mu(k)$$ and \$\mu(k)\$ is the Möbius function where \$μ(k) = 1\$ if \$k\$ has an even number of distinct prime factors, \$-1\$ if \$k\$ has an odd number of distinct prime factors, and \$0\$ if the prime fact...
I think we've all done this as a kid: some websites require a minimum age of 18, so we just subtract a few years from the year of birth and voilà, we 'are' 18+. In addition, for most rides at amusement parks the minimum height to enter is 1.40 meters (here in The Netherlands it as at least). Of course this can be cheat...
Being a Haskell hacker, I prefer pointfree notation over pointful. Unfortunately some people find pointfree notation hard to read, and I find it hard to get the correct number of parentheses when I write in pointful. Help me convert code written in pointfree to pointful notation! About In pointfree notation we use poin...
Given a list of indices and zero or more lists of integers, output the lists of integers, sorted in ascending order, with the key priority from the first input. Example Let the keys input be [1, 0, 2], and the lists input be [[5, 3, 4], [6, 2, 1], [5, 2, 1]]. Those lists need to be sorted by their second element, then ...
Notice the pattern in the below sequence: 0.1, 0.01, 0.001, 0.0001, 0.00001 and so on, until reaching 0.{one hundred zeros}1 Then, continued: 0.2, 0.02, 0.002, 0.0002, 0.00002 and so on, until reaching 0.{two hundred zeros}2 Continued: 0.3, 0.03, etc, until 0.{three hundred zeros}3 Continued: 0.4, 0.04, etc, until 0...
I was challenged by one of my friends to solve this coding problem: Given a non-negative number represented as an array of digits, add one to the number. The digits are stored such that the most significant digit is at the head of the list. Return the value as a new list. This was my solution, which does not work if [9...
The official release of the Nintendo 64 in North America was on September 29, 1996.[1] I figured that this anniversary deserved an ASCII art challenge. There's one small twist though, you have to output a different ASCII art for each of three different inputs. If the input is 1, output this ASCII art of an N64 Controll...
Interpret loose ranges ListSharp is an interpreted programming language that has many features, one of those features is a 1 index based range creator that works like this: You define a range as (INT) TO (INT) or just (INT) where both or the single int can go from min to max int32 value Then you can use those ranges to...
Make 2d ASCII buildings depending on what the input is. The submissions can either be a program that takes input, or a function that accepts input via its parameters. e.g. An input of 5,3,6 would output ┌──┐ │┌┐│ ┌──┐ │└┘│ │┌┐│ │┌┐│ │└┘│ │└┘│ │┌┐│ │┌┐│ │└┘│ ┌──┐ │└┘│ │┌┐│ │┌┐│ │┌...
Your task is to regulate traffic on a crossroads. There are 4 roads coming from north, east, south and west. The input is a string representing the upcoming traffic on each road. For example, NNNWS indicates there is a total of 5 cars: three at the north, one at the west and one at the south. The order of characters ha...
PPCG user and elected mod, @Dennis just became the second ever user to earn over 100k rep! This is a totally original idea, that I did not get from anybody else, but let's make a challenge based off of his user ID, 12012 as a tribute! Looking at it, you'll notice that there are two distinct "sections" to his ID. 12 ...
Write a program or function that outputs this exact text, case-insensitive: A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z. (Based on the alphabet song that many American kids learn to help memorize the alphabet, though edited for more compressibility.) The output must look exactly the sa...
The least common multiple of a set of positive integers A is the smallest postive integer B such that, for each k in A, there exists a positive integer n such that k*n = B. Given at least two positive integers as input, output their least common multiple. Rules Builtins are allowed, but if your solution uses one, you ...
The natural numbers including 0 are formally defined as sets, in the following way: Number 0 is defined as the empty set, {} For n ≥ 0, number n+1 is defined as n ∪ {n}. As a consequence, n = {0, 1, ..., n-1}. The first numbers, defined by this procedure, are: 0 = {} 1 = {{}} 2 = {{}, {{}}} 3 = {{}, {{}}, {{}, {{}}}...
Challenge I've recently gotten into 8-bit computers and are fascinated with the workings of them and others alike; thus the objective of this code golf, is to replicate a portion of the Woz Monitor, designed by Steve Wozniak for the Apple I. You are to store an array of 22 hexadecimal values with a width of two bytes...
Task Produce this 24kB ASCII art output: ________ \ \ ________ \____ \ ...
I'm tired, but I can't seem to fall asleep. Help me count sheep. Given an input N (positive integer), make N sheep jump over an ascii fence, like the sample below. Only one frame should be displayed at once: o |-| ──|-|── 0 o|-| ──|-|── 0 o |-| ──|-|── 0 |-|o ──|-|── 0 |-| o ──|-|── 0 o |-| ──|...
An aesthetically pleasing divisor tree is a tree of divisors of input n that, for any composite number m, has two children nodes that are the pair of divisors that are closest to the square root of m. The left node should be the smaller divisor of m and the right node should be the larger divisor of m. A prime number i...
Your task is to print the following: I have a pen I have an apple Uh! Apple pen! I have a pen I have pineapple Uh! Pineapple pen! Apple pen... Pineapple pen... Uh! Pen Pineapple Apple Pen! Remember, this is code-golf, so the code with the smallest number of bytes wins. Leaderboards Here is a Stack Snippet to generat...
Given N items (0 < N <= 50) with prices (which are always integers) P0 ... PN-1 and given amounts of each item A0 ... AN-1, determine how much the total cost will be. Examples N: 2 P0: 2 P1: 3 A0: 1 A1: 4 Result: 14 N: 5 P0: 2 P1: 7 P2: 5 P3: 1 P4: 9 A0: 1 A1: 2 A2: 3 A3: 2 A4: 3 Result: 60 Remember, this is code-golf,...
It is currently December 31, 2015, 11:59:00pm, and you must be at least 1324900 seconds old to be able to go to the New Year Celebration. Given the year, month, day, hour, minute, and second of your birth, determine if you are old enough to go. Notes: Assume that you are in the same timezone. Leap years are every 4 ye...
Given a ray with a point and a vector and a plane with a point and a normal vector to the plane. You have to find the intersection point of the plane and the ray.. So your job if you choose to accept is to write a shortest function that will do the job. RULES: The submission must be a complete program And that's all I...
Introduction A Gray Code is an alternative to binary representation in which a number is incremented by toggling only one bit, rather than a variable amount of bits. Here are some gray codes along with their decimal and binary equivalents: decimal | binary | gray ------------------------- 0 | 0 | 0 ----...
In a smallish class, some lectures are set aside for working in groups. The instructors don't want people to group themselves together with the same people every time; instead, they create the groups beforehand, trying to make sure that all students work with one another as equally as possible. Your job is to write a p...
Goal Create a program/function that takes an input N, check if N random pairs of integers are relatively prime, and returns sqrt(6 * N / #coprime). TL;DR These challenges are simulations of algorithms that only require nature and your brain (and maybe some re-usable resources) to approximate Pi. If you really need Pi d...
Introduction A bell tower will ring its bells every hour, n times, with n being the the current hour on a 12 hour clock. For example, a bell will ring 5 times at 5pm, and 10 times at 10am. Task Given two times in a suitable format, output the number of times the bell will ring, inclusive of the start and end times Exam...
Challenge Given a fraction with a surd (an irrational number) as the denominator, output the rationalised fraction. Rationalising the Denominator To rationalise the denominator, what you have to do is take the fraction and make one which is equal which does not have an irrational number in the denominator. Generally, t...
Introduction The Atari ST was a rather popular personal computer from the mid 80's to early 90's era, powered by a Motorola 68000 microprocessor. On this machine, the default behavior of the operating system for uncaught CPU exceptions was to display a row of bombs on the screen, as shown in the following picture: Sou...
Found this picture on the web today. Being a lazy programmer, I don't want to actually open google and type a couple of characters. Way too much work! This is such an important task that it should be automated. Challenge Everyone knows that the first image in a google search result is always the best. Hence it should ...