Questions tagged [decision-problem]

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

15
votes
13answers
3k views

Is my Rep in Stack-Exchange Form?

Premise: Your reputation is in Stack-Exchange Form if it can be represented by decomposing your medal counts (gold, silver, and bronze counted separately) into their base-10 digits and joining them ...
23
votes
17answers
3k views

Who won a Game of Bar Dice?

Challenge Bar Dice is a simple game played in a Bar with Dice (hence the name). You roll 5 six-sided dice and attempt to make the best hand. Scoring is based on amassing the largest number of ...
0
votes
3answers
208 views

Havel-to-da-Hakimi [duplicate]

It was a dark and stormy night. Detective Havel and Detective Hakimi arrived at the scene of the crime. Other than the detectives, there were 10 people present. They asked the first person, "out of ...
30
votes
19answers
5k views

Is it a Munchausen Number?

A Munchausen Number in base \$b\$, also known as a Perfect digit-to-digit invariant or PDDI is a peculiar type of positive integer where the sum of its base-\$b\$ digits raised to themselves is equal ...
17
votes
20answers
4k views

I'm in your subnets, golfing your code

Challenge Given an IPv4 address in dotted-quad notation, and an IPv4 subnet in CIDR notation, determine if the ...
8
votes
8answers
547 views

Type-check an expression

Given an infix expression, determine whether all constants are of the same type. Operators will consist only of these dyadic operators: +-/* Your program or ...
13
votes
9answers
396 views

Word Changer Reachability

Word changer is a game where you are trying to turn one word into another via single-character edits, with each step being its own word. For this challenge, edits may be replacements, insertions, or ...
21
votes
5answers
477 views

Congruent Numbers

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., ...
24
votes
40answers
4k views

Check if a string is entirely made of the same substring

This is taken from this question (with permission ofcourse). I'll quote: Create a function which takes a string, and it should return true or false based on whether the input consists of only a ...
27
votes
12answers
1k views

Letter Boxed validator

The New York Times has a daily online game called Letter Boxed (the link is behind a paywall; the game is also described here), presented on a square as follows: You are given 4 groups of 3 letters (...
19
votes
15answers
2k views

Match Roman Numerals

Challenge Given some input string, return a truthy value if it represents a correct roman numeral between 1 (=I) and 3999 (=...
27
votes
13answers
2k views

Pristine Bit Checking

Write a program/function that takes two integers in the range \$0\$ to \$255\$ inclusive, and returns whether the binary forms of the numbers are exactly one bit different. For example, \$1\$ and \$...
17
votes
16answers
2k views

Do I have a twin with permutated remainders?

We define \$R_n\$ as the list of remainders of the Euclidean division of \$n\$ by \$2\$, \$3\$, \$5\$ and \$7\$. Given an integer \$n\ge0\$, you have to figure out if there exists an integer \$0<k&...
10
votes
5answers
472 views

Valid term from quadratic sequence?

You are given four numbers. The first three are \$a\$, \$b\$, and \$c\$ respectively, for the sequence: $$T_n=an^2+bn+c$$ You may take input of these four numbers in any way. The output should be ...
13
votes
8answers
2k views

Is this draw by repetition?

Problem: In chess, there is a somewhat well known rule about draw by repetition. If the same position is repeated 3 times (or more) then the player intending to make the move which will cause the ...
12
votes
5answers
327 views

Terrain Reachability

Turn-based tactics games like Advance Wars, Wargroove, and Fire Emblem are made up of a square grid of varying terrain with units of differing movement classes requiring different costs for each ...
10
votes
13answers
360 views

Is there a smaller tautogram checker? [closed]

I got into code-golfing recently and tried to write the smallest tautogram checker. A tautogram is a sentence in which all words start with the same letter, for example: Flowers flourish from France. ...
25
votes
11answers
2k views

Is this Pascal's Matrix?

In Pascal's triangle each number is the sum of the two numbers directly above it, treating empty spots as zero: By rotating the triangle, we can cut out square matrices of varying sizes and rotations ...
90
votes
32answers
6k views

Would this string work as string?

Write a program that takes a single line string that you can assume will only contain the characters /\_‾. (That's forward and backward slash, underline and ...
8
votes
9answers
432 views

Pi Day: Determine if a list of words is correct Pilish

Background Though this is a bit late for Pi Day, I saw an article about Pilish and thought it would make a great challenge. Pilish is created by using a sequence of words where each word's length ...
28
votes
45answers
8k views

Am I not good enough for you?

Background: The current Perfect Numbers challenge is rather flawed and complicated, since it asks you to output in a complex format involving the factors of the number. This is a purely decision-...
64
votes
45answers
6k views

Is it a Cyclops number? “Nobody” knows!

Task: Given an integer input, figure out whether or not it is a Cyclops Number. What is a Cyclops number, you may ask? Well, it's a number whose binary representation only has one ...
14
votes
4answers
288 views

Is it a valid penalty shoot-out prefix?

In association football (also known as soccer), a penalty shoot-out is the second tie-breaker measure that may be used in a match which can't end in a tie, after extra time (i.e. association football ...
71
votes
37answers
12k views

Am I a Rude Number?

For a while now, I've been running into a problem when counting on my fingers, specifically, that I can only count to ten. My solution to that problem has been to count in binary on my fingers, ...
13
votes
5answers
573 views

Passwords Strong Against Bishops

Not to be confused with Password Bishop Goodness! Given a string, answer (truthy/falsy or two consistent values) if it constitutes a password which is strong against bishops. A password is strong ...
10
votes
24answers
2k views

Password Bishop Goodness

Derived from this, now deleted, post. Given a string, answer (truthy/falsy or two consistent values) if it constitutes a good Bishop password, which is when all the following conditions are met: it ...
3
votes
0answers
93 views

determine if the circle is boxed in [closed]

Pretty simple challenge here. Who can make the fastest algorithm (lowest time complexity) to determine whether or not the circle is "boxed in" given the following setup? Input: Your program receives ...
21
votes
23answers
3k views

School moving out (Day 1)

Challenge Taken with permission from my University Code Challenge Contest For some years now, the number of students in my school has been growing steadily. First the number of students was increased ...
40
votes
12answers
2k views

A well linked challenge

An activity I sometimes do when I'm bored is to write a couple of characters in matching pairs. I then draw lines (over the tops never below) to connect these characters. For example I might write \$...
12
votes
18answers
790 views

Find a Rocco number

I was asked this question in an interview but I was unable to figure out any solution. I don't know whether the question was right or not. I tried a lot but couldn't reach any solution. Honestly ...
32
votes
11answers
5k views

Who will win the election?

This is a challenge in which two people, 1 and 2, are running for office. People deterministically vote in certain ways in the world of 1 and 2, which can allow for the candidates to figure out the ...
9
votes
4answers
255 views

Is it Valid Modified UTF-8?

UTF-8 is a relatively simple way to encode Unicode codepoints in a variable-width format such that it doesn't easily confuse code that isn't Unicode aware. UTF-8 overview Bytes in the range of 1-...
32
votes
35answers
3k views

Equal, sum or difference!

Write shortest possible code that will return true if the two given integer values are equal or their sum or absolute difference is 5. Example test cases: ...
10
votes
15answers
2k views

Multi-level marketing “legs” investment rule

Multi-level marketing related challenge. A peer wants to get rewarded. So it attracted N investors (N>=1), each i-th ...
16
votes
23answers
2k views

Find if a list is an ABC-triple

Three positive integers A, B, C are ABC-triple if they are coprime, with A < B and satisfying the relation : A + B = C Examples : 1, 8, 9 is an ABC-triple ...
26
votes
11answers
1k views

Does this Set Represent a Natural Number?

In set theory, the natural numbers \$\mathbb{N} = \{0, 1, 2, 3, ...\}\$ are usually encoded as pure sets, that is sets which only contain the empty set or other sets that are pure. However, not all ...
29
votes
25answers
5k 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
175 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
408 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 ...
18
votes
8answers
771 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
176 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 ...
9
votes
7answers
325 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 ...
22
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'...
4
votes
7answers
266 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 ...
25
votes
37answers
9k 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
846 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 (...