instruction
stringlengths
34
53.1k
This is a tips question for golfing in Python concerning the Evil Numbers question on Anarchy Golf. An number is evil if its binary expansion has an even number of 1's. The challenge is to print the first 400 evil numbers 0,3,5,...,795,797,798, one per line. The Python 2 submissions are led by llhuii with a 42-byte so...
Take two inputs, a non-empty vector/list containing digits 1 and 2 and a string (no, you may not take 0/1 instead). The string will be one of the following (in lowercase, exactly as written below: increasing decreasing ones twos all none If the string is ____ then you shall return the indices ___: increasing ... wher...
Definition: A number m is called a primitive root of a prime p the condition that the smallest integer k for which p dividies mk-1 is p-1 Your task Given a tuple (a,b) of positive integers, return the fraction: (number of primes p equal to or less than a which has b as a primitive root) divided by (number of primes ...
There are n people on a 2D plane. Using distances between them we're going to find their positions. To get a unique answer you must make four assumptions: There are at least 3 people. The first person is at position (0, 0). The second person is at position (x, 0) for some x > 0. The third person is at position (x, y) ...
Given a date, output the X and Y position of the current day of the date on a digital calendar. The digital calendar is sort of the calendar that gets shown when you click on your computers clock (at least on windows), and it looks something like this: If we assume that the given date is 25.09.2017, the result would b...
The Challenge Write a program that takes an integer N as input, and outputs the stage of life or death that a tree is currently in. N will always be between 0 and 10. The Stages of Life and Death Life: To draw a stage of life, simply draw a base of size N, consisting of ^ characters, then move up and substract 2 from ...
Background Skip to "Task" if you are familiar with Tic-Tac-Toe (I think most are!) Tic-Tac-Toe is a famous two-player game. It consists of a 3x3 board that is filled gradually by two players (clarifications below); The first player uses the character X and the other one uses O. The winner is the first to get 3 consecut...
Challenge You are given two distinct bit strings of the same length. (For example, 000 and 111.) Your goal is to find a path from one to the other such that: At each step, you change only one bit (you can go from 000 to any of 001, 010, 100). You cannot visit the same bit string twice. The path is as long as possible,...
CHALLENGE Given a set of grouped letters, arrange them onto the board so that they cover the area entirely. Board Representation (a.k.a. the SHIP DECK) The board is a 6x6 grid. There will always be 36 total squares. Columns are marked A-F. Rows are marked 1-6. Example: A B C D E F +---+---+---+---+---...
Programming is very rigid. You can't tell a program to "output the banana count", you have to tell it to print(bananas). But when you do that, you end up with a problem: you don't know how many bananas you have beforehand, so you don't know whether to use a plural. Sometimes, programmers go the lazy way. Instead of che...
Given two positive integers a and b, output the frequency distribution of rolling a b-sided die a times and summing the results. A frequency distribution lists the frequency of each possible sum if each possible sequence of dice rolls occurs once. Thus, the frequencies are integers whose sum equals b**a. Rules The fre...
Alpha Decay is a kind of radiation decay where every time the atom "decays", it loses a helium nucleus (an alpha particle). This means that an atom loses 2 protons and 2 neutrons each time. Your task is to simulate this, including the problems that occur during alpha decay. Given two integers as input, \$m\$ and \$p\$,...
Given an integer p > 1, find the smallest integer q > p such that the list of exponents in the prime factorization of q is the same of that of p, no matter the order or the value of the prime factors. Examples The prime factorization of p = 20 is 22 x 51. The smallest integer greater than p with identical exponents in ...
For the purposes of this question, the prime factorial of a number n is the result of multiplying all prime numbers smaller than n, and then multiplying the result by n. Your Task: Write a program or function to find the prime factorial of a number, as outlined above. Input: An integer n where n is greater than one...
You deal cards labeled 0 to 9 from a deck one a time, forming stacks that start at 0 and count up by 1. When you deal a 0, you place it on the table to start a new stack. When you deal any other card, you stack it atop a card that's exactly one lower in value, covering it. If there's no such card, the deck isn't stac...
Suppose a new fairy chess piece named the Wazir is introduced to chess. Wazirs can move from a position (x, y) to:  (x+1, y)  (x, y+1)  (x-1, y)  (x, y-1) That is, they move orthogonally like the rook, but only one step at a time like the king. How many such wazirs can be placed on an N×N chessboard so that no two wazi...
I guess I'm not the only one who have seen this kind of image on Facebook (and other sites). The picture above was posted 16 days ago, and has accumulated 51 k comments. Some answers: 0, 4, 8, 48, 88, 120, 124 and so on. Challenge: The mathematics in the question doesn't make sense1, so we can't find the correct answ...
The Bible is one of the most influential books ever written, and commonly cited as the best selling book of all time. It was written by approximately 40 different authors over hundreds of years before being compiled into it's current form. But what's interesting about The Bible is the way it's divided up. It is split u...
Introduction: We all know these three basic arithmetic math tables I assume. ADDITION: + | 1 2 3 4 5 6 7 8 9 10 ---------------------------------- 1 | 2 3 4 5 6 7 8 9 10 11 2 | 3 4 5 6 7 8 9 10 11 12 3 | 4 5 6 7 8 9 10 11 12 13 4 | 5 6 7 8 9 10 11 12 13 14 5 | 6 7 8 9 10 11 ...
Introduction Given five points in the plane, your task is to compute the area of the ellipse passing through these points. You can assume that exactly one non-degenerate ellipse can be constructed with the given input values. Rules Input is 10 integers in any convenient form, corresponding to the x and y coordinates of...
Definition Narcissistic 1 integers of an array think they are better than their neighbours, because they are strictly higher than their arithmetic mean. Neighbours are defined as follows: If the integer is at index 0 (the first), then its neighbours are the last and the second elements of the list. If the integer is ...
Given an ordered list of 2 or more 2D cartesian points, output a truthy value if either the path touches itself or self-intersects; otherwise output a falsy value if it does not touch itself or self-intersect. You may assume that consecutive points in the list are distinct. Examples: (0,0), (1,0) -> falsey (0,0), (1,0)...
Given a positive integer N, output the innermost N×N square of an ASCII art spiral made of -|/\ that spirals clockwise inward. The - is used for horizontal portions, | for vertical portions, and / and \ for corners. The first character is - and the spiral proceeds left and down. Specifically, when N is 1 the output is:...
Inspired by digital roots, the prime factoral root of a number is the number that emerges when you take the prime factors of a number, add them together, and repeat the process on the resulting number, continuing until you end up with a prime number (which has itself as its only prime factor, and is thus its own prime ...
Multiplication between 2 integers can be reduced into a series of addition like so 3 * 5 = 3 + 3 + 3 + 3 + 3 = 5 + 5 + 5 Exponentiation (raising a to the power b) can also be reduced into a series of multiplications: 5 ^ 3 = 5 * 5 * 5 Therefore, exponentiation can be reduced into a series of additions, by creating a ...
Given a positive integer n output the n-th number of the euro-iginal sequence. Calculating the Sequence This sequence is equal to OEIS A242491. A number is part of said sequence if the number can be made up by using as many different euro coins or notes, but only one of each. Note that you don't have to consider cents....
Input: Two strings without newlines or whitespaces. Output: Both input strings on separate lines, with spaces where necessary† for one of the two strings. And a third line with the characters A, R, M and , representing added, removed, modified, and unchanged. † We add spaces to either the top or bottom input string (if...
I have the following code which I've written to emulate Newton's method for deriving the square root of a number: r=(x,y)=> (z=((y=y||x)*y-x)/(2*y)>1e-15)? r(x,y-(y*y-x)/(2*y)):y Where r(37) would result in 6.08276253029822 which is great given the limitations of my browser. I'd like to golf this code further seei...
Let's imagine we have a matrix of bits (which contains at least one 1): 0 1 0 1 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 1 1 0 0 1 0 0 1 1 0 1 0 0 0 1 0 1 1 0 0 1 0 We want to set some of the bits in this matrix such that it forms a contiguous blob of 1s, in which every 1 is directly or indirectly con...
Take an input list L containing positive integers, and insert the least amount of integers into the sequence, so that you make it a continuous one. Example: L = 4 2 6 1 Out: 4 3 2 3 4 5 6 5 4 3 2 1 The input and output formats are optional. Test cases: L = 1 Out: 1 L = 10 4 Out: 10 9 8 7 6 5 4 L = 13 13 Out: 13 13 ...
Take two positive integers N and M and create the concatenated cumulative sums of [N], with M iterations. Output the result of the last iteration. Definition of the concatenated cumulative sum: Start with a number N and define a sequence X = [N] Append to X the cumulative sums of X Repeat step 2 M times. The cumulati...
Given two positive integers p and q, your task is to return the array A created by applying the following algorithm: Start with A = [p, q] and d = 2 For each pair (x, y) of contiguous numbers in A whose sum is divisible by d, insert (x + y) / d between x and y. If at least one matching pair was found, increment d and ...
The problem #6 of IMO 2009 reads: Let a 1, a 2, a 3, ..., a n, be distinct positive integers and let T be a set of n-1positive integers not containing a 1+a 2+a 3+...+a n, A grasshopper is to jump along the real axis, starting at the point 0 and making n jumps to the right with lengths a 1, a 2, a 3, ..., a n in so...
Your task: write a program/function that when given a string containing only ASCII characters, outputs/returns the string in reverse-ish. Example: 1) Input Hello, World! 2) Number unique characters in input. (Input string separated by pipes (|) for readability) H|e|l|l|o|,| |W|o|r|l|d|! 1 2 3 4 5 6 7 8 9 10 3) ...
Introduction / Background In a recent discussion in the crypto chat I was challenged to discuss / help with the Fermat primality test and Carmichael numbers. This test is based on the premise that a^(p-1) mod p==1 will always hold for primes p, but not always for composites. Now a carmichael number is essentially the F...
Note: this challenge has been posted on the sandbox. Introduction This challenge is inspired by 2009 Putnam B1, a problem in an undergraduate mathematics competition. The problem is as follows: Show that every positive rational number can be written as a quotient of products of factorials of (not necessarily distinct...
For the purpose of this challenge, a Prime Power of a Prime (PPP) is defined as a number that can be defined as a prime number to the power of a prime number. For example, 9 is a PPP because it can be represented as 3^2. 81 on the other hand is not a PPP because it can only be represented as 3^4, and 4 is not prime. ...
This is part of a cops-and-robbers challenge. Go here for the robbers' part. The Cops' Challenge You should write a program or function in a language of your choice, which outputs the string Haystack. However, it must be possible to remove some subset of characters from your program (without reordering the rest), such ...
This is part of a cops-and-robbers challenge. Go here for the cops' part. The Robbers' Challenge A cop's answer can be cracked by removing any subset of characters from the Haystack program, so that it outputs Needle instead of Haystack (while still being a valid submission in the same language). You don't have to find...
One way to represent a natural number is by multiplying exponents of prime numbers. For example, 6 can be represented by 2^1*3^1, and 50 can be represented by 2^1*5^2 (where ^ indicates exponention). The number of primes in this representation can help determine whether it is shorter to use this method of representat...
If Abe goes, then Beth and Diana go. If Beth goes, then Catherine goes. If Catherine goes, then Diana goes. If Diana goes, then Ezra goes. Only three people go. Who goes? Challenge Given a list of several pairings of people, such that in each pairing the second person goes if the first person goes, and a positive integ...
This challenge is similar to my previous one, but has a twist that makes it significantly more difficult. There are n people on a 2D plane. Using distances between them we're going to find their positions. You may make four assumptions: There are at least 3 people. The first person is at position (0, 0). The second pe...
The "prime ant" is an obstinate animal that navigates the integers and divides them until there are only primes left! Initially, we have an infinite array A containing all the integers >= 2 : [2,3,4,5,6,.. ] Let p be the position of the ant on the array. Initially, p = 0 (array is 0-indexed) Each turn, the ant will mo...
Unlike most languages, Python evaluates a<b<c as it would be done in mathematics, actually comparing the three numbers, as opposed to comparing the boolean a<b to c. The correct way to write this in C (and many others) would be a<b && b<c. In this challenge, your task is to expand such comparison chains of arbitrary le...
I saw another prime challenge coming by in PPCG, and I do love me some primes. Then I misread the introductory text, and wondered what the creative brains here had come up with. It turns out the question posed was trivial, but I wonder if the same is true of the question I (mis)read: \$6\$ can be represented by \$2^1\...
For the purpose of this challenge, a smaller-base palindrome (SBP) is a number which is palindromic in a base between 1 and itself (exclusive), and is not a repdigit in the same base. For example, 5 is a SBP because it is a palindrome in base 2 (101). The first few SBPs are 5,9,10,16,17,20,21,23,25,26,27,28,29,33... ...
There have been a lot of prime-/prime factorization-related challenges recently, so I thought it might be interesting to go the other way. Given: a positive integer n, and a non-empty list of positive integers f write a full program or a function to find the smallest integer i such that i >= n and i is a product of n...
Consider a bridge of length B formed by tiles labeled with the digits of the positive integers concatenated. For example, if B was 41, then it would look like this: ----------------------------------------- 12345678910111213141516171819202122232425 Now imagine a train of length T crossing the bridge. The leftmost poi...
Given an integer n, print out n * reversed(n) reversed(n) is the number you get when you reverse the digits of n. reverse(512) = 215 reverse(1) = 1 reverse(101) = 101 >>>>>>>> func(5) = 5*5 = 25 func(12) = 12*21 = 252 func(11) = 11*11 = 121 func(659) = 659*956 = 630004 Shortest code wins! Leaderboard var QU...
According to RollingStone, below are the 26 greatest singers of all time: Aretha Franklin Al Green Ray Charles Robert Plant Elvis Presley Mick Jagger Sam Cooke Tina Turner John Lennon Freddie Mercury Marvin Gaye Bob Marley Bob Dylan Smoke...
Alphabet Rain The Task: The basic premise is to print out the input string and then repeat each character vertically, based on it's (0-indexed) position in the (case-insensitive) alphabet A-Z. A is at location 0 so is not repeated, e is at position 4 so is repeated 4 times, P is at position 15 so is repeated 15 times, ...
For the purpose of this challenge, a multi-base prime is a prime which, when written in base 10, is prime in one or more bases smaller than 10 and larger than 1 as well. All single-digit primes are trivially multi-base primes. 11 is also a multi-base prime, as 11 in binary is 3, which is prime (it is also prime in ba...
Given a matrix, sum its values up/down or left/right to form an X, fold it up, and return the list. I describe the algorithm here: Algorithm Your input will be a odd-sized square matrix of integers within your language's reasonable numerical capacity. Let's take the following matrix as an example: 1 2 3 2 1 0 3 2 3 0 4...
Lets define a pointer sequence to be any sequence such that a(n) = a((n-1)-(a(n-1))) forall n greater than some finite number. For example if our sequence begun with 3 2 1 Our next term would be 2, because a(n-1) = 1, (n-1)-1 = 1, a(1) = 2 (this example is zero index however it does not matter what index you use the...
Most of us are probably familiar with the concept of triangular and square numbers. However, there are also pentagonal numbers, hexagonal numbers, septagonal numbers, octagonal numbers, etc. The Nth Nagonal number is defined as the Nth number of the sequence formed with a polygon of N sides. Obviously, N >= 3, as th...
We haven't had a string question for a while (5 days to be precise), so let's go for one. Given a string s and a positive integer n, take every nth element of s, repeat it n times, and put it back into s. For example, if n = 3 and s = "Hello, World!", every third character is Hl r!. You then repeat each character n tim...
Given a nonempty finite list of integers, output a truthy value if there are exactly two equal entries and all other entries are distinct, and a falsey value otherwise. Examples truthy: [1,1] [1,2,1] [1,6,3,4,4,7,9] falsey: [0] [1,1,1] [1,1,1,2] [1,1,2,2] [2,1,2,1,2] [1,2,3,4,5]
Write a function or program that given a list of non negative integers, arranges them such that they form the largest possible number. INPUT [50, 2, 1, 9] OUTPUT 95021 INPUT 0 OUTPUT 0 INPUT (Interesting one) [7, 76] OUTPUT 776 RULES standard loopholes apply. Depending on your language you can use int(32) / in...
Siteswap is a notation for juggling patterns. The other siteswap puzzle is great and it explains siteswap in greater detail than here. This puzzle is meant to be a bit simpler! Numberphile recently interviewed Colin Wright which helped develop the notation. The part at ~16min will be useful for this challenge. Another ...
Let's define a sequence of integer square roots. First, a(1) = 1. Then, a(n) is the smallest positive integer not seen before such that sqrt(a(n) + sqrt(a(n-1) + sqrt(... + sqrt(a(1))))) is an integer. Some examples: a(2) is 3 because it's the smallest integer such that sqrt(a(2) + sqrt(a(1))) = sqrt(a(2) + 1) is int...
Zeroless numbers are numbers that do not contain 0 as one of their decimal digits. Given an integer K, return the Kth zeroless number. K will be non-negative if you choose 0-indexing, or positive if you choose 1-indexing instead. Note that this is OEIS A052382. This is code golf, so the shortest code in bytes wins. Tes...
Many people consider RPS to be a game of chance. If both players play unpredictably, the best strategy is to play randomly. However, let's introduce a bit of predictability to it. Each bot will have a chance to tell the other bot what it's going to play simultaneously. Then there is a pause in which each bot will know...
Challenge Given a string input, output the demolished version of it. The Process P r Pr r o o o g g g r r r rogr r a -> a -> a -> a -> a -> -> -> -> -> m m m m m m m ...
Given a string as input, print a new string with each letter pushed to the right by its respective alphabet index. We all know that A is a slow and Z is a fast letter. This means that Z gets shifted to the right by 25 spaces, A doesn't get shifted at all and B gets shifted by 1 space. Your program only has to handle up...
Given two integers, which may be negative, zero, or positive, \$a\$ and \$b\$ (taken in any reasonable format, including inputting a plain complex number), convert it to \$a + bi\$ where \$i\$ is the imaginary number (square root of negative one). Then, raise it to the power of a third (positive integer) input variable...
There are quite a few means in mathematics, such as the arithmetic mean, the geometric mean, and many others... Definitions and Task Note that these are the definitions for two positive integers*: The root mean square is the square root of the sum of their squares halved (). The arithmetic mean is their sum, halved ()...
A subsequence is any sequence that you can get from another by deleting any amount of characters. The distinct non-empty subsequences of 100 are 0, 1, 00, 10, 100. The distinct non-empty subsequences of 1010 are 0, 1, 00, 01, 10, 11, 010, 100, 101, 110, 1010. Write a program or function that given a positive integer n ...
Here is the code which I want to shorten. n=input() while n: s=raw_input() x,r,g,b=(int(x) for x in s.split()) a=x/r%2 c=x/g%2 d=x/b%2 r=((a*10+c)*10)+d if r==0:e="black" elif r==100:e="red" elif r==1:e="blue" elif r==10:e="green" elif r==101:e="magenta" elif r==11:e="cyan" elif r==110:e="yellow" else:e="...
Task: Take a string as input and if it meets the requirements, accept the password. Input: a string, e.g. someString, asjk23t89h, 123456789abcdef. Output: two distinct values representing "secure" and "insecure", e.g. 0/1, true/false, secure/insecure. Password requirements: In order for a password to be determined as s...
The binary-square-diagonal-sequence is constructed as follows: Take the sequence of positive natural numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ... Convert each number to binary: 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 10000, 10001, ... Concatenate them: ...
Former US Secretary of Defense, Donald Rumsfeld, famously popularized the phrase "known knowns." Here we're going to distill his remarks into a four-line stanza. Specifically, output this text: known knowns known unknowns unknown knowns unknown unknowns Capitalization doesn't matter (for example, Known unKnowns is fin...
You will be given a 2-D array A of integers, and a length N. Your task is to find within the array the straight line (horizontal, vertical or diagonal) of N elements that yields the highest total sum, and return that sum. Example N = 3, A = 3 3 7 9 3 2 2 10 4 1 7 7 2 5 0 2 1 ...
This is Hole-1 from The Autumn Tournament of APL CodeGolf. I am the original author of the problem there, and thus allowed to re-post it here. Given a list of numbers, produce a horizontal bar chart of # characters for how many numbers fit into each of ten equal-sized groups. For example, if the data ranges from 0-100...
Task The letters spell out actual words, but if you replace each letter with a digit from 0–9, it also “spells” an arithmetic equation. The trick is to figure out which letter maps to each digit. All the occurrences of each letter must map to the same digit, no digit can be repeated, and no “word” can start with the di...
A000330 - OEIS Task Your task is simple, generate a sequence that, given index i, the value on that position is the sum of squares from 0 upto i where i >= 0. Example: Input: 0 Output: 0 (0^2) Input: 4 Output: 30 (0^2 + 1^2 + 2^2 + 3^2 + 4^2) Input: 5 Output: 55 (0^2 + 1^2 + 2^2 + 3^2 + 4^...
TASK print integers n, where 12 <= n <= 123456789, and all pairs of consecutive digits in n have the same positive difference between them (e.g. 2468 but not 2469). NO INPUT. Output: 12 13 14 15 16 17 18 19 23 24 25 26 27 28 29 34 35 36 37 38 39 45 46 47 48 49 56 57 58 59 67 68 69 78 79 89 123 135 147 159 234 246 258 3...
A number is in base-b simplified Goodstein form if it is written as b + b + ... + b + c, 0 < c ≤ b The simplified Goodstein sequence of a number starts with writing the number in base-1 simplified Goodstein form, then replacing all 1's with 2's and subtracting 1. Rewrite the result in base-2 simplified Goodstein for...
This is Hole-3 from The Autumn Tournament of APL CodeGolf. I am the original author of the problem there, and thus allowed to re-post it here. Given: a number of turns (please state if no movements is 0, otherwise we'll assume it is called 1) and a list of one or more starting positions (in any form, e.g. 0 or 1 ind...
We all know what a quine is. An inverted quine is a non-empty program that prints the inverse of its source code without reading its source code, and consists solely of printable-ASCII characters (space through ~). Here, “inverse of the source code” means the following: the output of your program must contain each pri...
(no, not those ones) The Challenge You'll be given two inputs. The first is a positive integer n > 0, which is used to output an n x n right triangle of the numbers 1, 2, 3, ... n. This triangle starts in a corner and increases horizontally and vertically by one and diagonally by two. See examples below for clarificati...
Definition and Rules A golfy array is an array of integers, where each element is higher than or equal to the arithmetic mean of all the previous elements. Your task is to determine whether an array of positive integers given as input is golfy or not. You do not need to handle the empty list. Default loopholes apply....
Definition Let's call an (infinite) integer sequence universal if it contains every finite integer sequence as a contiguous subsequence. In other words, the integer sequence (a1, a2, …) is universal if and only if, for each finite integer sequence (b1, …, bn), there is an offset k such that (ak+1, …, ak+n) = (b1, …, bn...
The "prime frog" is a strange animal that jumps between integers, until it arrives on 3 or 19... Your program should accept an integer n as input and output the result of the below algorithm (3 or 19). For a given integer n >= 2: Let f be the position of the frog. It is initially set to n if f = 3 or f = 19 : the fro...
WPA2, the actual encryption standard that secures all modern wifi networks, has been cracked... This challenge has nothing to do with the way that the WPA2 was cracked, however is is about computing the 64-digit hexadecimal key that corresponds to a given WPA-PSK pass-phrase. A wireless network with WPA-PSK encryption ...
This is Hole-9 from The Autumn Tournament of APL CodeGolf. I am the original author of the problem there, and thus allowed to re-post it here. Given a simple (rectangular, non-jagged) Boolean array (of one or more dimensions) return a list of thusly shaped arrays where the first array is identical to the input and the...
Common words should still be avoided to be used as passwords. This challenge is about coding a very simple program that munges a given password (Modify Until Not Guessed Easily). Input A word, which is a string written in the alphabet abcdefghijklmnopqrstuvwxyz. It does not matter if the letters are lowercase or upper...
A person has two first names if their last name is also a common first name. You are tasked with determining which full names in a list are two first names. John Smith John Doe Luke Ryan Ryan Johnson Jenna Jackson Tom John Any name that occurs in the first name column is potentially a first name. If the number of occu...
An LTL Formula l is defined by the following grammar (where <x> describes the non-terminal symbol x): <l> ::= <b> | F <l> | G <l> | X <l> | (<l> U <l>) | (<l> W <l>) | (<l> R <l>) | (<l> & <l>) | (<l> \| <l>) | !<l> <b> ::= BVar | True | False | (<i> < <i>) | (<i> <= <i>) | (<i> > <i>) | (<i> >= <i>) ...
To celebrate the 2497th anniversary of the Greek victory at Salamis in 480 BC. Draw the lambda blazon. The lambda blazon was the lambda painted on greek shields like so: Puzzle: Given a positive odd integer n, produce an ascii art image of the above shield. Specifications: n=1: ( /\ ) n=3: ( /\ ) | / \ | ( /...
Life-like cellular automaton are cellular automaton that are similar to Conway's Game of Life, in that they operate on a (theoretically) infinitely large square grid, where each cell has exactly 8 neighbours, and is one of 2 states, namely alive and dead. However, these Like-like versions are different in a crucial way...
We are searching for a sequence Take the natural numbers 1,2,3,4,5,6,7,8,9,10,11,12,13,14... Convert to base-2 1,10,11,100,101,110,111,1000,1001,1010,1011,1100,1101,1110... Concatenate the above numbers 110111001011101111000100110101011110011011110... Partition this number in Prime-Chunks (chunks containing a prime num...
Expand an array to all directions by duplicating the outer elements You will be given two inputs: an array and the expansion degree For example if I give you [[1,2,3][4,5,6][7,8,9]] and 3, you must output: 1 1 1 1 2 3 3 3 3 1 1 1 1 2 3 3 3 3 1 1 1 1 2 3 3 3 3 1 1 1 1 2 3 3 3 3 4 4 4 4 5 6 6 6 6 7 7 7 7 8 9 9 9 9 7 ...
Consider the array of positive integers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ... Then, concatenate them: 1234567891011121314151617181920212223242526... And then split them into chunks of variable length, each length being equal to the Nth positive integer: [1][23][456][7891][01112][131415][1617181][92021222][3...
Given an integer n >= 2, output the largest exponent in its prime factorization. This is OEIS sequence A051903. Example Let n = 144. Its prime factorization is 2^4 * 3^2. The largest exponent is 4. Test Cases 2 -> 1 3 -> 1 4 -> 2 5 -> 1 6 -> 1 7 -> 1 8 -> 3 9 -> 2 10 -> 1 11 -> 1 12 -> 2 144 -> 4 200 -> 3 500 -> 3 1024...
Task: Make a program that draws the following figure line by line. Your program should wait for one-second after drawing each line(it can be longer, just has to be a noticeable difference) . Your program can only draw line by line (you cannot jump to another point or re-draw over a line) Given a positive integer n, pr...
Task Your task is to output a single integer, with one restriction: its digits must be a permutation of [1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6]. For example, you could output 653443653152432, 413265345463352, or any of the other 15-digit integers whose digits are a permutation of the list. Rules Your code must t...
This is the PPCG Prime 624 digits long 77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777711111111111111111111111111111111111111111111111111111111111111111111111111111118888888811888888881118888881118888881118811111...
Inclusion-Exclusion lets you calculate the sizes of some unions and intersections between sets knowing some of the other values. I won't explain it exactly, but your challenge is to visualize inclusion-exclusion on a Venn Diagram. Because I'm nice, you'll be using rectangles, not circles. You will be given a list of re...
Introduction: Since it's almost Halloween, I was just thinking of some random Halloween-themed challenges. Eventually I was reading through Frankenstein's wikipedia page, and came across the following text: The creature Part of Frankenstein's rejection of his creation is the fact that he does not give it a name, which...
Given a, b, c the length of the three sides of a triangle, say if the triangle is right-angled (i.e. has one angle equal to 90 degrees) or not. Input Three positive integer values in any order Output Either a specific true output (true, 1, yes, ...) or a specific false output (false, 0, no, ...) Example 5, 3, 4 ...