Posts tagged code-golf
Given 3 positive integers, indicate whether they are Borromean coprimes. Definition 3 positive integers are called Borromean coprimes if both of the following are true: Their greatest common d...
Inspiration: Leetcode's [3Sum] linkLink on CG&CC Problem Given an array nums of n (not necessarily distinct) integers, and given a target number target, return an array of all of the unique...
The goal of this challenge is simple: given a ratio of whole numbers, output a 50-character long progress bar representing the ratio. Rules Input Your program must take two numbers as input. T...
Task Given an IP address as a string, find its IP address class. For reference, here is a table: Class Leadingbits Numberof networks Addressesper network Total addressesin class Start...
Given an positive integer $n$, return the least positive integer $k$ such that the $k$th partial sum of the harmonic series is greater than or equal to $n$. For example, if $n = 2$, then $k = 4$, b...
In this challenge, add 2 integers, but if both the integers are 2, output 5. Shortest code in each language wins! Example ungolfed program in Python 3.x def add(x, y): if x == 2 and y == 2: ...
The challenge is to write as short a source as possible, where the English alphabet (in alphabetical order from top to bottom) "abcdefghijklmnopqrstuvwxyz" is a sub-sequence of the source code. Th...
Challenge Given the roots of a polynomial (that is, the $x$ values where the polynomial evaluates to zero), as an array of real numbers, return the polynomial's coefficients. That is, given real ...
Given a positive integer, count its odd digits. Input An integer from 1 to 999,999,999, inclusive, in any of the following formats: A number (such as an integer or floating point number), li...
Given a string of Roman numerals, decide whether it forms a valid Roman number. If not, output the substring that proves this, from the list of 50 strings described below. Relevant fact This chal...
Given a positive integer, indicate whether it is the product of its proper divisors. Integers equal to the product of their proper divisors can be found on the Online Encyclopedia of Integer Seque...
Given an integer from 1 to 1000, indicate whether it is a centered hexagonal number[1] (also known as a hex number). What is a hex number? The hex numbers can be visualised as follows: On a he...
Looping counter Create an infinite loop that outputs lines of asterisks, with each line containing one more asterisk. Instead of the asterisk, any printable, non-whitespace character can be used. ...
Does a positive integer have a substring as a factor? Input A positive integer. Output One of 2 distinct values to indicate whether the input has a factor that is a strict substring of it...
Given a hexomino, indicate whether it is a net of a cube. Input A 6 by 6 grid containing exactly 6 filled squares. The 6 filled squares will be in a single edge connected set (a hexomino). Th...
DC is a reverse-Polish calculator REPL that is available on most Linux distributions. In reverse-Polish notation, you can push values to a stack and then pop those values back off to perform operat...
Given 3 points, output one that is separated from its nearest neighbour by the largest distance. Input 3 distinct points (that is, no 2 points are in the same position). Each point is a pair o...
The Challenge Your job is to, given input positive non-zero integer $n$, output an ASCII representation of the tiled Fibonacci squares up to the $n$th number of the Fibonacci sequence. Rules Inp...
This is a fixed output challenge. It is similar to a standard Kolmogorov complexity challenge, except you get to choose your own fixed output. Given no input, output 55 fruits. You may choose any 5...
Introduction The classic "Hello, World" challenge. What more can I say? Rules Program takes no input. Program outputs Hello, World! with an optional trailing newline. No other output is accep...
Inspired by this challenge. If anyone has any suggestions for a song title I could use for the challenge title then please leave a comment. Definition We define f(x) for a given integer as the su...
The task Output the first 100 elements of the infamous FizzBuzz sequence. How? The FizzBuzz sequence is the sequence of decimal integers from 1 to 100 inclusive, but: If the integer is divisi...
Your goal is to reverse an ascii string. Given a (optionally newline or null terminated) input, output your input in reverse order, optionally followed by a newline. Terminate afterward. Function...
Given a single character, which is a valid Roman numeral, output its value. Values There are 7 valid single character Roman numerals, with the following values: Character Value I...
$N$ vessels initially contain $3$ stones each. What is the probability of having at least $3$ stones in the first vessel after moving a uniformly random selection from the first vessel to the secon...
Also posted here on CodeGolf.SE Brief introduction to Emmental: Emmental is a self-modifying programming language defined by a meta-circular interpreter. It is a stack based language, but also ...
In this challenge you will take an Irish word and a personal pronoun and create the possessive pronoun construction combining the two. For example sé, madra becomes a mhadra. Translated to English...
Suggest a word from a word list, given a string. Motivation Imagine typing a word one letter at a time, and seeing a suggested word after each letter is typed. At first the suggested word is simp...
Your mission for today, should you choose to accept it, is to write a simple 12-hour clock calculator. Your input will always be in the form of arg op arg, where op is either + or -, and arg is eit...
Given a list of non-negative integers the function $f$ replaces every integer with the number of identical integers preceding it (not necessarily contiguously). So f [1,1,2,2,1,3,3] = [1,2,1,2,3,1...
You work in a kitchen which has a peculiar rule. When you mix something into a pot you must always add at least one new ingredient. So you can add pasta, oil, salt then pesto, but not pasta, pesto...
Goal Print the modular multiplicative inverse with a modulus of 65536 (or a higher exponent of 2) for odd numbers 1-97. Example output Print these values (or an extension of them): 1 43691 52...