instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Please help me automate my discrete mathematics homework. Given a valid propositional formula, check if it is an instance of one of Łukasiewicz's axioms. Here's how it works.
A term can be defined inductively as follows:
Single lower-case letters of the Latin alphabet (a, b, c, etcetera) are terms.
Given a term ϕ, ¬ϕ ... | stackexchange_codegolf |
I know, I know, yet another primes challenge...
Related
A lonely (or isolated) prime is a prime number p such that p-2, p+2, p-4, p+4 ... p-2k, p+2k for some k are all composite. We call such a prime a kth-times-isolated prime.
For example, a 5th-times-isolated prime is 211, since all of 201, 203, 205, 207, 209, 213, 2... | stackexchange_codegolf |
Your task
Given a integer input, \$ n \$ (such that \$ n > 1 \$), decide whether it can be written as the sum of (at least 2) consecutive square numbers.
Test cases
Truthy:
Input Explanation
5 1 + 4
13 4 + 9
14 1 + 4 + 9
25 9 + 16
29 4 + 9 + 16
30 1 + 4 + 9 + 16
41 16 + 25
50 9 + 16 + ... | stackexchange_codegolf |
I feel tired to do "find the pattern" exercise such as
1 2 3 4 (5)
1 2 4 8 (16)
1 2 3 5 8 (13)
Please write a program that finds the pattern for me.
Here, we define the pattern as a recurrence relation that fits the given input, with the smallest score. If there are multiple answers with the same smallest score, using... | stackexchange_codegolf |
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:... | stackexchange_codegolf |
Robbers Thread
Cops, your task is to chose a program that prints a string (you can choose).
Although, if you change 1 character in your code, it should print another string.
But there's a twist: You should make your code hard to read, so that the robbers can't find your "changeable" character.
The winner cop is the use... | stackexchange_codegolf |
A Russian nesting doll, more commonly known as a Matryoshka doll, is a doll which contains a smaller version of itself, which then contains another smaller version of itself, which contains a smaller version of itself, which contains a smaller version of itself, which contains a smaller version of itself... - until fi... | stackexchange_codegolf |
Braille Patterns in Unicode contains 8 dots(⣿) and occupy area U+2800-U+28FF. Given a Braille Pattern character, where the bottom two dots are not used(aka. U+2800-U+283F), shift it down by one dot.
Test cases:
⠀ => ⠀ (U+2800 -> U+2800)
⠅ => ⡂
⠕ => ⡢
⠿ => ⣶
Shortest code wins.
| stackexchange_codegolf |
Introduction:
A typical cartoonish cactus usually looks like this:
One big stem in the middle, with some L-shaped branches sticking out.
We'll use this general shape for this challenge.
Challenge:
Given a pair of words, create an ASCII-art cactus with two upside down alphabets as stem. The first word is the left branc... | stackexchange_codegolf |
Challenge: With any given number that has multiple digits, every digit in the number needs to repeatedly be summed together until the sum is a single digit number. To make things interesting, if there's a 0 in the number, then it must equal 26, because zero starts with the letter z, which is the 26th and final letter o... | stackexchange_codegolf |
In 1.13, Minecraft language files were switched from being a simple multi-line key=value format to JSON.
Challenge
Write a program converting from the original format returning a JSON string. Input can be taken using any standard input method, output must be json from any standard output method
The original format cont... | stackexchange_codegolf |
Yes, I know there is a similar question, but this one specifically concerns any possible words, even with letters left over, while the linked one restricts to a permutation of the input
Objective
Have you ever had those moments in a Scrabble game where you're staring at your letters, trying to find a good word, and y... | stackexchange_codegolf |
Very heavily inspired by this challenge Code Golf: Your own pet ASCII snake - I thought making it horizontal would add an extra layer of complexity.
An example horizontal snake:
0 0
0 0 0 000
00 0 00 000 0 0
000 0 0 0 00
0 ... | stackexchange_codegolf |
Write a program or function that takes in a positive integer (via stdin, command line, or function arg) and prints or returns a string of that many of these small triangles tiled together, alternating which way they point:
/\
/__\
This sole triangle is the output if the input is 1.
If the input is 2, the output is
... | stackexchange_codegolf |
What general tips do you have for golfing in Grass? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Grass (e.g. "remove no-op characters" is not an answer).
Please post one tip per answer.
| stackexchange_codegolf |
Leon's story
Leon is a professional sling shooter and he comes to a shooting range everyday to practice. A casual target is not a challenge for him anymore so before shooting he first covers the target of radius 1.0 with k rectangle stickers. He then fires n shots that cannot hit the stickers.
What's special about Leo... | stackexchange_codegolf |
The riddle
In yesterday's newspaper, I found a puzzle in which a Rook should start in the lower-left corner of a 12x12 checkerboard and then, during a round trip, visit each field exactly once except for a selection which must be avoided. The puzzle came with a picture that identified the fields to be avoided as black:... | stackexchange_codegolf |
In this challenge, your task is to create a program which takes in a nested array and returns a single-dimensional flattened array. For Example [10,20,[30,[40]],50] should output [10,20,30,40,50].
Input
The input will be a nested array (eg. [10,20,[[[10]]]]). It will contain only Integers (both negative and positive),... | stackexchange_codegolf |
Introduction
A pure word (or perfect word), as defined by me, is a word where the sum of the position in the alphabet of each letter in the word is perfectly divisible by the total length of the word. For example, abcb is a perfect word because 1 + 2 + 3 + 2 = 8, and 8 / 4 = 2.
Your task
Given a word as input, output w... | stackexchange_codegolf |
A pleasing number (according to this definition) is a number that can be passed through the following process (let's use 41802000 as an example):
Separate the trailing identical numbers (41802000 => [41802, 000])
Sort the first half of the digits and take the maximum ([41802, 000] => [8, 000])
Take the length of the f... | stackexchange_codegolf |
Win a K vs KQ endgame
Summary
The goal of this challenge is to create a program or function which will win a Chess game with a King and Queen against a lone King. The user will specify three squares, representing the locations of the computer's King, the computer's Queen, and the user's King. The computer will then a o... | stackexchange_codegolf |
Alright, my second attempt at a code golf, let's see how this goes.
Pretend you have a 3x3 grid of digits, from 0 to 8:
0 | 1 | 2
---+---+---
3 | 4 | 5
---+---+---
6 | 7 | 8
Return the neighbors the input has as indexes of the array.
Rules:
It's code golf, so shortest answer wins.
The pretend array's index can sta... | stackexchange_codegolf |
Introduction
The game Minecraft has a 1 in 10000 chance of showing "Minceraft" instead of "Minecraft" on the title screen.
Your challenge
Your challenge is to code a function or program that takes no input, and on average 1 of 10000 times, returns "Minceraft" and the rest of the time returns "Minecraft".
Scoring
This i... | stackexchange_codegolf |
Given two positive integers a and b, output two positive integers c and d such that:
c divides a
d divides b
c and d are co-prime
the least common multiple of c and d equals the least common multiple of a and b.
If there are more than one possible answers, you can output only one or all of them.
Test cases:
a b c ... | stackexchange_codegolf |
Given two positive integers p and q, your task is to return the array A created by applying the following algorithm:
Start with A = [p, q] and d = 2
For each pair (x, y) of contiguous numbers in A whose sum is divisible by d, insert (x + y) / d between x and y.
If at least one matching pair was found, increment d and ... | stackexchange_codegolf |
In golf, a knowledgable caddie helps an already good golfer to be even better. In this challenge, you build a "caddie" to help you code golf. In particular, your caddie will compress golfed code in such a way that another program can uncompress and then run the code. A good caddie will compress golfed code to be much s... | stackexchange_codegolf |
Given the input of n and value. The code is supposed to nest the single element list with value repeated n times. The final output should be a multilevel nested list with single repeated values in all sublists.
This is code-golf, so the shortest code in bytes wins!
Test cases:
n = 1, value = 'a': ['a']
n = 2, value = '... | stackexchange_codegolf |
Given positive integers \$w\$ and \$h\$ output \$w\$ columns and \$h\$ rows of text as described below.
The first row begins with 11 0s, the second row with 10 1s, third with nine 2s and so on down the the tenth row with two 9s. On each of these first ten rows, following the initial run of consecutive digits, the next ... | stackexchange_codegolf |
Challenge:
Given a matrix (or 2d array) of 0s and 1s, output the number of steps it takes for Conway's game of life to reach a stable state, or -1 if it never reaches one. A stable state is a state in which no cells are turned on or off each step. The game must run in the given matrix, with the top and bottom connec... | stackexchange_codegolf |
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... | stackexchange_codegolf |
Motivation: Sometimes you need to know where you are in a string. You want to be able to look at any part of a string and know exactly where you are, as far as possible.
Challenge: write a program to output a tape measure string of a given length. A tape measure string self describes its length-so-far as often as possi... | stackexchange_codegolf |
Unsurprisingly, fibonacci primes are primes that are also Fibonacci numbers. There are currently 34 known Fibonacci primes and an additional 15 probable Fibonacci primes. For the purpose of this challenge, the Fibonacci numbers are the sequence \$F_n\$ defined as \$F_1 = 1\$, \$F_2 = 1\$, and \$F_n = F_{n-1} + F_{n-2}\... | stackexchange_codegolf |
Rules
Given a list of integer coordinates, l, with a length of at least 4, and an integer n such that n is smaller than the length of l (but at least 3), return the largest area of an n-sided polygon satisfies:
is simple (not self-intersecting).
has all the coordinates of its n vertices in the list l.
has no three con... | stackexchange_codegolf |
Background
In this challenge, a base-b representation of an integer n is an expression of n as a sum of powers of b, where each term occurs at most b-1 times. For example, the base-4 representation of 2015 is
4^5 + 3*4^4 + 3*4^3 + 4^2 + 3*4 + 3
Now, the hereditary base-b representation of n is obtained by converting t... | stackexchange_codegolf |
In the card game Magic: the Gathering there are five different colours, which represent loose affiliations of cards, White (W), Blue (U), Black (B), Red (R) and Green (G). These are often arranged in a pentagon as follows:
W
G U
R B
Both in the lore of MtG as well as in many card mechanics, adjacent colours in th... | stackexchange_codegolf |
Challenge
Given a whole number divisible by 9 and one missing digit, find the missing digit.
The missing digit may be represented by any character other than the digits 0-9 as long as it is consistent.
If the missing digit could be 0 or 9, output something to signify so.
Assume the user is intelligent enough to put onl... | stackexchange_codegolf |
Task
Given \$n\$, output position of the last odd digit in the decimal representation of \$2^n\$ (counting from the end).
Rules
There are no odd digits for \$n=1,2,3,6,11\$ \$(2, 4, 8, 64, 2048)\$ - you may output anything that is not a positive integer for them (no need to be consistent).
You choose whether to handle... | stackexchange_codegolf |
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... | stackexchange_codegolf |
The task:
Output a value for x, where a mod x = b for two given values a,b.
Assumption
a and b will always be positive integers
There won't always be a solution for x
If multiple solutions exist, output at least one of them.
If there aren't any solutions, output nothing or some indication that no solutions exist.
Buil... | stackexchange_codegolf |
Note
This is the decryption challenge. The encryption challenge can be found here.
Challenge
The challenge is to decrypt a given string, using the rules as specified below. The string will only contain lowercase alphabets, digits, and/or blank spaces. If you want to know how the input string has been encrypted, refer t... | stackexchange_codegolf |
This wasn't originally intended for code-golf, just as a little debugging routine to roughly visualize something "goofy" going on in a model of some (irrelevant here) physical process. But when I saw how surprisingly short it was, compared to my expectations, I just wondered if it can be further shortened. And that's p... | stackexchange_codegolf |
Your task is given an input string of the full/short name of a CS:GO (Counter-Strike: Global Offensive, a computer game) rank return an integer from 1-18 representing the rank number. A higher number means you are a higher rank and so "better" at CS:GO.
Input
A string representing either the full name or short name of ... | stackexchange_codegolf |
Challenge
You have a Chinese Checkers board looking like this:
board = [
[''],
['', ''],
['', '', ''],
['', '', '', '', '', '', ''],
['', '', '', '', '', ''],
['', '', '', '', ''],
['', '', '', '', '', ''],
['', '', '', '', '', '', ''],
['', '', ''],
... | stackexchange_codegolf |
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... | stackexchange_codegolf |
A knight fill is a flood fill using the connectivity of the knight chess piece. Specifically:
1 1
1 1
0
1 1
1 1
(0 is the initial point, 1s show the connected cells)
Challenge
Given a 2D grid of spaces and walls, and an initial location, perform a knight-fill on the grid. Shortest code wins.
Rules
You may tak... | stackexchange_codegolf |
Given a positive integer N, output the number of pairs of integers 0 <= a <= b < 2**N such that a*b >= 2**N.
Rules
You may assume that N is less than or equal to the maximum bit width for integers in your language (e.g. for C, N will not exceed 32 or 64, depending on the architecture of the machine). If your language ... | stackexchange_codegolf |
Definitions:
A triangle is considered a right triangle if one of the inner angles is exactly 90 degrees.
A number is considered rational if it can be represented by a ratio of integers, i.e., p/q, where both p and q are integers.
A number n is a congruent number if there exists a right triangle of area n where all thr... | stackexchange_codegolf |
The infinite monkey theorem states that, given infinite time, a machine sending an endless stream of random characters will always type any given text.
That sounds to me like a great idea for a challenge.
Process
In order to monkey-ize a string A, the following steps should be taken:
Take an empty string. We will call... | stackexchange_codegolf |
Write code to generate a PDF file containing 6 bingo cards. Winner is the one that uses the shortest code and needs no actions except for installing a library and running the code. (No Save As PDF). Rules are as follows.
The generated PDF file should display accurately in Adobe's PDF reader, Google Chrome and Moxilla ... | stackexchange_codegolf |
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 ... | stackexchange_codegolf |
MD5 checksums are relatively easy to crack. For this challenge you will create two separate programs, the first one writing Hello, World! and the second one writing Goodbye Cruel World! but with the source code having identical MD5 hashes.
The source code of both programs must not be identical.
The programs can use th... | stackexchange_codegolf |
A friend of mine challenged me to write a function that works with both of these scenarios
add(1,2) // 3
add(1)(2) // 3
My instinct was the write an add() function that returns itself but I'm not sure I'm heading in the right direction. This failed.
function add(num1, num2){
if (num1 && num2){
return num... | stackexchange_codegolf |
Your challenge is to implement a cyclic Program Sequence Generator (PSG) in a language of your choice.
Given a language, L, a PSG in L is a program in L that outputs a PSG in L. Some properties of a PSG are:
Repeated execution of a PSG in L generates a sequence of programs in L.
A PSG is said to be cyclic if the seque... | stackexchange_codegolf |
Your goal is to map a piece of text to a sine curve of the form:
a sin ( mx - b )
Where a and m are non-zero rational numbers, b is a rational number, and the calculations are in radians.
It doesn't really matter where the origin of your graph is, as long as you fit all the letters in your output. Also, it must be ASCI... | stackexchange_codegolf |
Your job is to write a program that finds the optimal number of moves it takes to get from the lower-left corner of a rectangle to the upper-right corner directly opposite.
Your program will accept input as an ordered pair (width, height). These will be the dimensions of the rectangle you will work with. Your program w... | stackexchange_codegolf |
Inspired by a meme I saw earlier today.
Challenge description
Consider an infinite alphabet grid:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
...
Take a word (CODEGOLF in this example) and make it a subsequence of the grid, repl... | stackexchange_codegolf |
Output/print this block of text:
1234567890
2468013579
3691470258
4815926037
5049382716
6172839405
7306295184
8520741963
9753108642
0987654321
Acceptable formats include:
Trailing newlines/whitespace
List of strings
List of lists of characters
List of lists of integers
However, list of integers is not acceptable bec... | stackexchange_codegolf |
Challenge
Given a 2D array, find the length and direction of all the longest consecutive characters.
If there are ties, output every possible winning combination in any order, (winners can overlap with other winners)
Zero "0" is a special padding character which cannot be a winner.
Code golf rules apply, shortest code... | stackexchange_codegolf |
Dr. Trump is the head psychiatrist at a mental hospital, which is populated by murdering psychopaths. If 2 psychopaths are left together, they will end up brutally injuring or even killing each other, so Dr. Trump needs to build walls to separate these psychopaths, but owing to the limited amount of funds he has left, ... | stackexchange_codegolf |
Fibonacci Numbers
Fibonacci Numbers start with f(1) = 1 and f(2) = 1 (some includes f(0) = 0 but this is irrelevant to this challenge. Then, for n > 2, f(n) = f(n-1) + f(n-2).
The challenge
Your task is to find and output the n-th positive number that can be expressed as products of Fibonacci numbers. You can choose to... | stackexchange_codegolf |
Fastest code is a scoring method on this site where the goal is to write code that is as fast as possible.
From the tag wiki:
The winner of a fastest-code challenge is determined by the runtime performance of the submissions. For fairness, all submissions should be benchmarked on the same machine, which usually means ... | stackexchange_codegolf |
World Time Conversion
Challenge:
Given an initial clock time in UTC and a list of countries: for each country in the list, output the local time it is in that country based on the initial time. In cases where a country is big enough to have multiple local time zones (like the United States), you may output any valid l... | stackexchange_codegolf |
Given a string consisting of only upper and lower case letters, output an if it begins with a vowel, and a if not. For the purposes of this challenge, we'll ignore normal grammar rules, and use a very basic rule instead: if the input begins with a vowel (any of AEIOUaeiou), then output an. Otherwise, output a.
Your pro... | stackexchange_codegolf |
Write a program/method that:
Becomes a quine when the input matches the source code;
Doesn't halt otherwise.
This is code-golf, so shortest solution wins. Avoid any standard loopholes.
| stackexchange_codegolf |
Background
Polyagony is a family of hypothetical esolangs where the source code is laid out on a specifically shaped board before running it. It's similar to Hexagony, but various uniform tilings can be used instead of a simple hexagon. The shape of the board and the tiling used is defined by the "mode".
Mode 3/3,6 is ... | stackexchange_codegolf |
Given a word, treat every letter as its number in English alphabet (so a becomes 1, b becomes 2, z becomes 26 and so on), and check if all of them, including duplicates, are pairwise coprime.
The input is exactly one word of lowercase English letters. The output is the fact if the word is coprime: any truthy/falsey val... | stackexchange_codegolf |
TL;DR: Solve this particular challenge, a robot simulation, by stepping on all of the white pads, and avoiding the gray pads. You can step on a white pad any number of times, as long as you step on each white pad at least once. Solutions in languages like Befunge with a 2D instruction pointer would also be accepted, bu... | stackexchange_codegolf |
This is a cross-post of a problem I posted to anarchy golf: http://golf.shinh.org/p.rb?tails
Given two integers \$ n \$ and \$ k \$ \$ (0 \le k \le n) \$, count the number of combinations of \$ n \$ coin tosses with at least \$ k \$ tails in a row.
For example, if \$ n = 3 \$ and \$ k = 2 \$, the answer is \$ 3 \$:
HHH... | stackexchange_codegolf |
Print or return the following text:
Hello world! The quick brown fox jumps over a lazy dog.
However, your submission will not be scored in bytes. Instead, primarily it will be scored by the width in pixels of the program when written in Arial in a 12pt font. In particular, the score is:
$$ (\text{visual width in px}) ... | stackexchange_codegolf |
A zigzag scan is a method of encoding 2D information in one dimension:
Write a function or program that, given a one-dimensional string of printable ASCII characters, will reverse the zigzag scan to arrange its characters into a square.
For example, given the input string ABeIfCDgJmnKhLop, your program should return:
... | stackexchange_codegolf |
At runtime, keep prompting for a line of input until the user input is not the name of an existing file or directory or other file system item, relative to the current working directory. Then return/print that last inputted filename. You may assume that all user inputs will be valid filenames.
Pseudo-code 1
myform = ne... | stackexchange_codegolf |
Língua do Pê, or P Language, is a language game spoken in Brazil and Portugal with Portuguese. It is also known in other languages, such as Dutch and Afrikaans. (Wikipedia)
There are some dialects in this language game. The different languages the game is played with even have their own unique dialects. Some people are... | stackexchange_codegolf |
Write a function, f, that takes in a positive integer and returns a function.
The new function returned should be identical to f. However, when the "termination call" happens, f should instead return the sum of all integers passed.
For example, g=f(4) (if f is the first function) should set g to another function. h=g(... | stackexchange_codegolf |
May this challenge serve as (another) tribute to Stan Lee, who passed away aged 95.
Stan Lee has left us an invaluable legacy and a peculiar catch word: Excelsior. So here's a small challenge based on what he said it was its meaning:
Finally, what does “Excelsior” mean? “Upward and onward to greater glory!” That’s wh... | stackexchange_codegolf |
What tips do you have for golfing in (,)? I've found that there are so many ways to make code shorter, and I want more ways. I doubt there even are any tips for (,) that are applicable in the majority of programming languages, but if there are, feel free to include them.
Please, one tip per answer.
| stackexchange_codegolf |
Background
The convex hull of a finite number of points is the smallest convex polygon that contains all of the points, either as vertices or on the interior. For more information, see this question on PGM which defines it very well.
Input
N+1 2-D coordinates (N >= 3) passed through STDIN (with other usual golf inputs ... | stackexchange_codegolf |
We already generated Minesweeper fields, but someone really has to sweep those generated mines before PCG blows up!
Your task is to write a Minesweeper Solver that is compatible with a slightly modified version of the accepted solution of “Working Minesweeper” (actions are separated by spaces to allow for larger fields... | stackexchange_codegolf |
Simple task, write a program/function that returns error if and only if presented with itself.
The program must give a valid output for any input other than itself.
For the error part, you can only use errors already built in errors that comes with your language of choice. New/ self-defined error messages are not allow... | stackexchange_codegolf |
Inspired by both the challenge "Unique is Cheap" by @Laikoni, where the score is based on the challenge itself, as well as the JavaScript (ES6) answer of @ETHproductions for the "Palindrome Compression" challenge, where he uses a pretty cool compression method for the palindrome-flag, upper/lower case indication, and l... | stackexchange_codegolf |
CODE GOLF & Coding Challenges: In today's challenge, you'll be asked to print the following very special AND tricky AND satisfying Prime Number...! Are you golfers ready?
67796869327179767032383267111100105110103326710497108108101110103101115583273110321161111009712139115329910497108108101110103101443212111111739108108... | stackexchange_codegolf |
The least weird fact about the US presidency right now is that there have been two unrelated presidents whose last names start with T-R-U-M.
That made me think, how many US presidents share other combinations of characters? There are obviously two presidents that share the characters "BUSH", and "ROOSEVELT". But did yo... | stackexchange_codegolf |
As a follow up to Shortest terminating program whose output size exceeds Graham's number and Golf a number bigger than TREE(3), I present a new challenge.
Loader's number is a very large number, that is kind of hard to explain (since it was itself the result of a code golfing exercise with a flexible goal). There is a ... | stackexchange_codegolf |
Given an integer p > 1, find the smallest integer q > p such that the list of exponents in the prime factorization of q is the same of that of p, no matter the order or the value of the prime factors.
Examples
The prime factorization of p = 20 is 22 x 51. The smallest integer greater than p with identical exponents in ... | stackexchange_codegolf |
Recently, I created a binary word search that got me working with grids. It was fun, so I wanted to create some more similar content. Meet Pythagoras' Golfing grid:
Each of d, e, f, g, h, i, j, k and T represent a numeric value.
Now consider an orthogonal triangle along the lower diagonal of this grid (so the vertical... | stackexchange_codegolf |
Given two arrays of non-negative integers \$A = [A_1,A_2,\ldots,A_n]\$ and \$R = [R_1,R_2,\ldots,R_n]\$ which are equal in length, return an array which has the element \$A_1\$ repeated \$R_1\$ times, then element \$A_2\$ repeated \$R_2\$ times, all the way up to \$A_n\$.
Standard loopholes are forbidden. As this is co... | stackexchange_codegolf |
This question was profoundly inspired by Joe Z's question.
But, with a twist...
So, now that it's almost 2017, it's time for a code question involving the number 2017.
Your task is to make a program that counts up from 0, printing each number until it reaches 2017. without using any of the characters 012345678 or 9 in... | stackexchange_codegolf |
One day in July 2020, I made the following C program:
#define A m]
a[9999],*m=a;main(){for(2[A=4[A=1;;){for(;4[A;putchar(6[m-=3]+48));
for(puts(a);7[A;2[A=4[A,4[A=1)if(4[A+=3[m+=3]-1,9<(3[A=2[A+=3[A))++
5[A,7[A=1,3[A-=10;}}
with three superfluous newlines removed, it's 167 bytes and it prints the fibonacci sequence (a... | stackexchange_codegolf |
Background
This challenge is inspired by this website, which published the following diagram:
This diagram shows us that the longest Roman Numeral expression under 250 is that of 188, which requires 9 numerals to express.
Challenge
The standard symbols used to express most Roman Numerals are the following: {I, V, X, L... | stackexchange_codegolf |
The Lisp language has a family of functions car, cdr, cadr, etc for accessing arrays. For each one, an a defines taking the first item of an array, and a d defines taking the rest.
For example, running cadr on [[1,3,4],5,7] will return [3,4] as the a gets the first item ([1,3,4]) and the d removes the first item.
We've... | stackexchange_codegolf |
Inspired by certain puzzles on Flow Free: Warps.
Background
We all know that L-triominos can't tile the 3x3 board, and P-pentominos can't tile the 5x5 board. But the situation changes if we allow the board to wrap around in both dimensions:
L-triominos can tile 3x3 toroidal grid
The 3rd tile wraps around through all fo... | stackexchange_codegolf |
This challenge is rather simple:
You are given an array of positive (not including 0) integers, and have to select a random element from this array.
But here's the twist:
The probability of selecting an element is dependent on the value of the integer, meaning as the integer grows larger, the probability of it to get s... | stackexchange_codegolf |
After all assignments are submitted, a dictionary is created that maps student number to the hash of their file.
This dictionary, or hashmap, or mapping (whatever your language calls it) will look as follows:
{100: "aabb", 104: "43a", 52: "00ab", 430: "aabb", 332: "43a"}
The key is the student number, and the value is ... | stackexchange_codegolf |
An example will easily explain this to you. Suppose an array [1,2,3,4,5]
Step 1
1 2 3 4 5
----+----
Step 2
5/
4/
1 2 3 /
----+/
Step 3
5|
4|
1 2 3|
----+|
Step 4
5\
4\
1 2 3\
----+-\
Step 5 Take the sum of face-to-face elements
6 6 3
You just successfully folded an array 1 time. 2 times f... | stackexchange_codegolf |
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... | stackexchange_codegolf |
I know, I know, yet another primes challenge...
Related
A lonely (or isolated) prime is a prime number p such that p-2, p+2, p-4, p+4 ... p-2k, p+2k for some k are all composite. We call such a prime a kth-times-isolated prime.
For example, a 5th-times-isolated prime is 211, since all of 201, 203, 205, 207, 209, 213, 2... | stackexchange_codegolf |
Generate a 7 by 7 grid, filled with random numbers. However, in cells with an odd row and column number (starting at 0), you must use the sum of the surrounding cells. Here's a small example with a 3 by 3 grid (sum-square bolded):
2 2 2
2 16 2
2 2 2
And here's an example 7 by 7 grid:
6 5 4 3 7 2 5
6 43 3 50 8 43 8... | stackexchange_codegolf |
This should be easy: given an arbitrary string, your program will give it a name.
Requirements
Your program will accept an input of a UTF8 string, and output a string representing the input's "name", how you define this name is arbitrary, but it must comply with some conditions.
I/O Ranges
The input will at most be 382... | stackexchange_codegolf |
Because there are not enough simple code-golf challenges:
Create an optionally unnamed program or function that, given (by any means) an integer 1 ≤ N ≤ 10000, outputs your language's True value with a pseudo-random probability of 1/N, False otherwise.
Please note that the requirement for naming has been removed. Feel ... | stackexchange_codegolf |
When you export data in JSON from Facebook, the multi-byte Unicode characters are broken. Example Unicode characters and their representation inside JSON:
'\u00c2\u00b0' : '°',
'\u00c3\u0081' : 'Á',
'\u00c3\u00a1' : 'á',
'\u00c3\u0089' : 'É',
'\u00c3\u00a9' : 'é',
'\u00c3\u00ad' : 'í',
'\u00c3\u00ba' : 'ú',
'\u00c3\u00... | stackexchange_codegolf |
In Bloons Tower Defense 6, the strength of different bloons can be measured by their Red Bloon Equivalent (RBE), or the number of single pops it takes to completely defeat the bloon.
The RBE for the bloon types are as follows (sourced from the wiki)
Bloon
RBE
red
1
blue
2
green
3
yellow
4
pink
5
black... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.