instruction
stringlengths
34
53.1k
This challenge is from an admission test to a closed number cyber security course. Anyway it doesn't have to do with cyber security, it's just to test the students logical and coding skills. Task Write a program that removes entries from an array so that the remaining values are sorted in a strictly decreasing order an...
Apparently yes! In three easy steps. Step 1 Let f(n) denote the prime-counting function (number of primes less than or equal to n). Define the integer sequence s(n) as follows. For each positive integer n, Initiallize t to n. As long as t is neither prime nor 1, replace t by f(t) and iterate. The number of iterations ...
As computer scientists, you're probably all familiar with the basic list operations of pop and push. These are simple operations that modify a list of elements. However, have you ever heard of the operation flop? (as in flip-flop)? It's pretty simple. Given a number n, reverse the first n elements of the list. Here's a...
Definition The maxima and minima of a given function are the largest and smallest values of the function either within a given range or otherwise within the entire domain of the function. Challenge The challenge is to find the local maxima and minima of a given polynomial function using any method you may like. Don't w...
As we saw in this question complex logical statements can be expressed in terms of the simple connectives of generalized Minesweeper. However Generalized minesweeper still has redundancies. In order to avoid these redundancies we define a new game called "Generalized-1 Minesweeper". Generalized-1 Minesweeper is a vers...
Your task is to model the effects of batter on pieces of food. Please add three layers of crust. [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0], // in [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0], [0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0], [0,0,0,0,0,0,0,0...
Task Given a list of integers L and another integer s, the goal is to compute the column-wise sums of all s-length (potentially overlapping) slices of L, while pertaining their positions relative to L (see below). Definitions The s-length (overlapping) slices of the list L are all the contiguous subsequences (without w...
Notice: I'm willing to give a bounty to any answer that I find interesting. Your challenge is to design a Turing-complete one instruction set computer (OISC): An OISC is an abstract machine that uses only one instruction – obviating the need for a machine language opcode. With a judicious choice for the single instruc...
A Russian nesting doll, more commonly known as a Matryoshka doll, is a doll which contains a smaller version of itself, which then contains another smaller version of itself, which contains a smaller version of itself, which contains a smaller version of itself, which contains a smaller version of itself... - until fi...
Your assignment is to write a program of even length, that prints an ASCII-art square (described below), that increases its side length by 1 unit each time the original source code is pasted in the middle of the current code. It is quite hard for me to define this task very well, so I'll give you an example: Let's sa...
Weather forecasting: Wrong too often to rely on, right too often to ignore. Given a high and low temperature and one of four weather conditions per day, output an ASCII-art graphical five day weather forecast. The structure of the four graphical indicators are shown below. \ / -O- Sunny / \ \ / -O(==) ...
We are doing a PCG challenge at work, and I'm submitting answers in C#. This is a modification of the "M'Kay" challenge. My solution has been deemed correct by the requirements, I'm just trying to shrink it further if possible. A filler word is an apparently meaningless word, phrase, or sound that marks a pause or h...
Given n=m^2, return a list of integers that do not border the m x m grid of integers from 1 to n. Examples n=1 (m=1) Grid: [1] Return: [] n=4 (m=2) Grid: [1,2] [3,4] Return: [] n=9 (m=3) Grid: [1,2,3] [4,5,6] [7,8,9] Return: [5] n=16 (m=4) Grid: [ 1, 2, 3, 4] [ 5, 6, 7, 8] [ 9,10,11,12] [13,14,15,16] Return: [6,...
Your challenge is to implement a cyclic Program Sequence Generator (PSG) in a language of your choice. Given a language, L, a PSG in L is a program in L that outputs a PSG in L. Some properties of a PSG are: Repeated execution of a PSG in L generates a sequence of programs in L. A PSG is said to be cyclic if the seque...
Normal brackets ((),[],<> and {}) are nice and unambiguous, however someone thought it would be a good idea to use non bracket characters as brackets. These characters, | and ", are ambiguous. For example does """" correspond to (()) or ()() It is impossible to tell. Things start to get interesting when you mix ty...
This challenge was originally sandboxed by Magic Octopus Urn; I adopted and posted it with his permission. This is the cops' thread. The robbers' thread is here. The challenge Step One: Write a piece of code (function or full program) which checks for primality. Step Two: Remove pieces of your code by replacing charac...
This is the robbers' thread. The cops' thread is here. Your challenge is to take an uncracked submission from the cops' thread and try to find the original unredacted program. Please comment on the cop's submission when you've cracked their code.
Challenge The challenge is to write a code that takes a positive integer 'n' as an input and displays all the possible ways in which the numbers from 1 - n can be written, with either positive or negative sign in between, such that their sum is equal to zero. Please remember that you may only use addition or subtractio...
It's annoying when you have to search for a language homepage, get its link, and add it to your SE comment/answer, right? Let's write a script to do that for you! Challenge For each language name (intentional or not) in the input, replace it with the markdown link to the language home page, defined by TIO. Rules (impo...
Challenge For this challenge, a mountainous string is one that conforms to the grammar rule M: x(Mx)* where at each production, the all x's are the same character. When indented, a mountainous string might look something like this: A B C D C E F E C B A As you can see, it looks a bit like a mounta...
The brethren from the order of St Golfus the Concise have a tradition of reciting a short prayer whenever they see someone make the sign of the cross. Due to the high level of sin measured among tourists recently, they have installed CCTV in the monastery, and they've hired you to help them keep old tradition alive in ...
Challenge Given a real number as input, calculate the number of times which the natural logarithm function ln can be applied to it before the resulting number becomes imaginary. Explanation Applying ln to a negative number results in a non-real number. This means that, by repeatedly applying ln to a number, you will ev...
There are n places set around a circular table. Alice is sat on one of them. At each place, there's a cake. Alice eats her cake, but it doesn't taste very nice. Then the Mad Hatter comes in. He gives Alice a list of n-1 numbers, each between 1 and n-1. For each item i in the list, Alice has to move around i places and ...
Triangularity is a new esolang developed by Mr. Xcoder where code structure has to follow a very specific pattern: For the nth line of code, there must be exactly 2n-1 characters of the program on it. This causes a triangular/pyramid shape, with the first line having only one character and the rest increasing by inc...
Quylthulg is a language by Chris Pressey that attempts to solve the problem of infix notation using what it calls panfix: like postfix, panfix does not require the deployment of arcane contrivances such as parentheses to override a default operator precedence. At the same time, panfix allows terms to be specified in t...
Haskell has this neat(-looking) feature where you can give it three numbers and it can infer an arithmetic sequence from them. For example, [1, 3..27] is equivalent to [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27]. That's cool and all but arithmetic sequences are fairly limiting. Addition, pfft. Multiplication's ...
Given the following input: An integer n where n > 0. A string s where s is not empty and s~=[0-9A-Z]+ (alpha-numeric capitals only). Using a standard, simplified QWERTY keyboard (as shown below): 1234567890 QWERTYUIOP ASDFGHJKL ZXCVBNM Perform the following operation: Find the original row that each character is in...
Last month I borrowed a plenty of books from the library. They all were good books, packed with emotions and plot-twists. Unfortunately, at some points I got very angry/sad/disappointed, so I tore some pages out. Now the library wants to know how many pages I have torn out for each book. Your goal is to write a program...
On PPCG, we have had lots of challenges where the length of your output is dependent on the length of your source code. For the purposes of this challenge, we will call these Source-length problems. The two most well known examples of source-length problems are Output with the same length as the code (the 1X source-l...
You are given an array A of n strictly positive integers, with n ≥ 2. Your task is to map each entry Ai to: 1 if Aj mod Ai is odd for each j such that 1 ≤ j ≤ n and j ≠ i 2 if Aj mod Ai is even for each j such that 1 ≤ j ≤ n and j ≠ i 0 otherwise (mixed parities) Example For A = [ 73, 50, 61 ], we have: 50 mod 73 = ...
A repost of this challenge. Meta discussion. Sandbox post. Body of the question similar to the original Robber's challenge This cops and robbers is now (08/03/2018) closed to further competing cop entries, as robbers may no longer be competing to crack answers, but feel free to post new answers. The Cops challenge was...
Cops challenge The Robbers' Challenge Find a vulnerable answer. That is, an answer which hasn't been cracked yet and which isn't safe yet either. Crack it by figuring out its language. That is, find any language in which the given program is a valid program (subject to the rules outlined in the Cops' Challenge above)...
Choose a set of four bytes without replacement (i.e. no byte repeated), and not necessarily in any particular order, from any one of the following four sets: The characters of any one single-byte encoding The Unicode characters in the range 00–FF The signed decimal integers in the range −128–127 The unsigned decimal i...
Most everyone here is familiar with Pascal's Triangle. It's formed by successive rows, where each element is the sum of its two upper-left and upper-right neighbors. Here are the first 5 rows (borrowed from Generate Pascal's triangle): 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 . . . Collapse these rows to the left 1 1...
Introduction Write a program to output the outgoing spiral of the famous pangram following given rules. Challenge A pangram is a sentence using every letter of a given alphabet at least once. One of the most famous pangrams is the one used extensively in Windows font viewer, namely "The quick brown fox jumps over the l...
This is a different type of compression challenge. In a normal kolmogorov-complexity challenge, you are required to recreate a list exactly. Here, you are allowed to round the values in any way you wish. What's the catch? Your score is penalized based on how wrong your output is. At the bottom of this question is a...
Write a code that runs or compiles in as many programming languages as possible and prints a newline separated list of names of previous and current programming languages. Every used language must have 1 character longer name than previous; ex. C#, C++, Ruby, Jelly, Python... Each language must output a list of langua...
Note This is the encryption challenge. The decryption challenge can be found here. Challenge The challenge is to encrypt a given string, using the rules as specified below. The string will only contain lowercase alphabets, digits, and/or blank spaces. Equivalent of a Character Now, firstly you would need to know how to...
An Izhikevich neuron is a simple yet quite effective model of a biological neuron, designed for use in a discrete time-stepping simulation. In this golfing challenge, you will be implementing this model. Parameters This model involves only 7 variables organized into 2 differential equations, compared to the dozens of p...
Context Consider square matrices with n columns and rows containing the first n^2 (i.e. n squared) positive integers, where n is odd. The elements of the matrices are arranged such that the integers 1 through n^2 are placed sequentially in a counterclockwise spiral starting at the center and initially moving to the lef...
Your task is to write a computer program such that when it is cut up into lines (split on the newline character) every arrangement of the lines will output a different number between 1 and n! (where n is the total number of lines). No number should be output by two different arrangements and every arrangement should o...
I was messing around with infinite resistor networks (long story) when I came across the following interesting recursive pattern: |-|| |--- Each instance of this pattern is twice as wide as it is tall. To go from one level of the pattern to the next, you break up this rectangle into two sub-blocks (each of which is a ...
Amazingly, this is the easier of the three card tricks I know off the top of my head... The aim of this is to have your compiler perform a specific card trick. There's no slight of hand, and the compiler won't be memorizing the choice and saying "Voila, this is your card!" The code will basically manipulate a stack of ...
Introduction: I collect twisty puzzles, so I'm quite the fan of rubiks-cube-challenges (even though most are fairly difficult). So, let's try a fairly easy rubiks-cube-challenge for a change. When an NxNxN Cube gets scrambled during a WCA (World Cubing Association) competition, the cube is always held in the same way b...
You will be given a square matrix of integers M and another positive integer n, strictly smaller than the size of M. Your task is to generate all square sub-matrices of M of size n. For the purposes of this challenge, a square sub-matrix is a group of adjacent rows and columns contained in M. Input / Output Formats Yo...
Statement Given N distinct integers, output them in order such that for any integer J from 2 to N, for any K>0 obtainable by dividing J by 2 (rounding down) at least one time, the Jth integer output is larger than the Kth if and only if the division by 2 that gave K (i.e., the last division) divided an odd integer...
A cyclic difference set is a set of positive integers with a unique property: Let n be the largest integer in the set. Let r be any integer (not necessarily in the set) greater than 0 but less than or equal to n/2. Let k be the number of solutions to (b - a) % n = r where a and b are any members of the set. Each solu...
Yes, It's basically You're a Romanizer, Baby, but harder. like, way harder. Learning Korean is HARD. at least for a person outside Asia. But they at least have the chance to learn, right? What you must do You will be given a Korean Statement. For example, 안녕하세요. You must convert the input to its Roman pronunciation. ...
Jack is a little businessman. He found out a way to earn money by buying electricity on days when it's cheap and selling it when it's much more expensive. He stores the electricity in a battery he made by himself. Challenge You are given N (if required), the number of days Jack knows the cost of electricity for, and X,...
John has made an array of numbers which are important to him. Unfortunately, John lost the array. Luckily, he knows some details about the array. You will receive each of these sets of details (which are lists of 3 integers). Each detail is the sum of a section of the list. Each has the numbers a, the starting index...
Most Android smartphones allow the user to use a swipe pattern to open their phone: Certain patterns are legitimate, and others are impossible. Given an input swipe pattern, return a truthy or falsy indicating if the given input pattern is legal or not. Input The grid is labelled row-wise 1 through 9: 1 2 3 4 5 ...
Pancake sorting is the colloquial term for the mathematical problem of sorting a disordered stack of pancakes in order of size when a spatula can be inserted at any point in the stack and used to flip all pancakes above it. A pancake number P(n) is the minimum number of flips required for n pancakes. 1 In 1979, a you...
A palindrome is a string which is the same when read forwards and backwards. For example "racecar" is a palindrome, but "Racecar" is not. A substring is a contiguous set of characters in a larger string. Your task is to write a program or method which takes a string or character array as input and outputs the length of...
Given a string l, find all palindromic substrings p of l (including duplicates and single character strings). Next, rearrange all sub-strings in p into a valid palindrome (there may be multiple correct answers). If it is not possible to rearrange p into a single palindrome, your program may have undefined behavior (err...
Bertrand's Postulate states that for every integer n ≥ 1 there is at least one prime p such that n < p ≤ 2n. In order to verify this theorem for n < 4000 we do not have to check 4000 cases: The Landau trick says it is sufficient to check that 2, 3, 5, 7, 13, 23, 43, 83, 163, 317, 631, 1259, 2503, 5003 are all prime. ...
Output or display the following three lines of text, exactly as they are shown below. A trailing newline is accepted. bC#eF&hI)kL,nO/qR2tU5wX8z A!cD$fG'iJ*lM-oP0rS3uV6xY9 aB"dE%gH(jK+mN.pQ1sT4vW7yZ That block of text is the same as the one below, but where the n'th column is rotated n times downward: !"#$%&'()*+,-./...
Sequence Definition Construct a sequence of positive integers a(n) as follows: a(0) = 4 Each term a(n), other than the first, is the smallest number that satisfies the following: a) a(n) is a composite number, b) a(n) > a(n-1), and c) a(n) + a(k) + 1 is a composite number for each 0 <= k < n. So we start with a(0) =...
Given a list of positive integers determine if there is an element that is either greater than its two neighbors or less than its two neighbors (a "bump"). To be clear a bump can never be the first or last item of the list because they only have one neighbor. Your program should output one of two consistent values eac...
Yabasic, or Yet Another Basic is a dialect of basic created by Marc-Oliver Ihm that may be run on Windows, Unix and PAL versions of the Sony PlayStation 2. Development for this language is ongoing. Helpful Resources Yabasic Official Website Yabasic Manual Yabasic Wikipedia Page Yabasic GitHub Yabasic PS2 Documentatio...
This page is not for Visual Basic .NET Tips or VBA tips Visual Basic (VB or VB6) is an object-oriented and event-driven dialect of basic that was developed and released by Microsoft in 1991. The last release of Visual Basic came as Visual Basic 6.0 in 1998, and the language was declared a legacy language in 2008. Visu...
This page is not for Visual Basic Tips Visual Basic .NET (VB.NET) is an multi-paradigm dialect of basic that was developed and released by Microsoft in 2002 as a replacement for Visual Basic. The current version of VB.Net as of Feb 2018 is Visual Basic .NET 15.0. Unlike Visual Basic (VB), Visual Basic .NET (VB.NET) is ...
Local periods Take a non-empty string s. The local period of s at index i is the smallest positive integer n such that for each 0 ≤ k < n, we have s[i+k] = s[i-n+k] whenever both sides are defined. Alternatively, it is the minimal length of a nonempty string w such that if the concatenation w w is placed next to s so t...
This is a brainfuck version of Largest Number Printable, and this. Let's think about brainfuck interpreter such that, Has array that can be stretched left & right arbitrary large Each cell can contain arbitrary large integer Can contain negative integer too When the interpreter starts, every cell is intialized by ...
Please participate in the meta discussion about reopening this challenge before casting a vote. Introduction This challenge was inspired by semicolon-#. Deadfish is a non-Turing-complete programming language, created by Jonathan Todd Skinner. It has an accumulator register and contains 4 commands, i, d, s, and o, sta...
A permutation of size n is a reordering of the first n positive integers. (meaning each integer appears once and exactly once). Permutations can be treated like functions that change the order of a list of items of size n. For example (4 1 2 3) ["a", "b", "c", "d"] = ["d", "a", "b", "c"] Thus permutations can be co...
Given an unsorted list of unique strictly positive integers, minimally sort it into a 2D matrix. The input list is guaranteed to be of composite length, which means the output matrix is not necessarily square, but is of size n x m with n,m > 1. "Minimally sort" here means the following: Sort the list in ascending orde...
Write the shortest code you can solving the following problem: Input: An integer X with 2 <= X and X <= 100 Output: Total combinations of 2, 3, and 5 (repetition is allowed, order matters) whose sum is equal to X. Examples: Input: 8 Output: 6, because the valid combinations are: 3+5 5+3 2+2+2+2 2+3+3 3+2+3 3+3+2 Inp...
tl;dr: Output the values where the reduced prime factorization leader changes. Every positive integer has a unique prime factorization. Let's call the reduced prime factorization just the list of multiplicity of the prime factors, ordered by the size of the factors. For instance, the reduced prime factorization of 1980...
Polystrips are a subset of polyominoes conforming to the following rules: each piece consist of 1 or more cells no cell can have more than two neighbours the cells should not enclose a hole Free polyominoes are distinct when none is a rigid transformation (translation, rotation, reflection or glide reflection) of ano...
Goal You will be given a positive integer number less than 10^20. You must convert it to Korean. For example, if the input is 12345, the output should be 일만이천삼백사십오. Technical details (Small) Let's starts with simple numbers. // 1 - 9 1 -> 일 2 -> 이 3 -> 삼 4 -> 사 5 -> 오 6 -> 육 7 -> 칠 8 -> 팔 9 -> 구 // 10, 100, 1000 10 ->...
Your task is to implement a Tetris strategy balanced in terms of score vs code size. In this version of the game tetrominoes are rotated and dropped from above into a grid of 20 rows and 10 columns. While falling, they cannot be rotated or moved horizontally. As usual, a dropped piece stops when it reaches the bottom o...
Guidelines Task Write a function that takes in a sentence (a string, or list of characters) and reverses all the words that are greater than or equal to 5 in length. Examples "Hey fellow code golfers" -> "Hey wollef code sreflog" "I aM noT a cAr" -> "I aM noT a cAr" "I Am a tRaiN" -> "I Am a NiaRt" Rules Since this ...
Guidelines Task Given a DNA strand, return its RNA complement (per RNA transcription). Both DNA and RNA strands are a sequence of nucleotides. The four nucleotides found in DNA are adenine (A), cytosine (C), guanine (G) and thymine (T). The four nucleotides found in RNA are adenine (A), cytosine (C), guanine (G) and ur...
Guidelines Task Given two non-negative integers, find the sum of both numbers... to the power of 4. Examples 2, 3 -> 97 (2^4 + 3^4 = 97) 14, 6 -> 39712 (14^4 + 6^4 = 39712) 0, 25 -> 390625 (0^4 + 25^4 = 390625) Rules You will only ever receive two non-negative integers as input (bonus points if you get it to work wi...
or: Build a vertical quine Inspired by Take a stand against long lines. Your task is to build a vertical quine with as short a line length as possible. Scoring Shortest line length (excluding newlines) wins, with code-golf criteria as a tie-breaker. Line length is determined as the longest line in your program excludin...
Your task is to write a program which prints following four verses extracted from the lyrics from The Beatles' song "Hey Jude" (© Sony/ATV Music Publishing LLC): Hey Jude, don't make it bad\n Take a sad song and make it better\n Remember to let her into your heart\n Then you can start to make it better\n \n Hey Jude, d...
Related. Given a printable ASCII string, split it into a list of non-empty strings with a new sub-string beginning every time a character, which has not previously been seen in the same case, occurs. Examples "mississippi" → ["m","i","ssissi","ppi"] "P P & C G" → ["P"," P ","& ","C ","G"] "AAA" → ["AAA"] "Adam" → ["...
The Challenge Given a number, find the sum of the non-composite numbers in the Fibonacci sequence up to that number, and find the prime factors of the sum. For example, if you were given 8, the non-composite numbers would be 1, 1, 2, 3, and 5. Adding these up would get 12. The prime factors of 12 are 2, 2 and 3, so you...
Guidelines Task Given two notes, inputted as strings or lists/arrays, calculate how many semitones apart they are (inclusive of the notes themselves), outputting as a number. Explanation of a semitone: A semitone is one step up or down the keyboard. An example is C to C#. As you can see below the note C is on a white n...
Stack Cats is a reversible, stack-based language. Its reversible nature makes for somewhat weird loops. This challenge is about the conditional loop (...). When these loops are nested in certain ways, it's possible to transform the code to reduce the nesting depth. Here are the rules (where A and B stand for an arbitra...
So, I wrote myself a one-liner which printed out a snake on the console. It's a bit of fun, and I wondered how I might condense my code... Here's a (short) example output: + + + + + + + ...
Introduction Write a solver for integer linear programming. Challenge Your task is write a solver for integer linear programming (ILP). In ILP, linear inequalities of a set of unknowns (all of which are integers) are given, and the goal is to find the minimum or maximum of a linear function. For example, for the inequa...
The first magic card trick I ever learned as a child was the following: Have 1 deck of cards where the pattern on the back is not vertically symmetric. Organize all cards to be facing one direction. Ask an individual to, "pick a card, any card, memorize it and give it back to you". Proceed to put it into the deck (in ...
It is easy to describe a finite state machine that recognizes multiples of 9: keep track of the digit sum (mod 9) and add whatever digit is accepted next. Such a FSM has only 9 states, very simple! By the equivalence between FSM-recognizability and regular languages, there is a regular expression for multiples of 9. Ho...
This is a very simple challenge, and it is to print the numbers -1, 0, and 1. The following paragraph is credited to Print numbers from 1 to 10 Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), and pr...
Given an ordered list of numbers (possibly with leading zeros), arrange the numbers vertically, then let all zeros drop all the way to the bottom and all overhangs drop to the bottom-most open slot. Output the resulting integers, removing leading zeros. Worked Example Say we were given the following as input: ['0000312...
Inspired by this unassuming StackOverflow question. The idea is simple; given a String and an array of Strings, remove any instances of words in the array (ignoring case) from the input String other than the first, along with any additional whitespace this may leave. The words must match entire words in the input Strin...
Very heavily inspired by this challenge Code Golf: Your own pet ASCII snake - I thought making it horizontal would add an extra layer of complexity. An example horizontal snake: 0 0 0 0 0 000 00 0 00 000 0 0 000 0 0 0 00 0 ...
In this challenge you will be given an alphabetic string as input. We will define the "anti-string" of a given input to be the string with the case of all the letters inverted. For example AaBbbUy -> aAbBBuY You should write a program that takes a string as input and searches for the longest contiguous substring who...
Given a list of n strings, return a list of that strings in ascending order. However, be aware, that in this case we want integer comparison for all numbers appearing in the strings, meaning that "12" > "3". Example cases: {"abc123", "abc6", "abc47", "abd49"} -> {"abc6", "abc47", "abc123", "abd49"} {"foo0", "bar12", "f...
Recently there have been a couple of ASCII pet snake challenges (e.g. here) 0 0 0 0 0 000 00 0 00 000 0 0 000 0 0 0 00 0 000 This challenge is to take a randomly generated horizontal pet snake (height of five line...
This task is to output the shortest path to a file, after glob expansion. What is shell globbing? In most shells, you can use the * character in a path to represent any characters at the position. For example, If directory foo contains files bar baz and asdf, then foo/b* will expand to foo/bar foo/baz. Now, lets say t...
Introduction Your task is to generate the first 1000 terms in the continued fraction representation of digit-wise sum of square root of 2 and square root of 3. In other words, produce exactly the following list (but the output format is flexible) [2, 6, 1, 5, 7, 2, 4, 4, 1, 11, 68, 17, 1, 19, 5, 6, 1, 5, 3, 2, 1, 2, 3,...
Task Given an array of non-negative integers a, determine the minimum number of rightward jumps required to jump "outside" the array, starting at position 0, or return zero/null if it is not possible to do so. A jump from index i is defined to be an increase in array index by at most a[i]. A jump outside is a jump wher...
...or "snakes but not too long". Inspired by this challenge and this comment. Task Write a program or a function that takes no input and outputs its own source code formatted as a snake according to the rules below: If your code has any whitespace, it will not be output; it will just be skipped. There will be one char...
Inspired by We do tower hopping and related to 2D Maze Minus 1D Introduction Your task is to find the shortest path to get out of an array maze following specified rules. Challenge A 1D array a with n elements can be regarded as a maze composed of n points, where point with index k is connected to the points with k+a[k...
I was at a friend's house for dinner and they suggested the idea of a "Prime-factor vector space". In this space the positive integers are expressed as a vector such that the nth element in the vector is the number of times the nth prime divides the number. (Note that this means that our vectors have an infinite numb...
We have some new sheriffs moderators in town, Mego and DJMcMayhem. We need a challenge to properly honour them for their new positions, so there we go. Here's something that has caught my attention when hovering over their profiles – their user IDs are \$31716\$ and \$45941\$. If you perform digit-wise subtraction, y...
A Brainfuck derivative Let's define a simple Brainfuck-like programming language. It has a two-directional tape of cells, and each cell holds one bit. All bits are initially 0. There is a moving head on the tape, initially at position 0. A program is a string over the characters <>01!, executed from left to right, with...
There's already a comprehensive list of tips for python here, so what I'm asking for are tips that specifically apply to using the numpy, scipy or pylab libraries. These can be either ways to shorten code already using numpy, or ways to shorten common python operations by using these libraries. One tip per answer, plea...