instruction
stringlengths
34
53.1k
A bag, also called a multiset, is an unordered collection. You can call it a set that allows duplicates, or a list (or an array) that is not ordered/indexed. In this challenge, you are asked to implement bag operations: addition, difference, multiplication, division, counting and equality test. Operations The specified...
There are numerous reasons for trying to obfuscate input. These include preventing decompiling, and being a nuiscance. With this in mind your challenge should your choose to accept it is to write a meta-obfuscator. Your code must in some Language X receive input as a String, and output a program in language X that out...
THE TASK DEFINITIONS Consider the points {1,2,3,4,5} and all their permutations. We can find the total number of possible permutations of these 5 points by a simple trick: Imaging filling 5 slots with these points, the first slot will have 5 possible numbers, the second 4 (as one has been used to fill the first slot) t...
Inspiration. Task Reverse runs of odd numbers in a given list of 2 to 215 non-negative integers. Examples 0 1 → 0 1 1 3 → 3 1 1 2 3 → 1 2 3 1 3 2 → 3 1 2 10 7 9 6 8 9 → 10 9 7 6 8 9 23 12 32 23 25 27 → 23 12 32 27 25 23 123 123 345 0 1 9 → 345 123 123 0 9 1
Write some code to do the following: Take as its input a signed integer in either signed decimal or signed octal (explained below) If the number is decimal convert it to octal. If it's octal, convert it to decimal Output the number! Instead of starting with a 0, negative octal numbers will start with a Z (capital zed...
Task Find a sequence of all numbers between min and max where every number differs from every other number in the sequence by at least "d" digits. Example of sub-sequence For min = 0, max = 1000 and d = 2, the following is part of one possible solution sequence: 123 ← Good 132 ← Good 145 ← Good 146 ← Bad Notes This i...
On TeX.SE the Help Centre says that the following is on topic: Formats like LaTeX, ConTeXt and plain TeX Engines like pdfTeX, LuaTeX and XeTeX Distributions like TeX Live, MiKTeX, and MacTeX Related software and tools, BibTeX, MakeIndex, Lyx, etc. I wanted you to write a program to tell me whether my TeX is in the on-...
This is a mirror: |. I just found out that you can stick a mirror in the middle of a string if the string can be mirrored on itself! For example, the string abccba. If you cut it in half the two halves are mirror images of each other: abc <--> cba So, we can stick a mirror in the middle of the string, and our new st...
Consider the following definitions taken from The number of runs in a string by W. Rytter. Note that word, string and substring are all roughly synonyms. A run in a string is a nonextendable (with the same minimal period) periodic segment in a string. A period p of a word w is any positive integer p such that w[i...
Challenge description Given a list / array of items, display all groups of consecutive repeating items. Input / output description Your input is a list / array of items (you can assume all of them are of the same type). You don't need to support every type your language has, but is has to support at least one (preferab...
Input: n Output: A list of length n, with each element being the nth happy prime. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number either equals 1, or it loops endlessly in a cycle which does not include 1. A happy number is a number...
There are already 30 challenges dedicated to pi but not a single one asks you to find the nth decimal, so... Challenge For any integer in the range of 0 <= n <= 10000 display the nth decimal of pi. Rules Decimals are every number after 3. Your program may be a function, or a full program You must output the result in ...
Domain name trading is big business. One of the most useful tools for domain name trading is an automatic appraisal tool, so that you can easily estimate how much a given domain is worth. Unfortunately, many automatic appraisal services require a membership/subscription to use. In this challenge, you will write a si...
July 1st is Canada day (yay Canada)! Or is it? It seems that the Wikipedia page for this day has a lot of Canada related content, but is there another day which is more Canadian? Your task is to write a program or function which takes a date (month and day) as input and returns or outputs the number of mentions of "Ca...
Introduction and Credit Today without a fancy prelude: Please implement takewhile. A variation of this (on a non-trivial data structure) was an assignment at my university functional programming course. This assignment is now closed and has been discussed in class and I have my professor's permission to post it here (I...
Task: Make a program that leaves a comment on this question. The content should be 1234567890123456. Edits: You may leave your usernames and passwords as U and P if you are using username and password. (if applicable) No URL Shorteners (if applicable) You may not use the browser console.
Background Countless generations of children have wondered where they would end up if they dug a hole directly downwards. It turns out that this would, unsurprisingly, be rather dangerous, but anyway... Antipodes are points that are directly opposite each other on the Earth's surface. This means that if a line was draw...
[This question is a follow up to Compute the runs of a string ] A period p of a string w is any positive integer p such that w[i]=w[i+p] whenever both sides of this equation are defined. Let per(w) denote the size of the smallest period of w . We say that a string w is periodic iff per(w) <= |w|/2. So informa...
The goal here is to simply reverse a string, with one twist: Keep the capitalization in the same places. Example Input 1: Hello, Midnightas Example Output 1: SathginDim ,olleh Example Input 2: .Q Exmaple Output 2: q. Rules: Output to STDOUT, input from STDIN The winner will be picked 13th of July on GMT+3 12:00 (One...
Your task is to, with an input number p, find the smallest positive cannonball number of order p that is NOT 1. Definition A cannonball number (of order p) is a number which is both: An p-gonal number (See this page). and an p-gonal pyramid number. The nth p-gonal pyramid number is the sum of the 1st to nth p-gonal n...
Consider the following table for the function d(n), which calculates the number of factors that n is divisible by without a remainder: n | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | ... d(n) | 1 | 2 | 2 | 3 | 2 | 4 | 2 | 4 | 3 | 4 | 2 | 6 | ... Going from left to right, it is possible to determine the "c...
A set is sum-free if no two (not necessarily distinct) elements when added together are part of the set itself. For example, {1, 5, 7} is sum-free, because all members are odd, and two odd numbers when added together are always even. On the other hand, {2, 4, 9, 13} is not sum-free, as either 2 + 2 = 4 or 4 + 9 = 13 ad...
Are you tired of languages with built in quining techniques? Your challenge, should you choose to accept it, is to add a built-in quine feature to the language of your choice. Task Given some programming language X, you should define A language X′ that is a subset of X. A quine command string Q. (This is a string of ...
An uninteresting number (which I totally didn't make up only for this challenge) is created like this: Take a positive integer N Create a new number O by adding the digits of N at the end of N The final uninteresting number is O*N For example for N=12: O = 1212 O*N = 1212 * 12 Final number is 14544 Input A posi...
If an integer has a digit/sequence of digits in it which repeats continuously (You will understand why I said "continuously") 5 or more times, we call It "Boring". For example, 11111 is Boring, whereas 12345 is not. Instructions Take an Integer as Input Output a truthy value if the integer is boring, and a falsey value...
Given n (the number of players), t (the threshold value), and s (the secret), output the n secrets generated by Shamir's Secret Sharing algorithm. The Algorithm For the purposes of this challenge, the computations will be done in GF(251) (the finite field of size 251, otherwise known as the integers mod 251). Ordinaril...
Given a non-negative integer (n), create a function that returns n in alphabetical order, according to the literal spelling of each digit in n. Examples: Input: 101 >> one, zero, one >> one, one, zero Output: 110 Input: 31948 >> three, one, nine, four, eight >> eight, four, nine, one, three Output: 84913 Input: 5544 ...
Given a string, return that string's "luck". A string's luck, as I completely just made up for the purpose of this challenge, is an integer, determined as so: The base luck for a string is 1. For each consecutive letter it shares with the word "lucky" (case insensitive), multiply the luck by 2. For instance, if your s...
A dual graph is defined such that for every "face" in a graph G, there is a corresponding vertex in the dual graph, and for every edge on the graph G, there is an edge in the dual graph connecting the vertices corresponding to the two faces on either side of the edge of the original graph. Note that the faces on both s...
Inspired by this, print an ascii diamond pattern built using 0-9. Rules Input n should be between 0-9, anything outside that range is undefined The diamond should be padded with spaces The middle line should always have no padding and be the only line to contain n, in the center Print to stdout As always, this is code...
Stackylogic is a logic-based programming language I made up that take in 0's and 1's for input and outputs a single 0 or 1 upon completion. A Stackylogic program consists of lines that can only contain the three characters 01? as well as exactly one < at the end of one of the lines. Lines may not be empty and the line ...
Do you recognize the PPCG logo? it looks like this, when you do an ascii art of it. +---+ |PCG| +---+ v Now, In this Code Golf, You will make a code, that makes logos for other sites, similar to the PPCG logo. What You should do The "Shortened" string will be the string, with all upper case letters and numbers in t...
Create a program that determines, given an input of the path, whether Mario can reach the end, denoted by E, from the start, denoted by S. A path will look something like this: S = E ===== In a path, the various symbols and what they represent are: =: wall/floor/ceiling. Mario cannot walk through wall , and cannot fa...
Write a program or function which, given an input string and a standard deviation σ, outputs that string along the normal distribution curve with mean 0 and standard deviation σ. Normal distribution curve The y coordinate of each character c is: where σ is given as input, and where x is the x axis coordinate of c. Th...
The challenge Given an input string, and an integer n - truncate any runs of consecutive characters to a maximum of n length. The characters can be anything, including special characters. The function should be case sensitive, and n can range from 0 to infinity. Example inputs/outputs: f("aaaaaaabbbccCCCcc", 2) //"aabb...
Introduction Kipple is a stack-based, esoteric programming language invented by Rune Berg in March 2003. Kipple has 27 stacks, 4 operators, and a control structure. Stacks The stacks are named a-z and contain 32-bit signed integers. There is also a special stack, @, to make outputting numbers more convenient. When a nu...
Chameleon challenges are a bad thing, apparently. Too bad, chameleons are beautiful creatures. Time for a change! As we all know, many chameleons posses a remarkable ability to blend in with their surroundings by changing the color of their skin. Which is also the objective of this challenge. Challenge Imagine a squar...
The goal is, having taken a string as input, duplicate each latin letter and "toggle" its case (i.e. uppercase becomes lowercase and vice-versa). Example inputs & outputs: Input Output bad bBaAdD Nice NniIcCeE T e S t Tt eE Ss tT s E t sS Ee tT 1!1!1st! 1!1!1sStT! n00b nN00bB (e.g...
Convert a classical directory structure like this: config.yml drafts begin-with-the-crazy-ideas.textile on-simplicity-in-technology.markdown includes footer.html header.html Into this . ├── config.yml ├── drafts | ├── begin-with-the-crazy-ideas.textile | └── on-simplicity-in-technology.markdown └──...
Everybody loves golfing code. Code is written in English (eh...). Therefore, everybody loves golfing English! Your task is to write a program or function that takes a string as input, and then returns or prints the golfed version. There will be no newlines or tabs in the input. This is how you golf a string. The order...
Introduction This site is rapidly building up a huge dataset of code snippets, so let's do something with it! Here's a data file. It contains 9,066 unique language+snippet pairs for 113 languages, all taken from this site. The format is tab-separated (language-TAB-snippet), with all newlines in the snippets replaced wi...
Inspired by this challenge Given a number m, output a program that prints out the string Do not repeat yourself. Now for the challenging part: Each program the original code prints out has to have the byte at place m*n be the same as m*n + 1 and the same as m*n + 2 .... all the way down to m*n + m - 1. (In case you can...
Your program's input is a string containing whitespaces, parentheses, and other characters. The string is assumed to be parenthesed correctly, i.e. each right parenthesis matches a unique left parenthesis and vice versa : so the program is allowed to do anything on incorrectly parenthesed strings, such as )abc, (abc or...
Your goal in this code golf is to take two strings, language and code (if the golfed code you wrote for this is multiline, then this variable would be multiline.), and one integer, bytes. They represent the variables for a programming language, number of bytes it takes, and the code itself. After that, you are going to...
i.e each byte appears in a different ANSI shell colour. Rules Resetting the color of the shell after output is not required Must be output in STDOUT or the primary colour text output of your language. Must be done programmatically (iterating through each color and letter of the string induvidually) instead of just wri...
You know—they look like this: source The goal is to draw a music beats illustration like the following: = = = = = = = = == = == = == = ==== == ==== == === = = ======= ======== == ==== = ========= = ================================= The rules are: The width of the illustration is 3...
A heap, also known as a priority-queue, is an abstract data type. Conceptually, it's a binary tree where the children of every node are smaller than or equal to the node itself. (Assuming it's a max-heap.) When an element is pushed or popped, the heap rearranges itself so the the biggest element is the next to be poppe...
Output the current time of day as Swatch Internet Time. Specifically, output a three-digit (zero-padded) number of ".beats" (1000ths of a day) which represent the current time of day in the Swatch Internet Time time zone of UTC+01:00 ("Biel Meantime"). For example, if the current time in UTC is 23:47, then it is 00:47 ...
Challenge: Print the entire printable ASCII charset (not just a range!) in order. !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Rules: read closely No other characters allowed in the output. Program/function does not accept input. Try not to hardcode/embed the outpu...
Tom is going to implement a new programming language of his invention. But before actually starting working on it, he wants to know whether his language should be case sensitive or not. On one hand, case insensitivity seems more easy to implement to him, but he worries that it could cause a lack in the possibilities o...
This year's UEFA Euro 2016 is over and besides a couple of negative headlines there has been a very positive surprise as well – the Iceland national football team. Let's draw their national flag. Input Well, obviously this challenge has no input. Output Draw the flag of Iceland in any applicable visual format of at le...
Generate the nth Narayana-Zidek-Capell number given an input n. Fewest bytes win. f(1)=1, f(n) is the sum of the previous floor(n/2) Narayana-Zidek-Capell terms. Test Cases: f(1)=1 f(9)=42 f(14)=1308 f(15)=2605 f(23)=664299
Or maybe it's not really a labyrinth, but still. Rules: Input is a two-line string, consisting of *, 1, x and X. That string is a labyrinth to walk through. The lines have the equal length. You could take the input as a string with , (comma) or any convenient separator between these two lines. Or you could take both l...
0. DEFINITIONS A sequence is a list of numbers. A series is the sum of a list of numbers. The set of natural numbers contains all "non-negative integers greater than zero". A divisor (in this context) of a natural number j is a natural number i, such that j÷i is also a natural number. 1. PREAMBLE A couple of other que...
Power Grid Resource Costs Introduction In the board game Power Grid, an integral part of the game is the act of buying resources to fuel your power stations. There are four types of resource used in the game (five, if you include renewable energy, but obviously you can't buy resources for that). These are Coal, Oil, Ga...
A Latin square is a square that has no repeated symbols in the rows or columns:. 13420 21304 32041 04213 40132 And as many Sudoku players know, you don't need all of the numbers to deduce the remaining numbers. Your challenge is to compress a Latin square into as few bytes as possible. You need to provide one or two...
Your task is to create a program or function that generates a zipper with a length of 10 lines. Each line of the zipper is represented by two dashes --: -- -- -- -- -- -- -- -- -- -- The program/function will take a percentage (divisible by 10) as input, and the output will be the zipper "unzipped" (dashes separated) ...
Write a program that, given any 'n' number of strings of 'm' length, returns 'm' number of 'n'-length strings, with this condition: Every new string should contains the letters at the same index of the others strings For example, the first output string must contain the first letter of all the input strings, the second...
You must write a program or function. The input is a 'map' of numbers. You can choose to take the map as either a string with new line characters (\n) or a 2D array of strings. All maps are 5 characters by 5 characters, and the characters are always either digits greater than 0 or spaces. Here is an example of a map...
Input: An array containing three integers: 0, 1 and 2 in any order (i.e. [2, 0, 1]) And a string of length >= 2 only containing alphabetic letters (both lower- and uppercase) and digits (i.e. a1B2c3) Output: Based on the array we sort and output the string. How does this work? The array indicates the order precedenc...
In this challenge, you will be given a text block, and you need to perform reflection on the text. Input: A string to be reflected. The text may not be supplied as an array whose elements are the lines of text. For example, "ab\ncd" and ['a','b','\n','c','d'] are allowed, but ['ab','cd'] or [['a','b'],['c','d']] are n...
Your goal is to output the strictly increasing sequence of consecutive, identical digits of pi (π). Each term in the sequence must be one digit longer than the previous. So 3 (0th digit of pi) is the first time a run of digits occurs (length 1). The next to occur is 33 (digits 24 and 25 of pi). Of course, this sequence...
In this question Tom learned that, in general, there are many motivations to choose to include case sensitivity in his programming language, because the possible combinations for a variable name are much more than what's possible with a case insensitive programming language for a name of the same length. But, as a more...
Your task is pretty simple, calculate the n-th element of A190810. Elements of A190810 are calculated according to these rules: The first element is 1 The sequence is increasing If x occurs in the sequence, then 2x+1 and 3x-1 also do You can use 1-based or 0-based indexing, but if you use 0-based indexing, please say...
Dropbox recently released Lepton (GitHub), a method that losslessly compresses JPEG images round-trip, saving an average of 22%. Because of the pigeonhole principle, any general compression algorithm cannot be guaranteed to result in a smaller file (general because it doesn't apply to inputs constrained to a specific ...
Stock Time Machine You've gained access to a dataset, tomorrowStocks, which contains the stock prices from your favorite business on the NASDAQ. This dataset is a container indexed by minutes past opening. Each index contains the price of the stock at that time. // Assume the stock market opens at 9:30AM EDT // tomorro...
For this challenge, you will be given an absolute path, and a "new" path (which can be absolute or relative), and you need to return the final path. For example, if your current directory was /var/tmp/test: my_dir or my_dir/ should return /var/tmp/test/my_dir ../../my_dir should return /var/my_dir /my_dir/./ should re...
Background The Italian definite article (corresponding to English the) has seven different forms: l', il, lo, gli, i, la, le. Which one to use depends on three variables: Gender: masculine / feminine. Number: singular / plural. Initial letter of the subsequent word: vowel / consonant type A / consonant type B. Vowel...
Goal The goal of this challenge is: given a string as input, remove duplicate pairs of letters, if the second item in the pair is of opposite capitalization. (i.e. uppercase becomes lowercase and vice-versa). Pairs should be replaced from left to right. For example, aAa should become aa and not aA. Inputs & outputs: I...
GolfScript automatically coerces values, according to the following ‘priority’ sequence: integer → array → string → block (listed from lowest to highest.) This means that "1"7+ leaves the string "17" on the stack (and not 8), because strings have a higher priority than integers. [To those GolfScript veterans – apolog...
Given a directory (such as C:/), given from stdin or read from a file, produce a directory tree, with each file/folder indented based on its depth. Example If I have a C:/ drive which only contains two folders foo and bar, and bar is empty while foo contains baz.txt, then running with input C:/ produces: C:/ bar/ ...
Task Define a mod-fold as a function of the form f(x) = x % a1 % a2 % … % ak, where the ai are positive integers and k ≥ 0. (Here, % is the left-associative modulo operator.) Given a list of n integers y0, …, yn−1, determine if there exists a mod-fold f so that each yi = f(i). You may choose and fix any two outputs Y ...
Write a program which outputs the square root of a given number in the shortest time possible. Rules It may not use any builtins or powering with non-integers. Input format as a function argument as a command line argument as a direct input on stdin or a window Your entry hasn't to be a complete program, it may be ...
Introduction We all know and love our Fibonacci sequence and have seen a myriad of challenge on it here already. However, we're still lacking a very simple case which this answer is going to provide: Reversed fibonacci! So given F_n your job is to find n. Specification Input Your input will be a non-negative integer, w...
Background The Copeland–Erdős constant is the concatenation of "0." with the base 10 representations of the prime numbers in order. Its value is 0.23571113171923293137414... See also OEIS A033308. Copeland and Erdős proved that this is a normal number. This implies that every natural number can be found at some point ...
What could be the shortest code for filtering the following array in Javascript without any library? My code is: filtered_obj = _.where(obj, { name: "Alpha" }); This uses a JS library called underscore. Test case: objs = [{'id':1,'name':'Alpha'},{'id':2,'name':'Beta'}, {'id':3,'name':'Gamma'},{'id':4,'name':'Eta'}, ...
In this code golf challenge, you will verify hashtags! #What_your_code_should_do Input is a string. Output a truthy value if it is a valid hashtag, and a falsy value otherwise. We define a string as a valid Hashtag if ... It starts with a hash (#). It doesn't have a number right after the hashtag (e.g. #2016USElection...
In the most common contemporary graphical desktop interfaces, when you perform double-click in a text, the word around your cursor in the text will be selected.† For example, let | be your cursor in abc de|f ghi. Then, when you double click, the substring def will be selected. Input/Output You receive two inputs: a st...
Write a program or function that prints or returns a string of the alphanumeric characters plus underscore, in any order. To be precise, the following characters need to be output, and no more: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_ When printing to stdout, an optional trailing newline after y...
I'm new here. I tried seeing if this challenge was introduced before. Found a close call one counting the number of cycles, but didn;t find one for listing them. So I'm writing this one. Sorry if I'm repeating... Anyway, I'm looking for the shortest function to return all close cycles in a shuffled list of indices. For...
Your task is to take an input n and output element n of the Rummy Sequence, a sequence which I made (looking on OEIS will not help you). Definition Each element of the Rummy Sequence is a set of truthy or falsey values. Ex.: [true, false]. The steps to producing a member of the Rummy Sequence are quite simple: Start o...
A difference pyramid is a pyramid where each new diagonal is the absolute value of the differences between the elements of the last diagonal. For example, if we start with the array 2 5 4 9 3 4 Now, we arrange these in a diagonal column: 2 5 4 9 3 4 Now, we fill in the nex...
A binary recurrence sequence is a recursively-defined sequence of the following form: $$F(1) = a_1 \\ \vdots \\ F(y) = a_y \\ F(n) = \alpha F(n-x) + \beta F(n-y), n > y$$ This is a generalization of the Fibonacci (\$x = 1, y = 2, a = [1, 1], \alpha = 1, \beta = 1\$) sequence and the Lucas (\$x = 1, y = 2, a = [2, 1], \...
In this challenge, given a list of ghosts from Pac-Man, you must output which ghosts are missing. You must do it in as few bytes as you can Input Input will consist of a string or list, which will include a number ghosts, which could include: Blinky Inky Pinky Clyde However, input may also include Pac-Man (with that ...
The text of the children's book Polar Bear, Polar Bear, What Do You Hear? has a very simple pattern. You might use the text to teach introductory programming concepts. My son was quickly bored by this idea, so I decided to play some golf with it instead. The Challenge In your programming language of choice, write the...
Presented in honor of APL as an interactive tool turning 50 this year Background Ken [Iverson] presented his paper Formalism in Programming Languages in August 1963 at a Working Conference on Mechanical Language Structures, Princeton, N.J. The list of conferees is full of famous and soon-to-be famous names, and a few ...
Summary Given a list of integers, return the index each integer would end up at when sorted. For example, if the list was [0,8,-1,5,8], you should return [1,3,0,2,4]. Note that the two 8s maintain their order relative to each other (the sort is stable). Put another way: For each element in the list, return the number...
This should be a simple challenge. Given a number \$n \ge 0\$, output the super-logarithm (or the \$\log^*\$, log-star, or iterated logarithm, which are equivalent since \$n\$ is never negative for this challenge.) of \$n\$. $$\log^*(n) = \begin{cases} 0 & \text{ if } n \le 1 \\ 1 + \log^*(\log(n)) & \text{ if } n > 1...
Lets Play Kick The Can! Although Moogie is the current winner, if anyone can take his crown they are encouraged to do so Kick the can is a children's game. Involving one defender, and multiple attackers. Today it is no longer such a game! Your job is to write a bot that plays it, to win, king-of-the-hill style! https:/...
Introduction When you are given a boring text, you just want to get it over with as quick as possible. Let's observe the following text: Ens colligi timenda etc priorem judicem. De quascunque ii at contingere repugnaret explicetur intellectu. Adjuvetis hoc fortassis suspicari opportune obversari vix eam? Dei praemia ...
Inspired by this StackOverflow post. Introduction Bob's job is to create spreadsheets and organize them. The way he organizes them is known to very few except for Bob, but he creates a list of each of the spreadsheets that fall under the same group. There's a bunch of data in the spreadsheet he creates, but there's o...
Your task is to create a program or function that takes, as input, a natural number (n) between 1 and 25 (inclusive) and prints an isometric representation of a slide and ladder with n number of rungs. Ladder and slide specifications The ladder is always oriented on the left and the slide on the right. We're viewing it...
In this optimization challenge you will write a program that sorts a single array by only comparing elements through asking the user on stdout to input comparison results on stdin. The below protocol is line-based, so everytime you print to stdout or read from stdin it is assumed a newline follows. Throughout the quest...
This is Pascal's Braid: 1 4 15 56 209 780 2911 10864 40545 151316 564719 1 3 11 41 153 571 2131 7953 29681 110771 413403 1542841 1 4 15 56 209 780 2911 10864 40545 151316 564719 I totally made that up. Blaise Pascal didn't have a braid as...
Validating a CPR number A Danish CPR number (Person Identification Number) is date of birth followed by 4 digits (the last one being a control digit): DDMMYY-XXXX The final digit validates the CPR number using Modulo 11 by satisfying the following equation: where the are the ten digits of the complete ID number, and ...
In the popular (and essential) computer science book, An Introduction to Formal Languages and Automata by Peter Linz, the following formal language is frequently stated: $$\large{L=\{a^n b^n:n\in\mathbb{Z}^+\}}$$ mainly because this language can not be processed with finite-state automata. This expression mean "Languag...
The Post's Correspondence Problem (PCP) gives you a list of pairs of strings, P_1 ... P_n. Your task is to find a k, and some sequence of k indices such that fst(P_i1) ... fst(P_ik) = snd(P_i1) ... snd(P_ik) We're trying to find some sequence of the pairs where the word we build from the first part is equal to the word...
In this question, we will only focus on losing weight by doing exercise, although there are still many ways to lose weight. Different sports burn different amount of calories. For example, playing billiards for an hour can burn 102 calories[1], while playing basketball for 15 minutes can already burn 119 calories [1], ...
This might be a very simple challenge, but I am surprised it hasn't been done on code-golf yet: Print all Integers from 1 to 10 inclusive in ascending order to standard output. Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of th...
Task Given two strictly positive integers n and d as input, determine whether n is evenly divisible by d, i.e., if there exists an integer q such that n = qd. You may write a program or a function and use any of the our standard methods of receiving input and providing output. The output should be a truthy or a falsy v...