instruction stringlengths 34 53.1k |
|---|
You are given a square \$n \times n\$ matrix \$A\$, and a list (or vector) \$u\$ of length \$n\$ containing the numbers \$1\$ through \$n\$ (or \$0\$ through \$n-1\$). Your task is to reorder the columns and rows of the matrix \$A\$ according to the order specified in \$u\$.
That is, you will construct a matrix \$B\$... |
Golf Golf!
This is my first challenge, so please be gentle! The challenge is to write a program that will output the correct score for a layout in the card game "Golf."
The card game Golf has many variations. The house rules I use follow the standard rules for Six-Card Golf given by Pagat, with one slight difference. T... |
Yet another blatant rip-off of a rip-off of a rip-off. Go upvote those!
Your task, if you wish to accept it, is to write a program/function that outputs/returns its string input/argument. The tricky part is that if I reverse your source code, the output must be reversed too.
For simplicity, you can assume that the inpu... |
Rip-off of a rip-off of a rip-off of a rip-off. Go upvote those!
Your task, if you wish to accept it, is to write a program/function that outputs/returns its input/argument¹. The tricky part is that if I transpose your source code², the output/result must be transposed too.
You may choose which kind of 2D data your so... |
Convert a string containing digits as words into an integer, ignoring leading zeros.
Examples
"four two" -> 42.
"zero zero zero one" -> 1.
Assumptions
Submissions can assume that:
The input string is comprised of space-separated digit words.
All words are valid (in the range "zero".."nine") and lowercase. Behaviour ... |
What is the Ultraradical?
The ultraradical, or the Bring radical, of a real number \$a\$ is defined as the only real root of the quintic equation \$x^5+x+a=0\$.
Here we use \$\text{UR}(\cdot)\$ to denote the ultraradical function. For example, \$\text{UR}(-100010)=10\$, since \$10^5+10-100010=0\$.
Challenge
Write a ful... |
Sandbox
French License Plates
French license plates come in a sequential order, following a specific pattern of numbers and letters : AB-012-CD
Challenge
Write a program or function that, for a given number, outputs the corresponding french license plate number. Your program should not handle any special case as specif... |
What general tips do you have for golfing in 1+? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to 1+ (e.g. "remove unnecessary whitespace" is not an answer).
Please post one tip per answer.
|
What general tips do you have for golfing in Keg? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Keg (e.g. "remove comments" is not an answer).
Please post one tip per answer.
|
Here is the (quite scary) Five little ducks song(it is not long):
Five little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack",
but only four little ducks came back.
Four little ducks went out one day,
over the hills and up away.
Mother Duck said, "Quack Quack Quack Quack... |
Your task is to create a program that determines whether a given string is a valid regular expression or not using code snippets sourced from sites on the StackExchange network.
For the purposes of this challenge, the regular expression dialect will be a stripped down and mostly minimal set of meta-characters: ()*?|\. ... |
Starting at 1-TET, give equal temperaments that have better and better approximation of the perfect fifth(just ratio 3/2). (OEIS sequence A060528)
The formal description of the sequence, copied from the OEIS:
A list of equal temperaments (equal divisions of the octave) whose nearest scale steps are closer and closer a... |
Tichu is a card game in which players take turn playing sets of cards from a deck consisting of a standard 52-card deck, plus 4 additional cards:
the dragon, which has a greater value than any other card
the phoenix, which can act as a wildcard
the dog, which passes the turn to your partner
the Mah Jong, which has val... |
I like card game challenges so I made this one for the Italian card game Scopa. My family has been playing this game since time immemorial. It has a very interesting scoring system that should be fun to golf. I will post an answer in R to get the fun started, that I am sure people will improve upon.
The challenge: figu... |
Challenge: Add two numbers. In O(n^m) time, where n and m are the two numbers given. Sleeping, or your language equivalent, is not allowed.
Input: Two integers, separated by a space.
Output: The sum of the two integers.
Additional notes: The exact timing doesn't matter, as long as the input 1000 2 takes roughly 1/1000t... |
Introduction
Some time ago, I need to write function which split string in some specific way. At the first look, task looks trivial, but it was not so easy - especially when I want to decrease code size.
Challenge
As example we have following input string (it can be arbitrary)
Lorem ipsum dolor sit amet consectetur ad... |
In Australian Football, goals are worth 6 points and behinds are worth 1 point. Scores may include the number of goals and behinds, as well as the total score. Given the number of goals and behinds for two different teams, determine which team won the game.
Take four integers g1, b1, g2, b2 as input, and output two dis... |
The previous neural net golfing challenges (this and that) inspired me to pose a new challenge:
The challenge
Find the smallest feedforward neural network such that, given any 4-dimensional input vector \$(a,b,c,d)\$ with integer entries in \$[-10,10]\$, the network outputs \$\textrm{sort}(a,b,c,d)\$ with a coordinate-... |
Given a non-empty list of decimal digits (0, 1, ..., 9), replace each zero by the most recent nonzero, if possible.
Example 1: given
1 4 3 0 0 7 5 5 0 3
the output should be
1 4 3 3 3 7 5 5 5 3
Note how the first two zeros are replaced by 3, which is the most recent (i.e. rightmost) nonzero. Similarly, the last zer... |
Challenge
Write a program that applies an injective function which takes an ordered pair of strings as input and one string as output. In other words, each input must map to a unique output.
Specifics
The input may be any two strings of arbitrary length, but will consist only of printable ASCII characters (codes \$[32... |
I'm new to this site, so I don't know whether this challenge already appeared:
Write a piece of source code, so that after running the code, it prints out exactly (i.e. not longer, not shorter) the source code itself.
The code can be in any programming language, but preferably in commonly used ones, such as the C famil... |
We haven't had any nice, easy challenges in a while, so here we go.
Given a list of integers each greater than \$0\$ and an index as input, output the percentage of the item at the given index of the total sum of the list.
Output should be whatever the natural representation for floats/integers is in your language (una... |
Given a UTF-8 string, give a string that represents byte counts of each characters.
Rules:
As long as the input string is encoded in UTF-8 (without BOM), its type doesn't matter. In C++, it can be char[] or std::string. In Haskell, it can be [Int8] or [CChar].
The output must be (in usual case) a string of ASCII digit... |
The challenge
Find the smallest feedforward neural network such that, given any 3-dimensional input vector \$(a,b,c)\$ with integer entries in \$[-10,10]\$, the network outputs the largest (i.e., "most positive") root of the polynomial \$x^3+ax^2+bx+c\$ with error strictly smaller than \$0.1\$.
Admissibility
The notion... |
I just got a job as a postman and I need your help to keep it.
I have to order a lot of mails before I go out to deliver them.
Streets are numbered strictly sequentially, starting with 1 at the start of the street, and continuing in order skipping no numbers until the end, with odd numbers on the left side and evens on... |
There's a little-known secret in Banjo-Kazooie that you can interleave the three Cheato codes on the Treasure Trove Cove Sandcastle floor and it will still recognize all of them. So you could, for instance, enter BLUREEGOLDDFFEEGEAATHTHEEGSRSRS, activating BLUEEGGS, REDFEATHERS, and GOLDFEATHERS all at once.
Challenge
... |
Introduction
During work with BMP (bitmap) generator I face problem of converting number to little endian hex string. Here is function which I create in JavaScript - but wonder how small code can works similarly
let liEnd= num => num.toString(16).padStart(8,'0').match(/../g).reverse().join``;
console.log(liEnd(304767... |
Given a UTF-16 string, test its endianness.
Rules:
As long as the input is in UTF-16 without BOM, its type doesn't matter. In C++ on Windows, it can be std::wstring or std::u16string. In Haskell, it can be [Int16] or [Word16].
The endianness is tested by noncharacters. If the input contains a noncharacter, it is in wr... |
21, 21, 23, 20, 5, 25, 31, 24, ?
Inspired by this Puzzle, given an integer \$n>0\$ , print out the following sequence until you reach a non-Integer (spoilered, in case you want to solve the puzzle yourself first)
\$a_0 = n\$
\$a_{4k+1} = a_{4k} \cdot(4k+1) \$
\$a_{4k+2} = a_{4k+1} + (4k+2)\$
\$a_{4k+3} = a_{4k+2} - (... |
This is essentially the inverse of Generate a US License Plate
Challenge: Given a string that matches one of the below license plate formats, output all possible states that match that formatting. In the below table 0 stands for a single digit 0 through 9 inclusive, and A stands for a single letter A through Z inclusiv... |
Write a full program or a function taking an unsigned integer number N and doing this cut out work:
Cut out a hollow hexagon 'donut' shape with side B-C equal to 2N times '/'
Translate the piece above by 3 lines.
Repeat the job N times (from the piece obtained) decrementing by 2 '/' side B-C , until smallest hexagon ... |
We seem to never get tired of alphabet-related challenges...
The recipe
Given
a string of letters S, and
two positive integers M, N,
produce an alphabet soup with the letters of S occupying random positions in a rectangular bowl of size M×N, framed by a non-alphabetic, non-space character to represent the rim of the... |
Spreadsheet Columns
In most spreadsheet programs, columns go A, B, C, ... X, Y, Z. After this comes AA, AB, AC ... AX, AY, AZ, BA and so on.
Your task is to convert one of these strings in to a column number. You must support inputs up to the maximum length of your language, to a minimum of 3.
Test Cases:
A => 1
B ... |
It's simple, simply output text to STDERR containing the string EOF.
Input/Output
Your input will be none; however, you should output the message to STDERR.
Rules
Since this is code-golf, the shortest answer wins.
No standard loopholes please.
Any method approved by Standard I/O is allowed.
Your code may not contain t... |
In this challenge, your task is to input a rectangle ASCII pattern (You may assume only printable characters need to be handled, and you may assume a trailing newline or not), C4_4 symmetrify, and output it.
Here, C4_4 symmetric means symmetric under 90-degree rotation around a corner of the corner character. The corre... |
In this challenge, your task is to detect (vertical) Skewer Symmetry. This means that one half of the pattern can be produced by mirroring the other half along a vertical axis, and then moving it vertically.
For example, the following pattern has skewer symmetry:
asdf
jkl;fdsa
;lkj
Because if you start from th... |
Given an input string of length 2 or longer consisting solely of alphabetical characters [A-Z] or [a-z] (your choice if they're all uppercase or all lowercase), output a continuous string of characters forming a double diamond pattern.
The input string starts on the center line and extends down-and-right at a diagonal ... |
Display the emoji of the eastern zodiac of given time, according to given country.
The eastern zodiac is a classification scheme that assigns an animal and its reputed attributes to each year in a repeating 12-year cycle. It is also assigned to hours.
Rules:
The country must be given as ISO 3166-1 alpha-3 code. The li... |
The objective
Given a string of Hangul syllables, sort the characters in North Korean dictionary order.
Introduction to Hangul syllables
Hangul(한글) is the Korean writing system invented by Sejong the Great. Hangul syllables are allocated in Unicode point U+AC00 – U+D7A3. A Hangul syllable consists of an initial consona... |
Code Golf Measurer © 2019
Hexdumps used with xxd look something like this:
00000000: 666f 6f20 6261 7220 7370 616d 2065 6767 foo bar spam egg
00000010: 730a s.
Your task is to convert a hexdump in this form in to the number of bytes used.
Rules:
Usual loopholes forbidden.
This is ... |
Fermat's polygonal number theorem states that every positive integer can be expressed as the sum of at most \$n\$ \$n\$-gonal numbers. This means that every positive integer can be expressed as the sum of up to three triangle numbers, four square numbers, five pentagonal numbers etc. Your task is to take a positive int... |
\$T(n, k)\$ gives the number of permutations of length \$n\$ with up to \$k\$ inversions. This values grows very quickly, for example for \$T(20, 100) = 1551417550117463564\$.
The maximum number of inversions possible is \$n\frac{n-1}{2}\$ so for \$k = n\frac{n-1}{2}\$ we know that \$T(n, k) = n!\$.
To make this tas... |
The newest "nice" OEIS sequence, A328020, was just published a few minutes ago.
Number of distinct tilings of an n X n square with free n-polyominoes.
This sequence counts tilings up to symmetries of the square. The sequence has six terms, but I'd like to see if folks here can extend it further.
Example
For n=4 there... |
About Hangul
As I'm Korean, I'm really proud of Korean character, Hangul(한글).
Hangul is a syllabary invented by King Sejong the great, 4th king of Joseon dynasty, in 1443.
Because today (October 9th) is Hangul day in Korea, I'll give you a challenge: Make some Hangul ascii-art
List of characters
So, To make ASCII art, ... |
Background
You've been given a task to take notes for a meeting. You start typing on your Google Doc, but you don't have enough time during the meeting to look at your keyboard while you type.
Fortunately for you, you can type without looking at your keyboard. After the meeting, you realize that everything you typed wa... |
What general tips do you have for golfing in MathGolf? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to MathGolf (for tips which can be applied to loads of programming languages, look at the general tips).
|
NOTE: Since I'm Dutch myself, all dates are in the Dutch dd-MM-yyyy format in the challenge description and test cases.
Challenge:
Inputs:
Start date \$s\$; End date \$e\$; Digit \$n\$
Outputs:
All dates within the range \$[s,e]\$ (including on both sides), which contain \$n\$ amount of unique digits in their date.
Exa... |
Let's assume we've got an imaginary assembler. The assembler supports numerical labels. An infinite loop example:
:1
jmp 1
Your task is, to write a preprocessor for this assembler supporting named labels (instead of numerical ones; with up to 8 characters in length), so the label name is replaced to it's numerical... |
The objective
Given a Russian text, encrypt it with Caesar cipher with key 16.
The basic Cyrillic alphabets
The basic Cyrillic alphabets are: (U+0410 – U+042F)
АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ
By the Caesar cipher, they are mapped to:
РСТУФХЦЧШЩЪЫЬЭЮЯАБВГДЕЖЗИЙКЛМНОП
The small letters (U+0430 – U+044F) are also mappe... |
Given (in any structure; flat list, two lists of lists, a tuple of matrices, a 3D array, complex numbers,…) the coordinates for two non-degenerate triangles ABC=[[Ax,Ay],[Bx,By],[Cx,Cy]] and PQR=[[Px,Py],[Qx,Qy],[Rx,Ry]], determine if they are similar, that is,
they both have the same shape, or one has the same shape ... |
The challenge
How well can you gerrymander North Carolina into 13 voting districts?
In this challenge, you use the following files to draw different maps for Republicans and Democrats.
File 1: NC_2016_presidential_election.csv
File 2: NC_county_adjacency.csv
File 1 gives county-level voting data from the 2016 president... |
Convert a large int (e. g. 1234567890) into a string containing the usual decimal prefixes k, M, G, T, etc. for kilo, mega, giga, tera, etc. The result shall be groups of three digits, interspersed by the prefixes (e. g. 1G234M567k890), so that it is easy to glance the order of magnitude of the number without counting... |
One of the Klarner-Rado sequences is defined as follows:
the first term is \$1\$
for all subsequent terms, the following rule applies: if \$x\$ is present, so are \$2x+1\$ and \$3x+1\$
the sequence is strictly increasing
This is A002977.
The first few terms are:
1, 3, 4, 7, 9, 10, 13, 15, 19, 21, 22, 27, ...
(\$3\$ ... |
Inspired by this lumosity mini game, Pinball Recall
We start with a rectangular grid (viewed from above) with several bumpers as follows. Entrances/exits are numbered counter-clockwise starting from the leftmost of the bottom of the grid, as number 0.
24 23 22 21 20 19 18 17 16 15
25 . . . . . / . . . . 14... |
The Hadamard transform works similarly to the Fourier transform: it takes a vector and maps it to its frequency components, which are the Walsh functions. Instead of sine waves in the Fourier transform, the Walsh functions are discrete "square waves" so to speak. This makes it easier to compute.
The size of a Hadamard ... |
We all know the age-old debate - should strings be length-prefixed or should they be null-terminated? Well, you've run into a blob of binary data and apparently whoever made it decided that the best solution would be a compromise and length-terminated their strings.
For the purposes of this challenge, a length-terminat... |
How can we depict a turned shape simply and nicely using ascii characters in 3D space?
I suggest this method :
Instead of a circle we use a square rotated by 45° for the cutting section so that we only need '/' and '\' characters to draw it.
/\
/ \
\ /
\/
And we use '_' character for the profiles: upper, lower ... |
In this challenge you will write a piece of text which when viewed from two different angles will create two different programs.
Your string as viewed from above must take a string containing only characters ASCII 10, 32 - 126 and output it as viewed from above. Additionally your program when viewed from the left must... |
When translating DNA into proteins, the ribosomes read the sequence of DNA nucleotides 3 by 3. Each set of 3 nucleotides is called a codon, and each codon encodes for an amino acid, with some redundancies. Here's the conversion table used by most organisms (table is read left, top, right):
Humans and most other organi... |
The flag of Tennessee is specified by chapter 498 of the Public Acts of 1905.
An oblong flag or banner in length one and two thirds times its width, the large or principal field of same to be of color red, but said flag or banner ending at its free or outer end in a perpendicular bar of blue, of uniform width, running... |
Write a program which, when every nth character is skipped, it prints n. For example, if every 2nd character is skipped, it prints 2.
Example
n=0
foobar
Output:
0
n=1
foa
Output:
1
n=2
fobr
Output:
2
Rules
If n=0 (no characters are skipped), 0 must be returned.
Must print to STDOUT.
Standard loopholes are forbid... |
I'm sure this is going to spark some controversy, but let's do a practical demonstration.
The objective of this is simple, using the new code of conduct and no input, print out my pronouns ( "he/him", "he him" is also acceptable).
Here's the challenge. This is a classical polyglot contest!
This means that the first... |
SOMe PEOPle lIkE tO TYpE iN A LoGiCAL MAnNER, WITh CapITals aT tHe bEGiNnIng Of ThE SENtENCE and smaLl LETTErS EVeRYWHErE eLsE. NOT Us. NOt Us. Your joB iS to tAkE A SenTEncE Of A
LL SMAlL LeTTeRS, And rANDOmly ChAnGe sOMe to caPiTAl. ThiS iS a Code gOLF so tHE SmaLleST coDE WIll win.
the input will always be small l... |
The Objective
Build a random number generator whose range is \$\left[0,1\right) \cap \mathbb{Q} .\$
This is, build a random number generator that can produce any value that's:
at least \$0 \,;\$
not \$1\$ or greater; and
expressible as the ratio of two integers.
What's the fuss?
This RNG is weird. Its range is nowhe... |
(Essentially the inverse of Find the needle in the haystack)
Given two tuples, (w, h) and (x, y), generate a haystack composed of a single random printable ASCII character of w width and h height with a needle made of a different random printable ASCII character at (x, y) when measured from the upper-left.
For example,... |
Your task is to create a plain hunt (a bell ringing pattern) with n bells. An example with 6 bells:
123456
214365
241635
426153
462513
645231
654321
563412
536142
351624
315264
132546
123456
Each number "bounces" off the side of the grid. From Wikipedia:
Each bell moves one position at each succeeding change, unless ... |
If we assign each letter a respective integer, starting from 1, then a is 1, b is 2, c is 3, and so on. After z, the letters loop back around, but with a in front (aa, ab, ac). It then goes to ba, bb, bc... After this is completed, as you may have figured, another letter is added (aaa, aab, aac). "Prime letters" would... |
I have a bunch of ASCII art that I have recovered from a failed hard drive. Unfortunately, all of the newlines were stripped out, and I don't know the resolution of the original artwork. I do know that each one was originally rectangular, but to make matters worse, all the white space at the beginning and end was strip... |
Well, you know it's Snow White, and the evil Queen is at it again. Will Snow White be saved? Will she fall asleep once again? Will the Prince find her?
Challenge:
Given an arbitrary number (>= 2) of possibly duplicated hexadecimal color values (ranging from #000000 to #FFFFFF) and paired strings, calculate the followin... |
Inspired by this challenge from puzzling.SE.
Polyominoes are fun - you can fill all sorts of shapes with them. But as soon as you have limits on what polyominoes you can use, you sadly start running into shapes you can't fill.
Today we'll be looking at the L tromino - a shape made up of three conjoined squares, in such... |
Input
_ _ _ _ _ _ _ _
| _| _||_||_ |_ ||_||_|| |
||_ _| | _||_| ||_| _||_|
output
1234567890
Rules
Code golf - shortest code wins.
Input will be given as a 3-line string with each line separated by a newline, or as 3 separate strings. Each line is guaranteed to be a multiple of 3 characters lo... |
This is the inverse of negative seven's question.
Write a program or function which, given any single, possibly-empty string of printable ASCII (codes \$[32,126]\$) outputs or returns two strings of printable ASCII.
For any two ordered, possibly empty strings \$s_1\$ and \$s_2\$, there must be third string \$s_0\$, whi... |
A wave of power \$k\$ is an infinite array that looks like \$1,2,\dots,k,k-1,\dots,1,\dots,k,\dots,1,\dots\$, and so on.
For example, a wave of power 3 starts with \$1,2,3,2,1,2,3,2,1,...\$, and repeats indefinitely. A wave of power 1 is an infinite array of ones. They happen to be beautifully expressed as $$w_k[t] = k... |
Create a program which prints the amount of characters its source has in English words.
If your program is nine letters long it should print "nine".
Capitalization is ignored: in case you're printing "one" (somehow) you can print "one", "oNe", "ONE" or anything else.
Base ten is required.
Proper spacing is also require... |
Write a program that outputs Hell0 W0rld!. It must match this output exactly, including capitalization, zeroes instead of o's, exactly one space, etc. Trailing new lines are allowed.
Lowest score wins. Scoring is based on the sum of the values of each character in the language's code page - otherwise Unicode values ... |
The world has been invaded by aliens. They are everywhere killing people and taking over the world. You are hiding with your friend.
They have one weakness - the high pitched sounds.
You can't go yell at them, because you'd get caught before, so you remember the state had a conveniently made machine that emits a high p... |
This is the Grid Game:
It's a game based on cellular automata, where the aim is to remove all of the pieces belonging to your opponent.
How it works:
There are two kinds of piece in the game, cities and walkers.
Each player starts with one city (marked with C and a number, which is it's health), which will regularly ... |
This challenge is inspired by my earlier challenge "Create a program that prints the amount of characters it has, in words".
This challenge's rules are simple: make a program that prints its character count, in words, which works in as many languages as possible.
Each programming language the program works in must make... |
I'm surprised this hasn't been done yet, but here we go.
Create a program which prints some number of 1s (ideally as large as possible) before halting.
The rules are simple:
Your program is bounded to 50 bytes in size.
Your output must only be a continuous row of 1s (plus trailing newline if it has to be added), withou... |
This is a simple challenge: given n in any way practical (Function arg, stdin, file, constant in code) output the internal angles
(NOT the sum of the internal angles, just one) of a regular polygon with n sides. The output can be in degrees, gradians or radians, and can be displayed in any way practical (Function retu... |
I was doing some investigation into trig functions using compound angles recently, and noticed that the results are really long and tedious to write:
$$
\cos(A+B) = \cos A \cos B - \sin A \sin B \\
\cos(A-B) = \cos A \cos B + \sin A \sin B \\
\sin(A+B) = \sin A \cos B + \sin B \cos A \\
\sin(A-B) = \sin A \cos B - \sin... |
Introduction
Every number can be represented as ASCII. For example, \$0\$ comes in ASCII is \$48\$, \$1\$ is \$49\$, and so on. Using this method of translating numbers to other numbers, it is possible to infinitely expand a number, by replacing all its digits with their ASCII values and doing the same for the result. ... |
Back again, stealing another question from stackoverflow.
You are given a list of integers >= 0. Generate in order square 1-matrices where the side length is given by the list entry of the current index and fill the rest with 0s.
So given a list 2,4,1,3 print this to stdout:
1 1 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0
0 0 ... |
Let's consider a list \$L\$ (initially empty) and a pointer \$p\$ into this list (initialized to \$0\$).
Given a pair of integers \$(m,n)\$, with \$m\ge 0\$ and \$n>0\$:
We set all uninitialized values in \$L\$ up to \$p+m+n\$ (excluded) to \$0\$.
We advance the pointer by adding \$m\$ to \$p\$.
We create a vector \$[... |
This is a problem that the Hacker Cup team made for the 2018 Facebook Hacker Cup, but we ended up not using it (though Ethan struggles through a variety of other challenges). Normally code size isn't a factor in the Hacker Cup, but we thought this would make for an interesting code golf challenge. We look forward to se... |
(based on this deleted question)
Take the English alphabet a b c d e f g h i j k l m n o p q r s t u v w x y z (spaces added for clarity), and split it into chunks of X width, padding any leftover lines with spaces if necessary for your language. For example, splitting it into width 4 results in
a b c d
e f g h
i j k l... |
Your goal is to write a program that prints the string abc in two languages. However, while the full code will print abc in one language (we'll call it Language 1), the other one (Language 2) must print abc if (and only if) every other character is skipped starting from the second character. If the full code is run in ... |
Without taking any input, output this exact text:
A
B A
C B A
D C B A
E D C B A
F E D C B A
G F E D C B A
H G F E D C B A
I H G F E... |
Introduction
Every string has an "alphabet", composed of the characters that make it up. For example, the alphabet of \$abcaabbcc\$ is \${a, b,c}\$. There are two operations you can do with alphabets: getting the alphabet of a string, and seeing if another string has a given alphabet.
Challenge
Given two strings, you m... |
There are 4 regular polygons that we can construct using ASCII art:
. . .
. . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
. . . . . . .
... |
A Hamiltonian path in a graph is a path that visits each vertex exactly once; a Hamiltonian cycle is a Hamiltonian path that is a cycle – the path forms a simple closed loop. In this challenge the graph will be a n x n grid, where n is an even number greater than 2.
Here is an example of a Hamiltonian cycle on 12x12 re... |
Story
In an unnamed company, some people use Java and some use C++. This was always a nuisance, and they kept on arguing which single language they should all be using. To settle the dispute, the management decided that they'll buy a translator program that will be able to rewrite their C++ programs to Java and vice ve... |
Introduction
We all know prefixes and suffixes. But there are other types of affixes that exist too. Such as circumfixes, a type of affix that has two parts, one of which is a prefix and another of which is a suffix. Figuring out whether some string is a prefix or a suffix of some other string is easy, but what about f... |
It is Halloween and Jimmy (/o\) has gone into a mysterious neighborhood for trick-or-treating (ask himself why). Now some evil ghosts are chasing him. Can Jimmy escape the ghosts?
Challenge:
Input:
A board showing position of Jimmy, ghosts, solid objects and empty spaces.
An example 10x5 board, o is Jimmy (we needed a ... |
You are given a matrix of forward and back slashes, for instance:
//\\
\//\
//\/
A slash cuts along the diagonal of its cell corner-to-corner, splitting it in two pieces.
Pieces from adjacent (horizontally or vertically) cells are glued together.
Your task is to count the number of resulting pieces. For the same examp... |
This challenge will give you an input of a degree sequence in the form of a partition of an even number. Your goal will be to write a program that will output the number of loop-free labeled multigraphs that have this degree sequence.
Example
For example, given the input [3,3,1,1], you should output the number of label... |
I have a hardware that has a 32-bit input register. The register has the following characteristics:
The 32-bit register consists of eight 4-bit fields.
Each 4-bit field holds a value in signed-magnitude; it can hold an integer between -7 and +7 inclusive, including -0 and +0 (signed zeroes).
For example, the hexadeci... |
You want to find the length shortest path between two points, on an 2d ASCII "map". The roads are made up of + characters, and the two endpoints are represented by #s (not counted in the length). This road can be arranged in any way, and any other characters can be ignored. You can assume the endpoints will always conn... |
Very recently, I changed my SE username because I made this account some years ago and wanted to get back into asking questions. However, I’m still planning to post questions and potentially earn votes. We can imagine a site that has some issues dealing with name changes. The problem: given a list of names, reputation ... |
"Set" is a card game played with a deck of 81 cards, twelve of which are pictured below:
Each card has four attributes, each of which may assume three values:
Number: the number of symbols, either 1, 2, or 3
Shape: the shape of the symbol, either squiggle, diamond or oval
Colour: either purple, red or green
Shading: ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.