instruction stringlengths 34 53.1k |
|---|
N in a row
Input:
The character and a 2-Dimensional array.
The array with a size of N x N where 1 <= N <= 26, it will be filled randomly like so:
N = 1
A
N = 2
B | A
-----
A | B
N = 3
A | B | C
----------
B | A | B
----------
C | A | C
As N increases by 1, so does the number of letters. A = 1, B = 2, C = 3. There wi... |
According to this site a general rule recommended by The U.S. Government Printing Office Style Manual is
Capitalize all words in titles of publications and documents, except
a, an, the, at, by, for, in, of, on, to, up, and, as, but, or, and
nor.
This might not be true as I'm unable to find such a recommendation i... |
The task:
You have to input 2 numbers and output the results of several operations done with them.
Details:
Input 2 floating point numbers, x != 0 and y != 0 via stdin, command line or function arguments.
Output x+y,
x*y,
x^y (pow(x,y), not x XOR y),
x-y,
y-x,
x/y and
y/x on ST... |
Monday, October 31st, is Halloween. And it got me thinking -- I wonder what other months have the last day of the month also be a Monday?
Input
A positive integer in any convenient format representing a year, 10000 > y > 0.
The input can be padded with zeros (e.g., 0025 for year 25) if
required.
Output
A list of the... |
Cheat is a card game where you're trying to get rid of your hand. A turn looks something roughly like this:
Determine what card rank you have to play that turn. In most variants this is one rank higher than the previous turn.
Play 1-4 cards, face down. These don't have to match the valid rank. If they don't, it's cons... |
Your task is to print this exact text:
az za
abyz zyba
abcxyz zyxcba
abcdwxyz zyxwdcba
abcdevwxyz zyxwvedcba
abcdefuvwxyz ... |
The goal is simple: Output a nonzero real solution x to the equation sin(x) = -mx, given input m, in the fewest number of bytes.
Specifications:
Your answer must be correct to 3 significant figures.
You may output any real solution other than the trivial solution x=0. You can assume m is such that at least one soluti... |
The goal is to output the number of the months given as input in a compact concatenated form which is still parsable if one knows the construction rules:
If either:
January is followed by January, February, November or December; or
November is followed by January or February
There must be a separator placed between.
... |
Given the width and height of a line in characters, draw it using ascii characters.
Input
Two integers separated by a space, the first one being the width, the second one being the height.
Example: 5 3
Output
An oblique line formed with the characters /\|_, that has the width and height given in the input. The characte... |
This is different from My Word can beat up your Word as it is less complex and only requires you to calculate it, and not compare them.
To find the digital root, take all of the digits of a number, add them, and repeat until you get a one-digit number. For example, if the number was 12345, you would add 1, 2, 3, 4, and... |
In Chinese, numbers are written as follows:
1 一 2 二 3 三 4 四 5 五 6 六 7 七 8 八 9 九 10 十
For numbers above 10, it is expressed as the number of tens and the number of ones. If there is only one ten, you do not need to explicitly say one, and if there are no ones, you don't need to put anything after:
11 十一
24 二十四
83 八十三
90... |
xkcd is everyone's favorite webcomic, and you will be writing a program that will bring a little bit more humor to us all.
Your objective in this challenge is to write a program which will take a number as input and display that xkcd and its title-text (mousover text).
Input
Your program will take a positive integer a... |
Bailey–Borwein–Plouffe Iterations
We've seen a few pi challenges on PPCG, but none that specifically dictate the algorithm you should be using. I'd like to see implementations of the Bailey–Borwein–Plouffe algorithm in any language up to iteration n. The formula is as follows:
Your algorithm should output each iterati... |
Input
An array that can contain arrays or positive, consecutive, ascending integers. The arrays can have any number of arrays inside of them, and so on and so forth. No arrays will be empty.
Output
This array simplificated
How to simplificate an array
We will use the array, [1, [2, 3], [[4]], [[[5, 6], 7, [[[8]]]], 9]]... |
The cool stuff
The following rosace can help calculate numbers modulo 7.
In order to do that, you must start at 0 and turn clockwise a number of steps given by the first digit. Then, for each successive digit, follow the arrow and then turn clockwise the number of steps given by that digit.
Here is how you proceed for... |
Here's an ASCII pumpkin carved into a Jack-o-Lantern. Isn't it cute?
((^v^))
Here's an ASCII ghost. Look how spooky it is!
\{O.O}/
Obviously, the pumpkins have to be on the ground, with a space between them so they don't rot.
Ghosts, however, like to stand on top of pumpkins, so they're even spookier. However, they h... |
A Pythagorean triple consists of three positive integers a, b, and c, such that a2 + b2 = c2. Such a triple is commonly written (a, b, c), and a well-known example is (3, 4, 5). If (a, b, c) is a Pythagorean triple, then so is (ka, kb, kc) for any positive integer k. A primitive Pythagorean triple is one in which a, b... |
(Note: this is an easier spin-off of my previous challenge Find the Infinity Words!, which is a spin-off of my other previous challenge Find the Swirling Words! :) )
Definition of a Wavy Word:
If you connect with curves all the characters of a Wavy Word on the alphabet (A-Z) you obtain the path of a wave continuously ... |
Chained Binary Operations
Here's a challenge involving truth tables and binary operations. For this specific challenge, your task is to use the following table of operations:
To create a function that takes in two inputs f(p,a), where p is the initial truthy/falsy value and a is a list of tuples representing multiple ... |
Given a string that contains only lowercase letters, encode that string with the alphabet cipher.
To encode with the alphabet cipher (I will be using the example hello):
First, convert each letter in the string to a number depending on its position in the alphabet (a = 1, b = 2, etc.) Example: 8 5 12 12 15
Pad each nu... |
Given a string to encode, and a number of columns (the key), encode the string as follows:
I will be using the example Hello, world! and the key 3
First, write out the number of columns:
1 2 3
Next, write the text starting from the upper left, one character per column, and when you run out of columns, go to the next l... |
Your task is to write some code in Python 2 or 3 such that this expression:
(a+b)(c+d) == a*c + b*c + a*d + b*d
will evaluate to True without raising any exceptions.
To clarify, I will copy your code into a file, then from the file import *. Then I will type the expression into the console and verify that it is True.
... |
Intro
The Switching sequence is defined like so:
Start with n people standing in a circle (6 for this example).
1 2
6 3
5 4
Starting from person 1, the person that is to the left of the "chosen" person is removed.
1
6 3
5 4
The removed person can "switch" the removal method up:
If the removed person is ... |
I am interested in seeing programs which don't ask for any input, print a googol copies of some nonempty string, no less, no more, and then stop. A googol is defined as \$10^{100}\$, i.e., 1 followed by a hundred 0's in decimal.
Example output:
111111111111111111111111111111111111111111111111111111111111111111111111...... |
Your task is to print the titles of the questions with the five highest scores (upvotes minus downvotes) here on CodeGolf.SE, while skipping over any closed, locked and on-hold questions.
Currently these are:
Produce the number 2014 without any numbers in your source code
Showcase your language one vote at a time
Ameri... |
Given an odd integer N (5 <= N <= 51), generate a maze with side length N that follows the following requirements:
The maze must be composed of the characters | - and +. It must use the | character as a vertical wall, the - character as a horizontal wall, and if that wall turns, the character + should be used.
The wid... |
Background
Bathroom Etiquette, when pertaining to the available urinals, states that the next urinal to be filled in should be the one that minimizes the total discomfort. The total discomfort equation is given by the following set of equations:
dist(x,y) = linear distance between person x and person y in Urinal Units... |
Your challenge is to write a program or function that, when given two strings of equal length, swaps every other character and outputs/returns the resulting strings in either order.
Examples
"Hello," "world!" --> "Hollo!" "werld,"
"code" "golf" --> "codf" "gole"
"happy" "angry" --> "hnpry" "aagpy"
"qwerty" "dvorak" -->... |
A simple Markov Model will be used in this question. For more information about Markov Chains, see http://setosa.io/ev/markov-chains/.
Take a string. For this example, we will use the word:
reader
Now, for each character, take the characters that appear after each occurence of the character in the string. (`^` repre... |
The challenge
Output an array or string representation of Dürer's famous magic square:
that is,
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
Some properties of this square, which can perhaps be exploited, are:
It contains each integer from 1 to 16 exactly once
The sum of each column or row, as well as the the sum... |
When babies open their mouths, they're not just spewing gibberish. They're actually talking in a highly advanced, adult-proof cipher...
The Baby-talk Cipher
When a baby talks, it could look something like gogooa gagooook aagaaoooy
Each single-space separated section represents a character (so the example above represen... |
The challenge
Your task is to animate Adve the Adventurer moving through a creepy (i.e. Halloween) maze. Adve is a •; he's character fluid, though, so he does not mind being represented by a different character.
To animate Adve, you print out each frame; a frame is the map with his current location in it. Adve moves on... |
Introduction
I defined the class of antsy permutations in an earlier challenge.
As a reminder, a permutation p of the numbers from 0 to r-1 is antsy, if for every entry p[i] except the first, there is some earlier entry p[i-k] such that p[i] == p[i-k] ± 1.
As a fun fact, I also stated that for r ≥ 1, there are exactly ... |
A string is pairable if it can be split into subtrings, each of which is a string repeated twice consecutively. For example, aabaaababbbaba is pairable as:
aaba aaba
b b
ba ba
Given a non-empty string of a's and b's, output a Truthy value if it's pairable and a Falsey value if it isn't.
Pairable:
aa
abaaba
bbababbb
aa... |
Given a sequence of 625 32-bit unsigned integers (that is, in the range [0, 2**32)), output which of the following pseudorandom number generators generated the sequence:
Linear Congruential Generator
Xorshift
Mersenne Twister
Specifically, the C implementations of these three generators used for this challenge are as... |
Seems like an impossible task right? Well, it's actually not that hard. If we write the word Infinity as 8-bit binary ASCII code, we'll get:
01001001 01101110 01100110 01101001 01101110 01101001 01110100 01111001
This can be concatenated, and converted to the decimal value 5291279215216915577. Now that's a number we c... |
Review
First, let's review the Simple Substitution Cipher.
To encode a string in the Simple Substitution Cipher, replace each letter in your string with another letter.
A letter may not be used to replace more than one existing letter.
For example, if I was encoding the text Hello world, my name is Oliver! I like code... |
Background
Back in the late 90's / first 00's when Flash Web Design was so much cool that noone could live without having a full Flash website, or at least an animated widget, I was hired to develop a "horse races viewer" in Flash/Actionscript, in the shape of an 80's videogame style animation, so the site's visitors c... |
Given a number as input, determine how many significant figures it has. This number will should be taken as a string because you have to do some special formatting. You'll see what I mean soon (I think).
A digit is a sig-fig if at least one of the following apply:
Non-zero digits are always significant.
Any zeros bet... |
Given a positive integer n, output the 2^n binary sequences of length n sorted in the following precise ordering.
Test cases:
0:
0 or 1 (defining this is a matter of debate)
1:
0
1
2:
00
01
10
11
3:
000
001
010
100
011
101
110
111
4:
0000
0001
0010
0100
1000
0011
0101
1001
0110
1010
1100
0111
1011
1101
1110
1111
e... |
Your task is to palindromize a string as follows:
Take the string.
abcde
Reverse it.
edcba
Remove the first letter.
dcba
Glue it onto the original string.
abcdedcba
But here's the catch: since this challenge is about palindromes, your code itself also has to be a palindrome.
Remember, this is code-golf, so the code... |
Given a palindrome generated according to this challenge, depalindromize it.
Test cases
abcdedcba -> abcde
johncenanecnhoj -> johncena
ppapapp -> ppap
codegolflogedoc -> codegolf
As this is about depalindromizing, your code cannot be a palindrome.
Remember, this is code-golf, so the code with the fewest bytes wins.
|
Background
When I was in elementary school, we used to play a game in math class that goes as follows.
All kids sit in a big circle and take turns counting, starting from 1.
However, the following numbers must be skipped while counting:
Numbers that are multiples of 3.
Numbers that have a 3 in its decimal representat... |
inspired by Count down from infinity
Given a non-negative integer N, output the number of repetitions of the following steps it takes to reach 0:
Convert N to binary (4812390 -> 10010010110111001100110)
Flip each bit (10010010110111001100110 -> 01101101001000110011001)
Trim leading zeroes (01101101001000110011001 -> 1... |
Note: this is heavily inspired by this question.
Task:
Your task is to generate the nth prime, when each character of your program is repeated n times in place.
Let's say your program is:
Derp
Every character in there is repeated once, so it should output 2.
When every character is duplicated in place, like so:
DDeerr... |
Given a string, first square it as follows:
First, write the string.
abcde
Next, write the string rotated one left.
abcde
bcdea
Keep doing this until you have written len(string) lines.
abcde
bcdea
cdeab
deabc
eabcd
Now, read from the string like this:
----+
+--+|
|+>||
|+-+|
+---+
Which gives:
abcdeabcdcbaedcbcdea... |
Your task is to determine the palindromic degree of a given non-empty string.
To do this, loop until one of the following conditions are met:
The string is not a palindrome.
You encounter a string that has already been encountered.
And do the following:
If it is a palindrome, add one to the degree.
Depalindromize.
... |
Introduction:
Like Twitter and Instagram and others, I wanted to display numbers like 1.2K and 3.8 M instead of 1,222 or 3,823,456.
But that's not all! As we all know, there might be some human beings which undoubtely won't like these abbreviations and will try to reverse them. So, 1.2k will become 1,200 and 3.8 M will... |
The program should take input the number, the start of the range and the end of the range, and output how many integers the number appears between the start and end of the range, inclusive. Both programs and functions are allowed.
Example Inputs
For example:
//Input example 1
3,1,100
//Input example 2
3
1
100
//Input e... |
Given N (2 <= N), print N lines of the letter Fibonacci series like this (i.e. N = 5)
First, start with a and b:
a
b
Next, add the two lines.
a
b
ab
Keep adding the last two lines.
a
b
ab
bab
Keep going...
a
b
ab
bab
abbab
And we're done.
Remember, this is code-golf, so the code with the fewest bytes wins.
|
This is my first code golf exercise for you:
Your input is two integers n and k. You can assume n >= 1 and k >= 1
You have to output all numbers from 1 to n (inclusively) and replace every element that is a multiple of k or that contains k with "Shaggy".
you can take the input in any convenient form and output it in a ... |
Write a program or function that draws a mountain range, where each subsequent larger mountain peak is "behind" the ones in front, and alternates which side is visible.
This is a mountain range of size 1
/\
This is a mountain range of size 2
/\
/\ \
This is a mountain range of size 3
/\
/ /\
/ /\ \
This is a mou... |
Today you will be doing another palindrome challenge!
So, your task today is to take a string, and determine the minimum amount of letters required to insert to turn it into a palindrome.
For example, let's take the string fishes.
In this, case the best way would be to add h if, so the result would be 3.
fishe s
h... |
You can create a list of all rationals 0 < r ≤ 1 by listing them ordered first by denominator and then by numerator:
1 1 1 2 1 3 1 2 3 4 1 5 1 2 3 4 5
- - - - - - - - - - - - - - - - -
1 2 3 3 4 4 5 5 5 5 6 6 7 7 7 7 7
Note that we skip any rational number that already o... |
A binary convolution is described by a number M, and is applied to a number N. For each bit in the binary representation of M, if the bit is set (1), the corresponding bit in the output is given by XORing the two bits adjacent to the corresponding bit in N (wrapping around when necessary). If the bit is not set (0), th... |
Write a program that takes two numbers as its input. The first one is the number of dimensions - 0 for a dot, 1 for a straight line, 2 for a circle, 3 for a sphere. The second number is the radius of the object, or, if it's 1-dimensional, the number itself. Output 0 for 0 dimensions. The output is the length/area/volum... |
Given the following Python 3 script:
def greet():
print("Hello, world!")
greet()
Prepend some lines to this text file so that it can be both executed as a Python program as well as compiled and run as a C++ program producing the same output Hello, world! (including the newline at the end):
$ python3 bilingual.py.... |
I often forget what I wanted to say when the teacher calls on me to speak. Can you make me a tool to solve this?
Requirements:
The program must loop as follows:
First, take in input
If the input is empty, print the last stored question.
Otherwise, store the input as a question.
Notes:
The input will never be empt... |
Given a sequences of events with probabilities between 0.0 and 1.0, generate and derive the probability of each combination occurring. You may presume that a sequence of numbers is provided in whatever construct your chosen language provides.
Here's an example; you may presume that the length of the sequence's combinat... |
...will you help me immortalize it?
I've had this pillow a few years now, and apparently it's time to get rid of it. Can you please write a function or program, that I can bring with me and use to recreate this pillow whenever I want to reminisce a bit.
It must work with no input arguments.
The output should look exa... |
A Primenary (binary-prime) string is one which, when written as a binary grid, every row and column has a prime total.
That's quite a vague explanation, so let's break it down with a worked example...
For this example we'll use the string bunny:
First, find the ASCII code point of each character and its binary repre... |
Inspired by, and in memory of, my dear friend and colleague,
Dan Baronet, 1956 – 2016. R.I.P.
He found the shortest possible APL solution to this task:
Task
Given a Boolean list, count the number of trailing truth values.
Example cases
{} → 0
{0} → 0
{1} → 1
{0, 1, 1, 0, 0} → 0
{1, 1, 1, 0, 1} → 1
{1, 1, 0, 1, 1} → 2
... |
Your task is to write a program that runs in two different languages, and does the following:
In one language, it palindromizes a given string.
Take the string. abcde
Reverse the string. edcba
Remove the first character. dcba
Glue it onto the original string. abcdedcba
In another language, it depalindromizes a give... |
Your task is simple: Write a program (or function) that takes no input and outputs something like this:
## *name*, *length* bytes
*code*
Where *name* is the name of the language you are using, *length* is the number of bytes in your code, and *code* is your program's source code. If *code* contains multiple lines,... |
Introduction to Numerical Mathematics
This is the "Hello, World!" of PDEs (Partial Differential Equations). The Laplace or Diffusion Equation appears often in Physics, for example Heat Equation, Deforming, Fluid Dynamics, etc... As real life is 3D but we want to say "Hello, World!" and not sing "99 bottles of beer,..."... |
Given a string of text that contains lowercase letters, encode it as follows: (I will be using abcdef)
First, encode the alphabet cipher, but this time, 0-indexed. 000102030405
Reverse it. 504030201000
Loop through the string.
If the next two digits together are 25 or smaller, encode those two numbers. 5 04 03 02 01... |
Find X
I was inspired by math questions in which one is asked to "Find X" for a given shape. Originally, I was just going to have the challenge be to print the x and y location of the character 'x' in a String. But I supposed that would be too simple. So I considered the context they were normally in, and decided findi... |
Problem Description
Imagine you're a turtle on a grid. You're given two numbers f and b, and you're facing east. You perform a march across the grid, counting each of the cells you encounter, according to the following rules:
By default, you write the count to the cell you're in, then walk forward.
If the count is di... |
I got this challenge from Codingame and am curious about better solutions than mine:
Given a width via standard input draw a hollow square of '#' in given width and length.
Example:
5 results in
#####
# #
# #
# #
#####
I used python to solve this so i am particulary interested in other python code. But please fe... |
Challenge
Given an ASCII operator from the list below and a number n, draw an ASCII representation of the operator using that operator as the character with the line segments of the operator having length n.
Input
An ASCII character from the list = + - x / and an integer n where n >= 1. (I'm using x instead of * and /... |
Cubes can be made of six squares as sides. But you could also fold three 2x1 rectangles in half and glue them together to form a cube. Now in this challenge you get a set of pieces which are each made from squares, and you have to determine whether you can choose pieces to form a unit cube. Not all of the pieces have t... |
In my time on PPCG, I've noticed that quine problems and polyglot problems are quite popular. Also, meta-solutions to problems, that is, scripts which generate a program which is the solution to a problem, tend to get a lot of positive feedback from the community. Therefore, I have created this challenge, which impleme... |
This problem is about separating a string representing a product identifier into three components.
The first part consists of upper and lower letters of arbitrary length which represents the warehouse.
The second part is digits which represents the product number. This part is also of arbitrary length.
The last par... |
Today is November 8th, 2016, Election Day in the United States of America.
If you are a U.S. citizen eligible to vote, then go out and vote if you haven't already before answering this challenge. Do not discuss who you voted for. It only matters that you voted.
If you are not a U.S. citizen or not eligible to vote, the... |
I want a blanket that looks like this. Each strip goes over, under, over, under. Can you print it?
\\\\////\\\\////\\\\////\\\\////\\\\////\\\\////
\\//// \\//// \\//// \\//// \\//// \\////
//// //// //// //// //// ////
////\\ ////\\ ////\\ ////\\ ////\\ ////\\
////\\\\////\\\\////\\\\/... |
Challenge
I need help building a brick wall! Throw together some code for me
using no input and produce the following output wall shown below:
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|... |
It is only Tuesday, ugh. I deserve a treat. Golf me a Castle. The Least amount of bytes wins!
Taken no input and output this image exactly:
/\ /\
/ \ / \
---- ----
| |^^^^^^^^^| |
-----------------
| _ |
| | | | | |
| | | |
Edit
Build me a brick wall!
36 votes... |
Your program must take in a string like:
test string
And must output each character adding one at a time like this:
t
te
tes
test
test
test s
test st
test str
test stri
test strin
test string
notice how spaces count!
Good luck!
Least Bytes win.
~N
|
In the alternating Fibonacci sequence, you first start with 1 and 1 as usual.
However, instead of always adding the last two values to get the next number, you alternate starting with adding, and every other time you subtract instead.
The sequence starts like this:
1
1
2 # 1 + 1
-1 # 1 - 2
1 # 2 + -1
-2 # -1 ... |
Let's define a simple 2D language, which we'll give the incredibly original name befinge. Befinge has 5 instructions:
<>^v, as in most 2D esolangs, redirect the instruction pointer in their respective directions.
. is a no-op.
The instruction pointer starts out at the top-left corner going right. If the instruction ... |
Given an xxd hexdump such as this one:
00000000: 1f8b 0808 4920 2258 0003 7069 6c6c 6f77 ....I "X..pillow
00000010: 2e74 7874 00d3 d707 8218 10d0 2799 c545 .txt........'..E
00000020: ba96 41a1 994c 7d60 d650 d53c 44a3 8a22 ..A..L}`.P.<D.."
00000030: cd43 34aa 28d2 3c44 a38a 22cd 4334 aa28 .C4.(.<D..".C4.(
00000040:... |
As you all know, today is election day!
Your task today is to print out a ballot, given an input.
If the input is Hillary Clinton, print:
Hillary Clinton ===-----===>
Donald Trump === ===>
____________ === ===>
However, if the input is Donald Trump, print:
Hillary Clinton === ===>
Donald Trum... |
Introduction
The perimeter density matrix is an infinite binary matrix M defined as follows.
Consider a (1-based) index (x, y), and denote by M[x, y] the rectangular sub-matrix spanned by the corner (1, 1) and (x, y).
Suppose that all values of M[x, y] except Mx, y, the value at index (x, y), have already been determin... |
Consider a date formatted in YYYY-MM-DD.
You can use the joker * at the end of the date string. E.g. 2016-07-2* describes all the dates from 2016-07-20 to 2016-07-29.
Now, consider a period represented by a start date and an end date.
The algorithm must find the smallest possible list of dates representing the period.... |
This challenge has two threads. This is the cops' thread. The robbers' thread is located here.
Your challenge is to choose an OEIS sequence and write two full programs in two different languages that produces that nth item in the sequence when given an n via STDIN, or an other forms of standard input, where n is any p... |
This is the robbers' thread of this challenge
The cops will choose an OEIS sequence and write two full programs in two different languages that produces that nth item in the sequence when given an n via STDIN. The two programs must be anagrams of each other, meaning each can be rearranged from the other's letters.
The... |
An emirp is a non-palindromic prime which, when reversed, is also prime.
The list of base 10 emirps can be found on OEIS. The first six are:
13, 17, 31, 37, 71, 73
However, due to the reversal rule, emirps are different in each base. For example, the first six binary emirps are:
Bin | 1011, 1101, 10111, 11101, 1010... |
A cruise control has 3 different options to move the handle to set the speed you want to drive with.
Towards you: Adds 1 speed.
Upwards: Increases speed to the next multiple of 10 (e.g. 20-->30, 32-->40)
Downwards: Decreases speed to the next multiple of 10 (e.g. 20-->10, 32-->30)
Input
2 integers: the first is the ... |
An orthogonal matrix is a square matrix with real entries whose columns and rows are orthogonal unit vectors (i.e., orthonormal vectors).
This means that M^T M = I, where I is the identity matrix and ^T signifies matrix transposition.
Note that this is orthogonal not "special orthogonal" so the determinant of M can be... |
Solve a Tron Game
Tron is a great game, and if you haven't played it the internet has MANY online versions available.
A fun challenge is to try to write an AI that plays Tron, which is normally much better than any human, thanks to their frame perfect dodging.
Even with their perfect dodging of walls, they still get th... |
I apologize if this isn't fit for this site but it is a puzzle, not all that practical, so I thought it would fit.
Take this code:
string s = "";
Console.WriteLine(ReferenceEquals(s, string.Empty));
This will print out true because "" is interned by the JITter at some early point and literals are reused from the inter... |
Let's define the "unwrapped size" function u of a nested list l (containing only lists) by the following rules:
If l is empty, then u(l) is 1.
If l is non-empty, u(l) is equal to the sum of the unwrapped sizes of every element in l, plus one.
Your task is to write a program (or function) that takes a list as input an... |
Given the equation of a polynomial and an x-coordinate find the rate of change of the point at that x-coord on the curve.
A polynomial is in the form: axn + axn-1 + ... + ax1 + a, where a ϵ Q and n ϵ W. For this challenge, n can also be 0 if you don't want to have to deal with special cases (constants) where there is n... |
Let's define a 2-quine as a program that prints its source code two times. For example, if the program ABC printed ABCABC, it would be a 2-quine.
Let's define a 3-quine as a program that prints its source code three times. For example, if the program ABC printed ABCABCABC, it would be a 3-quine.
Let's define a n-quine... |
Introduction
Consider two arrays of the same length, say A = [0,1,0,2] and B = [-1,1,2,2].
Suppose we know that their contents are equivalent in some sense, item by item:
0 is equivalent to -1,
1 is equivalent to 1,
0 is equivalent to 2, and
2 is equivalent to 2.
Equivalence is transitive: -1 and 0 are equivalent, an... |
Are you feeling jealousy towards Mathematica, Matlab et al. for their intricate plotting capabilities? If you answered yes, this challenge is for you!
Challenge
Given, via parameters or standard input, a list of numbers list and a positive integer h for the height of the plot, write a program/function/snippet that prin... |
The Challenge
I was looking into small code examples for a specific language as a small tutorial and came accross a simplified Blackjack that should be implemented. In this Challenge you will have to implement a full Blackjack game, with 5 Decks.
The Game
You are playing against a Dealer and he has 5 Decks of Poker pla... |
This challenge is based upon three sequences, below are their formulae:
Recamán's sequence:
a1 = 0; for n > 0, an = an-1 - n
if positive and not already in the sequence, otherwise
an = an-1 + n
Fibonacci sequence:
an = (Φn – (–Φ)–n) / √5
where Φ denotes the golden ratio, and
a1 = 0
Triangular numbers s... |
Today, November 11th, is known as Remembrance Day, Armistice Day, or Veterans Day (depending upon the country), and is a day of reflection and gratitude for members of the military and their service, specifically started to reflect the end of European hostilities in the first World War. Let us reflect on that with a si... |
This is the cops' thread. For the robbers' thread, click here.
Cops' Task
First, write a quine in a language of your choosing.
Next, scramble the quine. Make sure to do this well as the robbers will be trying to unscramble it and find the original source code! Note that the scrambled code does not need to work.
Post a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.