instruction
stringlengths
34
53.1k
Inspired by the job-interview with Joel Grus, the goal of this challenge is to write a tensorflow (or other deep/machine learning) program that learns Fizzbuzz and correctly prints out the answers to the positive integers less than 1000. You can assume there are files named train.csv and test.csv and each contain a so...
The formula Take for instance the number 300 The prime factors of 300 are [2, 3, 5] (unique numbers that are factors of 300 and prime) Squaring each of those numbers will give you [4, 9, 25] Summing that list will give you 4 + 9 + 25 = 38 Finally subtract that sum (38) from your original number 300-38 = 262 (this is ...
A function is said to have a cycle of length n if there exists an x in its domain such that fn(x) = x and fm(x) ≠ x for 0 < m < n, where the superscript n denotes n-fold application of f. Note that a cycle of length 1 is a fixed point f(x) = x. Your task is to implement a bijective function from the integers to themsel...
Back in the day, all the 1337 kids used text faders in chatrooms. I don't know about you guys, but I want to feel cool like they did. The only problem is that their old scripts and applications were heavily coupled to the software they were made for, so I can't just make use of this amazing functionality wherever I wan...
In this challenge, you need to find a specific pixel within an photograph (taken with a real camera). You are passed an (R, G, B) tuple and an image, and you need to return a point (x,y) within the image that matches the RGB color given. The image may have multiple points that match the color; you only need to find 1....
Uptime is a very important metric, as we all know, so we'd like to measure the uptime since our service was first launched. The SLA specifies an uptime of a certain number of nines, such as 3 nines for at least 99.9% uptime, or 1 nine for at least 90% uptime, and you're wondering if you've actually met the SLA or not. ...
To dynamically include a JavaScript file in a web page, you'd normally insert a <script> tag pointing to your script. For example: var js_file= document.createElement("script"); js_file.src='http://example.com/js.js'; document.body.appendChild(js_file); Write JavaScript code will load an external JavaScript file in th...
Given an integer N >= 1, output the mean number of bits in an integer from 0 to N - 1 Specification The output can be calculated as the sum of the number of bits in the binary representation of each integer from 0 to N-1, divided by N. The binary representation of an integer has no leading zeroes in this context, with...
This question is probably harder than all of those "generate a sequence of numbers" tasks, because this requires TWO sequences working in unison. Really looking forward to the answers! In his book "Gödel, Escher, Bach: An Eternal Golden Braid", Douglas Hofstadter has a quite few sequences of numbers inside, all of them...
A paragraph of text has numbers and alphabetic letters mixed. Your task is to separate the numbers to the left side and the alphabetic letters to the right side in the same order of each line. Rules: Numbers are plain integers; so no decimal point, and no negative/positive signs. Numbers may or may not be contiguous,...
I am shamelessly posting a request for something I would actually find useful. The task is to take an arbitrary ascii box drawing like this | +----+----+ | state A +---+ +---------+ | | +----v----+ | state B | +---------+ ... and turn it into something more beautiful us...
Given a string containing only 0's 1's, 2's and brackets, output the grammar tree of the string. A 2 requires 2 arguments - one to the left and one to the right A 1 requires a single argument - to either the left or right A 0 doesn't require any arguments and is the base case A pair of brackets counts as one argument a...
Given a mapping from the integers from 1 to N to the integers from 1 to N, determine if the mapping is surjective, injective, bijective, or nothing. You may choose any character/digit for the four outputs. Specs Input format: n, arrays of pairs (n is the highest number in the domain and range) For example, if the first...
Write one/two program(s)/function(s): The first one should return a truthy value if given your Stack Exchange username. ~~Optional~~ An obfuscated one (as explained below) that does the same thing. Rules for number 2: May be no more than ten times the byte-count of number 1 or 100 bytes, whichever is higher. Must ...
Air balloons need a gas that is lighter than air. However, hydrogen is flammable, while helium is not sustainable, so we need a replacement! You must write code that determines whether any given gas is lighter than air. Input: a molecular chemical formula of a gas (ASCII) Output: true if the gas is lighter than air; f...
Inspired by this question which was further inspired by this one, write a program which takes two integers and adds them in a unique way, by performing an OR operation on the segments used to display them in a 7-segment display. For reference, the digits are represented in the following way: _ _ _ _ ...
Identicons are visual depictions of hash values, often made from symmetrical arrangements of geometric shapes. Your default Stack Exchange avatar is an identicon. This challenge is about creating "wordenticons", simple text-based versions of identicons that apply to strings of lowercase letters, i.e. words. Challenge W...
This is not a duplicate of this question. This is asking for the nth number that can be represented as the sum of two cubes in two different ways, while that is asking for the n-th number that can be expressed as the sum of two cubes in n ways. Introduction I was just watching The man who knew Infinity, and I thought i...
A number square containing the values 1, 2, 3, 4 looks like this: 12 34 To work out what a number square is, you first make four numbers by reading across the rows and across the columns; for the example above you would get 12, 34, 13 and 24, then you add them all up (12+34+13+24), giving you the value of the square. ...
Your challenge is to write a program (full program, not a function), that will take an integer and output all prime numbers up to (including) the given integer. Output is any readable list containing all integer primes (array, string, 1 prime per line, whatever you want) and must run to stdout or equivalent. Simple? He...
Here is the challenge as proposed by @trichoplax thanks to him for consolidating my post and standarizing it to PPCG common-rules. A galaxy is a group of numbers where each one is mapped to another via a precise function f either a symbolic one or mathematical, a structure of numbers sharing some common points with t...
Inspired by this question and refined by Luis Mendo. Challenge Given a 2D matrix of integers, each row has a maximum value. One or more elements of each row will be equal to the maximum value of their respective row. Your goal is to determine which column(s) contain the most entries which are equal to their respective ...
Find the longest run of true in a list of booleans. Return the same list, with all other trues falsified. Input, output A list; any usual format (e.g., a delimited list as a string). Details True and false can be anything your language typically uses for those values, or the integers 1 and 0. If you use single characte...
Given an input n, output the value of the Fransén-Robinson constant with n digits after the decimal place, with rounding. Rules You may assume that all inputs are integers between 1 and 60. You may not store any related values - the constant must be calculated, not recalled. Rounding must be done with the following cr...
Introduction The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (+0 is the same as -0). In the following sequence, we are going to alternate between the positive sign, the zero and the negative sign. The sequence starts with 1, so we write 1 with a positive sign, with zero (t...
Given a non empty finite sequence of integers, return an arithmetic subsequence of maximal length. If there are multiple of the same maximal length, any of them can be returned. Definitions: An arithmetic sequence is a sequence \$a(1),a(2),a(3),a(4),...\$ such that there is a constant \$c\$ such that \$a(m+1)-a(m) = c\...
Credits to @Agawa001 for coming up with this question. Explanation My new "keybore" only has 2 buttons, namely + and -. The number in the memory starts at 0. Each consecutive press of + or - will increment/decrement the memory for exactly how many times it has been pressed consecutively. Therefore, if you press + 4 tim...
RFC 2550 is a satirical proposal (published on April 1, 1999) for a space-efficient ASCII representation of timestamps that can support any date (even those prior to the beginning of the universe and those past the predicted end of the universe). The algorithm for computing a RFC 2550-compliant timestamp is as follows ...
Background Visualizing λ-calculus terms Famous lambda-juggler (and code golfer) John Tromp devised an interesting visualization of terms in the λ-calculus. In his words: abstractions (lambdas) are represented by horizontal lines, variables by vertical lines emanating down from their binding lambda, and applications by...
Consider binary block diagonal matrices which have square blocks of 1s on the main diagonal, and are 0 everywhere else. Let's call such matrices "valid" matrices. For example, here are some valid 4x4 matrices: 1 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 1 1 0 0 0 1 1 0 0 1 1 1...
Don't you find that reading simple text isn't appealing enough? Try our ##### ### ### ##### ##### ##### ##### # # ##### # # # # # # # # # # # # # # ##### ### # # # # #### # # # # # # # # # # # # # # ...
We don't have enough (semi-)easy challenges for beginners. More and more of the easy ones are already taken. So I tried to come up with something that might be achievable by beginners, but that isn't a duplicate. Input: A single string separated with your OS new-line (i.e. \r\n), or an array with multiple strings. Outp...
Your challenge is to convert a string to an ASCII art version of it. Input Your input is a single string, wich you should convert into the ASCII art version of it. Output Your output should be formatted in the following ASCII art type: _/_/_/_/ _/_/_/_/ _/_/_/_/ _/_/_/ _/_/_/_/ _/_/_/_/ _/_/_/_/ _/ _/ ...
Problem Say you have N stacks named S1 through SN, where each Sk (k = 1 to N) contains N copies of the number k. For example, when N = 3 the stacks looks like this: 1 2 3 <- top of stack 1 2 3 1 2 3 <- bottom of stack ======= 1 2 3 <- stack index Here there are 3 stacks indexed as 1, 2, and 3, and each one ...
Write a program or function with no input that prints or returns this string of 24-hour and 12-hour times: 00:00 12:00am 01:00 1:00am 02:00 2:00am 03:00 3:00am 04:00 4:00am 05:00 5:00am 06:00 6:00am 07:00 7:00am 08:00 8:00am 09:00 9:00am 10:00 10:00am 11:00 11:00am 12:00 12:00pm 13:00 1:00pm 14:00 2:00pm 15:...
Who needs to compare things case insensitively when you're able to generate every permutation of uppercase and lowercase? No one! That's the answer. No one does. Your task is to achieve this feat; generate all possible permutations of uppercase/lowercase for a given input. Input A string of printable standard ascii cha...
Background I have a bunch of old and grainy black-and-white images. Some of them depict vines climbing on a wall, others don't – your task is to classify them for me. Input and output Your input is a rectangular 2D array of bits A, given in any convenient format. It will not be empty, but it's not guaranteed to contain...
Statement Given an input like this 35 15 0 0 10 that matches the following constrains: Width in characters of the grid (5-50) Height in characters of the grid (5-25) Initial X position of the ball (0-(Width-1) Initial Y position of the ball (0-(Height-1) Number of movements to simulate Generate a grid that shows the ...
For every given degree \$n\$ it is possible to construct (at least one) an integral polynomial \$p \in \mathbb Z[X]\$ such that \$p(k)\$ (\$p\$ evaluated in \$k\$) is the coefficient of the term \$x^k\$ in the polynomial for all \$0 \leqslant k \leqslant n\$. To make them unique, we require the leading coefficient (the...
"Digital sum" refers to the sum of all the digits in a number. For example, the digital sum of 1324 is 10, because 1+3+2+4 = 10. The challenge is to write a program/function to calculate the smallest number bigger than the input whose digital sum is the input. Example with walkthrough As an example, take the number 9 a...
What's the Binary Time? Everybody knows what the normal time is. It's up there in the top-right (or wherever you put it) of your screen. But a question people rarely seem to ask themselves is this: What's the binary time? Binary Time Binary Time (True Binary Time) works by first reading the most significant bit (MSB) o...
Cosmic rays are bad for computers. They corrupt RAM, and that causes problems. Computer chips are shrinking, and that makes them more vulnerable to the cosmic rays. We will not give in to these high-energy particles. Turing-completeness shall live on! Task Your task is to write a Turing machine. But not just any Turing...
Task Given an input list of integers x1…xn, compute a list of ranks r1…rn (a permutation of {1…n}) so that xr1 ≤ xr2 ≤ … ≤ xrn. Then, for each xi, replace its rank by the arithmetic mean of the ranks of all values in x that are equal to xi. (That is, whenever there is a tie between equal values in x, fairly redistribut...
This is my first codegolf question, so I apologize in advance if it's not appropriate, and I welcome any feedback. I have a file with this format: a | rest of first line b | rest of second line b | rest of third line c | rest of fourth line d | rest of fifth line d | rest of sixth line The actual contents vary, as do...
Background Jelly's arithmetic atoms vectorize automatically. In fact, x + y is well-defined whenever x and y are numbers or ragged arrays of numbers. Jelly's source code implements this behavior using a generic vectorizer, but for this challenge, we'll only consider addition of integers and nested integer arrays. Defin...
(Inspired by this question) Objective Your task is to write a program or function to print an ASCII version of the Stack Overflow logo to STDOUT \|/ (-) (-) (-) (-) Your program should take two inputs, referred to here as H and N. The height of the stack "container" (the parentheses) is determined by H. The number of...
Let's build a simulation for an aspect in the card game, which I personally know by the Dutch name 'Oorlog' (translates to 'War'). How does 'Oorlog' work? Two decks of cards (each including two Jokers) are equally divided between the amount of players playing. Each player shuffles their own stock, put it upside down in...
Given a sequence of bytes, output the SHA-256 hash value of the sequence. The SHA-256 Algorithm The following pseudocode is taken from the Wikipedia page for SHA-2. Note 1: All variables are 32 bit unsigned integers and addition is calculated modulo 2^32 Note 2: For each round, there is one round constant k[i] and one ...
Remember that a set is unordered without duplicates. Definition An N-uniquely additive set S whose length is K is a set such that all N-length subsets in S sum to different numbers. In other words, the sums of all the N-length subsets of S are all distinct. Objective Given an array/set as input and a number N to a func...
Task description Given an integer, swap its (2k–1)-th and 2k-th least significant bits for all integers k > 0. This is sequence A057300 in the OEIS. (The number is assumed to have “infinitely many” leading zeroes. In practice, this simply means prepending a single 0 bit to odd-length numbers.) This is code-golf, so th...
Write a program or function that takes in a nonempty list of positive integers. You may assume it is input in a reasonable convenient format such as "1 2 3 4" or [1, 2, 3, 4]. The numbers in the input list represent the slices of a full pie chart where each slice size is proportional to its corresponding number and all...
(Follow-up to my question about swapping bits with their neighbours.) Task Given a positive integer x = (2a · 3b) · (5c · 7d) · (11e · 13f) · …, print the integer obtained by swapping the exponents in this factorization for each successive pair of primes, y = (2b · 3a) · (5d · 7c) · (11f · 13e) · … A061898 in the OEIS....
This one is simple to describe and I could hardly believe that this was not golfed before: For a given image (whatever format is supported by your language), find the unique colors and output a list of the colors. Print the color code in hex RGB, that is a hash sign # followed by 2 digits for R, 2 digits for G and 2 ...
Background / Description Note: as @HelkaHomba points out, the actual GitHub identicons are not actually random but based on the hash of a username The default GitHub avatar is a 5x5-pixel image. A color is picked randomly, and then random pixels are filled in on one side (right or left, 2x5 size) using that color. Then...
A Faro shuffle is a technique frequently used by magicians to "shuffle" a deck. To perform a Faro shuffle you first cut the deck into 2 equal halves then you interleave the two halves. For example [1 2 3 4 5 6 7 8] Faro shuffled is [1 5 2 6 3 7 4 8] This can be repeated any number of times. Interestingly enough, if y...
The card game War is interesting in that the final outcome is entirely determined by the initial arrangement of the deck, so long as certain rules are followed for the order in which cards are picked up from the playing field and moved to decks. In this challenge, there will only be 2 players, simplifying things greatl...
(via chat) The OEIS entry A123321 lists the sequence of numbers that are the product of seven distinct primes. For brevity, we'll call this a 7DP number. The first few numbers and their corresponding divisors are below: 510510 = 2 * 3 * 5 * 7 * 11 * 13 * 17 570570 = 2 * 3 * 5 * 7 * 11 * 13 * 19 690690 = 2 * 3 * 5 * 7 *...
Geobitsian language is a new perversion of English where a word is broken into segments that each must start with a different letter. Then every time one of those starting letters appears in another string, it is replaced with its entire corresponding segment, maintaining capitalization. This process is called Geobitsi...
Cribbage is an interesting game, because you need a specific board to score your game. A cribbage board looks like this: Notice how the first column is on the left as it goes up, then on the right as it goes down, then back on the left as it goes up again. And here is what a poorly drawn rendered ASCII art of a cribba...
Given a list of integers L, and an integer N, output L splitted in N sublists of equal lenghts. Non-divisible lengths If N does not divide the length of L, then it is not possible that all sublists have equal length. In any case, the last sublist of the output is the one that adapts its length to contain the remainder ...
Task Define a simple regex as a non-empty regular expression consisting only of characters 0 and 1, grouping parentheses ( and ), one-or-more repetition quantifier +. Given a non-empty string of 0s and 1s, your program should find the shortest simple regex matching the full input string. (That is, when matching a sim...
The happy ending problem (actually a theorem) states that Any set of five points in the plane in general position has a subset of four points that form the vertices of a convex quadrilateral. The problem was so named by Paul Erdős when two mathematicians who first worked on the problem, Ester Klein and George Szekere...
The 3BV of a Minesweeper board represents the minimum number of left clicks required to solve the board if you already know the solution. It stands for "Bechtel's Board Benchmark Value". Here's his site explaining it. Below is a solved Minesweeper board. The flags indicate mines; tiles without mines indicate the count ...
Write a program using only printable ASCII characters that takes no input. For reference, here are the 95 printable ASCII characters in order: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ When your program is run it should print 0 (plus an optional trailing newline) t...
There is a rather curious number which shows up sometimes in math problems or riddles. The pseudofactorial(N) is the least (i.e. lowest) common multiple of the numbers 1 through N; in other words, it's the lowest number which has all numbers from 1 through N as factors. For instance pseudofactorial(7) = 3 * 4 * 5 * 7, ...
Background: Here's a little simple challenge. You want to be able to find out whether the arrays inside an array have the same length. Input: Your input should consist of exactly one array (this is the value passed to the function, not a user input). Your function takes exactly 1 parameter. It could contain arrays or ...
In a project I am working on, I am checking to see if certain DNA sequences appear in certain genes in E. coli. I have written a program in Java that performs the below features. However, since I wrote my program in Java, the universe needs to be corrected and rid of verbosity by having you write your code in as few by...
This is similar to simplifying fractions, but with Dates! The input of your program must be of the form mm/dd For example 3/4 //March 4 12/15 //December 15 1/1 // January 1 We assume that the input will be valid such that the months have these numbers of days in them: January 31 February 28 March 31 April 30 May 31 Ju...
Well, sum it down really. Write a program or function that takes in a nonempty list of decimal integers (0-9) and outputs a downward pointing "triangle" of digits with the input list at the top where every digit after the first line is the sum of the two digits above it modulo 10. For example, the input [7, 5, 0, 9] ha...
Tonight, my fiancée took me out to dinner to celebrate my birthday. While we were out, I heard Happy Birthday sung to 5 different guests (including myself), in a restaurant full of 50 people. This got me wondering - the original birthday problem (finding the probability that 2 people in a room of N people share the sam...
Introduction and Credit We all know and love our awesome rules to test whether a number is divisble by 11 or 3, which is just some clever sum over the digits of the number. Now this challenge takes this to a new level, by requiring you to compute the sum of the digits and then checking whether the result is a perfect i...
We all know that the Euler's number, denoted by \$e\$, to the power of some variable \$x\$, can be approximated by using the Maclaurin Series expansion: $$e^x=\sum_{k=0}^{\infty}{\frac{x^k}{k!}}=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\dots$$ By letting \$x\$ equal \$1\$, we obtain $$\sum_{k=0}^{\infty}{\frac{...
Write a program/function that returns the vote count of its own Stack Exchange answer at the time of its execution. Your program/function may access this page (codegolf.stackexchange.com/questions/82609) off the internet, however: Your program/function may not accept any user input and The use of URL shorteners is not...
This challenge is very simple. You are given as input a square matrix, represented in any sane way, and you have to output the dot product of the diagonals of the matrix. The diagonals in specific are the diagonal running from top-left to bottom-right and from top-right to bottom-left. Test Cases [[-1, 1], [-2, 1]] ->...
Implement the Discrete Fourier Transform (DFT) for a sequence of any length. This may implemented as either a function or a program and the sequence can be given as either an argument or using standard input. The algorithm will compute a result based on standard DFT in the forward direction. The input sequence has leng...
In a single file, write a program that requires no input and produces no output. When run it should reverse the name of the file it is contained in, regardless of what the name is, without altering the code or producing other lasting side effects. Any way of achieving this is fine. It only matters that once the program...
Note: reference to Nothing up my sleeve number. Your task is to take no input and generate this exact output: d76aa478 e8c7b756 242070db c1bdceee f57c0faf 4787c62a a8304613 fd469501 698098d8 8b44f7af ffff5bb1 895cd7be 6b901122 fd987193 a679438e 49b40821 f61e2562 c040b340 265e5a51 e9b6c7aa d62f105d 02441453 d8a1e681 e7...
This is my pet emoji, Billy: -_- Emojis don't like to be in the rain, so Billy is sad... Let's draw him an umbrella to make him feel better! /\ / \ / \ -_- This is good, he is entirely covered by his umbrella! Here is an example where only part of him is covered: /\ / \ / \ -_- In this case, s...
Your dumb teacher is always wrong, so flip his answer. Change these responses True -> False Yes -> No 0 -> 1 Yeah -> Nope and vice versa. Keeping punctuation and the first letter's capitalization counts. Only one condition will be passed to the program. You only need to accept the following test cases: True <-> Fals...
Given a nonempty list of nonnegative integers, consider rewriting it as an arithmetic problem where: A plus sign (+) is inserted between pairs of numbers that increase from left to right (a.k.a. from the start of the list to the end). A minus sign (-) is inserted between pairs of numbers that decrease from left to rig...
I think most people around here know what a 7-segment display for digits is: _ _ _ _ _ _ _ _ | | | _| _| |_| |_ |_ | |_| |_| |_| | |_ _| | _| |_| | |_| _| We can define the 7-segment difference (7SD) between two digits to be the number of segments that ...
Introduction Eisenstein integers are complex numbers of the form a+bω Where a,b are integers, and ω = e^(2πi/3) The Eisenstein integers form a triangular lattice in the complex plane: We say that an Eisenstein integer z=a+bω is prime if it cannot be written as the product of two non-unit (not 1,-1,ω,-ω,ω^2, or -ω^2) ...
Last time when I tried to come up with something easy that wasn't a duplicate, it ended up being way too hard.. So hopefully this time it's indeed something newcomers can try as well. Input: An array/list with integers/decimals. (Or a string representing an array with integers/decimals.) Output: Loop through the number...
The cosmic call is a message sent into space in 1999 and 2003. It's made of 23 127*127px monochrome bitmap images, as detailed here. Your mission is to write a program that displays the entire 127*2921px message, either as a text (made of zeros, ones and line breaks) or as an image (drawn on screen or saved on disk). T...
Earlier, we did the pseudofactorial of a number, which is the LCM of the numbers from 1 to n. It would be useful in adding fractions together. However, we find that the denominator of 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 is 20 instead of the pseudofactorial of 6, which is 60. Your task is to find the denominator of 1/1 + ...
Turn the characters abcdefghijklmnopqrstuvwxyz!?., upside down and don't modify the other characters. Then, reverse the text to achieve the upside down affect. If text is already upside down, turn it right side up. Don't modify capitals. Use this as a reference: abcdefghijklmnopqrstuvwxyz!?., ɐqɔpǝɟƃɥıɾʞןɯuodbɹsʇnʌʍxʎz...
Back to basics... As a teacher at the local primary (grade?) school, you need a way to teach your class their times tables. At your disposal, you have hundred squares and a load of red pens. You need to also be able to show your class the correct answers quickly. Now, you're clever enough to write a program that can do...
Introduction We define twin primes as two natural numbers p,p+2 which both are prime. Example: 5 and 7 are twin primes. Let's define the twin number of some set of numbers as the number of twin prime numbers in that set Example: {6,7,11,13,18,29,31} has a twin number 4, since there are four twin primes; 11,13 and 29,3...
Write a program or function that takes in a positive integer N and outputs the first N numbers of this amplifying zigzag pattern, using only the lines needed: 26 25 27 . 10 ...
Given an integer N, output the Nth positive number K with the following property in decimal base: For each digit I at position P of K, the number formed from K by removing the Pth digit (i.e. I) is divisible by I. Example and remarks 324 is such a number: 3 divides 24 2 divides 34 4 divides 32 Note 1: we assume that ...
A field in mathematics is a set of numbers, with addition and multiplication operations defined on it, such that they satisfy certain axioms (described in Wikipedia; see also below). A finite field can have pn elements, where p is a prime number, and n is a natural number. In this challenge, let's take p = 2 and n = 8,...
In special relativity, the velocity of a moving object relative to another object that is moving in the opposite direction is given by the formula: \begin{align}s = \frac{v+u}{1+vu/c^2}.\end{align} s = ( v + u ) / ( 1 + v * u / c ^ 2) In this formula, \$v\$ and \$u\$ are the magnitudes of the velocities of the objects...
So task is simple, given array of numbers and result, you need to find what operations you need to use on numbers from array , to obtain requested result. Let's make it simple for start, and allow only basic operations such as: addition, subtraction, multiplication and division. Example: Input : [5,5,5,5,5] 100 Outpu...
The handshake problem is the classic problem that for n people in a room, if they all shake hands, what's the total number of handshakes that occur. You code should take an input of any number and output the number of handshakes, both in base ten. Also the code should not let non-integers through. You should output a ...
{}is the empty set. You may use () or [] if you choose. We aren't going to rigorously define "set", but sets all satisfy the following properties: Sets follow the usual mathematical structure. Here are some important points: Sets are not ordered. No set contains itself. Elements are either in a set or not, this is bo...
For example, the gate A and B is a logic gate with 2 inputs and 1 output. There are exactly 16 of them, because: each logic gate takes two inputs, which can be truthy or falsey, giving us 4 possible inputs of the 4 possible inputs, each can have an output of truthy and falsey therefore, there are 2^4 possible logic ga...
Given a natural number \$n\$, return the \$n\$-th Leyland number. Leyland Number Leyland numbers are positive integers \$k\$ of the form $$k = x^y + y^x$$ Where \$x\$ and \$y\$ are integers strictly greater than 1. They are enumerated in ascending order. EDIT: @DigitalTrauma suggested I include following "definition": ...
Almost every function can be expressed as a polynomial with infinite terms. For example, e^x = 1 + x + x^2/2! + x^3/3! + x^4/4! + ... For example, sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ... The coefficients of the n-th terms form a sequence, and the corresponding function is called the Generating Function of the seque...
Earlier, we talked about exponential generating functions (e.g.f.). Task You will take a few terms of a sequence. Your task is to find another sequence with that many terms, whose e.g.f., when multiplied to the original e.g.f., would be exactly the constant function 1 accurate to that many terms. That is, given a0=1, a...
Task Using any type of parallelisation, wait multiple periods, for a total sleep time of at least a minute (but less than a minute and a half). The program/function must terminate within 10 seconds and return (by any means and in any format) two values: the total elapsed time, and the total executed sleep time. Both ti...