Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [decision-problem]

For challenges which involve deciding whether or not the input meets certain criteria, and outputting some data, representing that decision.

29
votes
22answers
4k views

Number that can eat itself

Given a positive integer, output a truthy/falsy value as to whether the number can eat itself. Rules Leftmost is the head, rightmost is the tail If the head is greater than or equal to the tail, ...
8
votes
2answers
139 views

Let's play Peg Solitaire

Peg solitaire is a popular game usually played alone. The game consists of some number of pegs and a board which is divided into a grid - usually the board is not rectangular but for this challenge we ...
11
votes
3answers
389 views

Is it an arithmetico-geometric sequence?

An arithmetico-geometric sequence is the elementwise product of an arithmetic sequence and a geometric sequence. For example, 1 -4 12 -32 is the product of the ...
17
votes
19answers
3k views

Is this number a hill number?

A hill number is a number that has the same digit in the first & the last, but that's not all. In a hill number the first digits are strictly increasing, and the last digits are strictly ...
17
votes
8answers
739 views

Is this quadrilateral cyclic?

In mathematics, a cyclic quadrilateral is one whose vertices all lie on the same circle. In other words, every vertex is on the circumcircle of the other three. For more information, see the MathWorld ...
17
votes
10answers
2k views

Reciprocal copycats

Let \$A\$ be a positive integer consisting of \$n\$ decimal digits \$d_1,d_2,...,d_n\$. Let \$B\$ be another positive integer. For the purpose of this challenge, we call \$A\$ a copycat of \$B\$ if ...
8
votes
2answers
170 views

Should this identifier be suggested?

Introduction In Android Studio and other IDEs there are code completions to assist efficient code insertion (especially when the names of the classes or methods are so verbose), like the one in the ...
8
votes
7answers
284 views

Magic: The Gathering, Paying for Spells

For more MtG-goodness: Magic: The Gathering Combat with Abilities Premise: In Magic: the Gathering, you cast spells by paying their mana cost by tapping lands for the required amount. These lands ...
16
votes
9answers
2k views

Is this a Major Scale (or equivalent)?

Sandbox The major scale (or Ionian scale) is one of the most commonly used musical scales, especially in Western music. It is one of the diatonic scales. Like many musical scales, it is made up of ...
19
votes
32answers
3k views

How fast am I vrooooming?

Introduction My car speedometer was hacked! Instead of showing me how fast i'm driving, it just shows: "Vroooom!" Please help me know how fast i'm going. Challenge Take a string as input, and check ...
21
votes
11answers
6k views

Is this number secretly Fibonacci?

Background Most of you know what a Fibonacci number is. Some of you may know that all positive integers can be represented as a sum of one or more distinct Fibonacci numbers, according to Zeckendorf'...
3
votes
7answers
250 views

Choose the Most Dramatic Outcome

The premise of this is simple: A 10% chance is pretty unlikely, but everyone knows that a one-in-a-million chance is a sure thing! So, write code that implements the following "dramatic" probability ...
20
votes
36answers
8k views

IP address or not?

Your network scanning tool is annoyingly picky about input, and immediately crashes if you feed it an IPv4 address that contains improper characters or isn't properly formatted. An IPv4 address is ...
15
votes
13answers
774 views

Is this string a palindrome (in Morse Code)?

Challenge Inspired by this video As you may know, a palindrome is a word that is spelled the same forward as it is backward. The word "PULP" is not a palindrome, but when translated into Morse Code (...
20
votes
13answers
2k views

Is this a BST pre-order traversal?

Background A binary tree is a rooted tree whose every node has at most two children. A labelled binary tree is a binary tree whose every node is labelled with a positive integer; moreover, all ...
22
votes
15answers
2k views

A Semi-palindrome Puzzle

An palindrome is a word that is its own reverse. Now there are some words that might look like palindromes but are not. For example consider the word sheesh, <...
33
votes
25answers
5k views

Can the number be split into powers of 2?

Yesterday while playing with my kid I noticed the number in his toy train: So we have $$4281$$ that can be split into $$4-2-8-1$$ or $$2^2-2^1-2^3-2^0$$ So simple challenge: given a non-negative ...
20
votes
15answers
5k views

One line Keyboard

The Challenge The goal of this challenge is to determine whether a given String can be typed using only one line of a standard UK QWERTY keyboard. This is ...
18
votes
26answers
3k views

Is the word coprime?

Given a word, treat every letter as it's number in English alphabet (so a becomes 1, b becomes 2, ...
18
votes
12answers
2k views

Is the Matrix Positive-Definite?

Introduction Today we're gonna take care of the bane of first-year linear algebra students: matrix definiteness! Apparently this doesn't yet have a challenge so here we go: Input A \$n\times n\$ ...
9
votes
5answers
489 views

A sorcerer's spellbook

Edit: I haven't played D&D before so when I initially made this question I didn't properly research it. I apologize for this, and I'm making a few edits that might invalidate answers to stay as ...
16
votes
38answers
1k views

Sum \$\text{Square}^2\$

Let \$n=42\$ (Input) Then divisors are : 1, 2, 3, 6, 7, 14, 21, 42 Squaring each divisor : 1, 4, 9, 36, 49, 196, 441, 1764 Taking sum (adding) : 2500 Since \$50\times 50=2500\$ therefore we return ...
16
votes
24answers
2k views

Check my tunneling arrays

Imagine you have an array of integers, whose non-negative values are pointers to other positions in the same array, only that those values represent tunnels, so if the value in position A is positive ...
12
votes
52answers
2k views

Are all three integers distinct?

You will be given 3 integers as input. The inputs may or may not be different from each other. You have to output 1 if all three inputs are different from each other, and 0 if any input is ...
14
votes
2answers
363 views

Impatient divisibility test

Your task is to write a program or function that determines whether a number is divisible by another. The catch is that it should give an answer as soon as possible, even if not all digits of the ...
14
votes
12answers
4k views

A greeting bot for a colleague from work

I have a colleague at work that works from home every Tuesday and Thursday. At around 8:00 AM he sends us a message with the following text: Hello today I'm working from home In order to relieve ...
16
votes
7answers
563 views

Magic: The Gathering Combat with Abilities

Related Goal: Given two creatures with optional combat abilities, return unique but consistent values that represent which creatures died, if any. Input: ...
6
votes
6answers
851 views

Lucas and Fibonacci are in pair

Influenced by Non-discriminating Programming, I made up an idea of a similar challenge. Here, we say a string is a Lucas string if the number of appearances of each character is a Lucas number (2, 1, ...
10
votes
5answers
879 views

The Onion, or Not The Onion?

The Onion (warning: many articles are NSFW) is a satirical news organization that parodies traditional news media. In 2014, The Onion launched ClickHole (warning: also frequently NSFW), a satirical ...
30
votes
3answers
4k views

Primality testing formula

Your goal is to determine whether a given number n is prime in the fewest bytes. But, your code must be a single Python 2 expression on numbers consisting of only ...
12
votes
6answers
523 views

Golf a Solubility Chart

Given the name of a cation and anion, output "S" (soluble) or "I" (insoluble). The table we will be using is from wikipedia: https://en.wikipedia.org/wiki/Solubility_chart. It is copied at the end of ...
7
votes
3answers
174 views

Evaluate Words Based on “Rules” (Skeptics.SE Crossover)

I came across this picture, which I initially questioned and thought about posting to Skeptics. Then I thought they'll only tell me if this one case is true, but wouldn't it be great to know how true ...
28
votes
77answers
13k views

Is this number evil?

Introduction In number theory, a number is considered evil if there are an even number of 1's in its binary representation. In today's challenge, you will be identifying whether or not a given number ...
21
votes
13answers
4k views

Is this a straight flush?

Related: Name the poker hand A straight flush is a poker hand containing five cards of sequential rank, all of the same suit. As part of a straight flush, an ace can rank either above a king or ...
15
votes
25answers
2k views

Mixed Fraction Equality

In elementary school, children learn about proper fractions, where the numerator is less than the denominator, and thus the value of the fraction is less than one. Later, they are taught about ...
10
votes
2answers
215 views

Solve the Halting Problem for Modilar SNISP

In the spirit of Solve the Halting Problem for Befinge, let's define another 2D language called Modilar SNISP. Modilar SNISP has the following six instructions: \ ...
37
votes
28answers
4k views

Is the matrix centrosymmetric… and so is the code?

Defintion A centrosymmetric matrix is a square matrix that is symmetric about its center. More rigorously, a matrix \$A\$ of size \$n \times n\$ is centrosymmetric if, for any \$i,\: j \in ([1, n] \...
19
votes
12answers
2k views

Socket - Plug compatibility

Traveling with electronics is always fun, especially when you need an adapter to charge them. Your challenge is to make planning a trip a little easier by checking if a given plug will be compatible ...
17
votes
12answers
2k views

In for a bumpy ride

Your task is to write a computer program or function that takes a list of positive integers of at least length 2 and determines if they are a "zigzag". A sequence is a zigzag if and only if the ...
8
votes
8answers
1k views

Was it a Superb Shuffle™️

According to this question a Superb Shuffle™️ is defined as a full deck of cards (including jokers) which follows this set of rules: No two cards (except Jokers) of the same suit are adjacent. No ...
17
votes
3answers
441 views

Dead Frog Walking

Introduction Jonny wants to play Frogger. However, he's not very good. In fact, he will only try to move forward, and only after the platforms have moved. Find out if Jonny's frog manages to reach ...
19
votes
15answers
2k views

Upper or Lower Wythoff?

First, let's talk about Beatty sequences. Given a positive irrational number r, we can construct an infinite sequence by multiplying the positive integers to r in order and taking the floor of each ...
18
votes
2answers
318 views

Is this a Weyr matrix?

There's a type of n×n matrix W called the basic Weyr canonical form. Such a matrix is described by its blocks and has the following properties, using the following reference diagram: the main ...
0
votes
0answers
117 views

Validate Sudoku (N by N) [duplicate]

Challenge : Create a random (pseudo random) Sudoku board with dimension n x n Input : Given : ...
16
votes
12answers
2k views

Is it an exercise set?

We all know that a lot of exercises only affect one half of your body, so you have to do them twice, once for each side. Such exercises have two counterparts, one for the left side and one for the ...
19
votes
47answers
5k views

Determining Yes or No?

After inputting a string [length 1-20], only containing the chars y for yes and n for no, your program should output the result (y or n). Example input: yynynynny ...
20
votes
5answers
370 views

Modified Boggle Checker, with Modified Boggle-able Code

Background Boggle is a board game where the players have to find English words on a 4-by-4 board of random alphabets. Words can be constructed by selecting sequentially adjacent cells on the board. ("...
14
votes
3answers
283 views

Are there mountain rings?

Challenge Given a matrix of positive integers, determine if there are any "rings" of mountains. The formal definition for this challenge is: given a matrix of positive integers, is there any positive ...
19
votes
16answers
2k views

Is this a consecutive-prime/constant-exponent number?

A while ago, I had a look at the prime factorization of 27000: 27000 = 23 × 33 × 53 There are two special things about that: consecutive-prime: The primes are consecutive: 2 is the ...
27
votes
14answers
3k views

Fridge magnet substitution

When writing a message with fridge magnets, you'll often find yourself substituting a 1 for an I. In this challenge, your goal ...