Questions tagged [decision-problem]

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

Filter by
Sorted by
Tagged with
39 votes
5 answers
2k views

Is this word on the boggle board?

Introduction After a day of drinking and watching the world cup, you sit down to play friendly game of boggle. Tempers rise as you are accused of wasting everyone's time with nonsense words that aren'...
user avatar
150 votes
1 answer
5k views

"KNOT" or "NOT"?

Write a program that processes an ASCII art representation of a tangled string and decides whether or not it can be untangled into a simple loop. The tangle is represented using the characters ...
user avatar
  • 19.6k
368 votes
1 answer
115k views

Regex that only matches itself

There are some pretty cool challenges out there involving regex (Self-matching regex, Regex validating regex) This may well be impossible, but is there a regex that will ONLY match itself? NOTE, ...
user avatar
39 votes
80 answers
10k views

Determine if all decimal digits are unique

Deleted questions on Stack Overflow sometimes make for great golf material. Write a function that takes a nonnegative integer as input, and returns true if all the digits in the base 10 ...
user avatar
  • 607
41 votes
9 answers
6k views

"Convenient palindrome" checker

If you've ever tried to write palindromic code before, you'd know how much brackets tend to get in your way. ()() is not a palindrome, even though it kinda looks ...
user avatar
13 votes
21 answers
1k views

Determine if an integer is a palindrome in a given radix (base)

Write a program that reads from stdin two integers, each newline terminated, hereafter called "number" and "radix", and: Prints any fixed message you want if the number is a palindrome in that radix (...
user avatar
  • 4,762
23 votes
22 answers
5k views

Create a sudoku solution CHECKER

Create a Sudoku solution CHECKER There are oodles of Sudoku SOLVERS here, but I want you to create a solution CHECKER as small as humanly possible (code-golf). A valid entry will be able to either ...
user avatar
11 votes
13 answers
575 views

Fibonacci distribution validator

Related: Hello world!!! Fibonacci distribution Create a program that returns True if a given input meets the following specifications, and False otherwise: The count of numeric characters (0-9) in ...
user avatar
  • 2,498
29 votes
69 answers
9k views

Check whether an integer is a power of 2 without using +,- operations [closed]

Write a program that checks if the integer is a power of 2. Sample input: 8 Sample output: Yes Sample input: ...
user avatar
  • 1,039
20 votes
20 answers
3k views

Verify Brainfuck program

Yet another Brainfuck parsing problem, but this time... different. You are working in the Infinite Monkeys Incorporated, the company making Brainfuck programs, to solve various interesting problems ...
user avatar
9 votes
2 answers
2k views

Check if the 15 puzzle is solvable

The fifteen puzzle is peculiar in that only half the possible states of arrangement are solvable. If you flip the 14 and 15 tiles, there is no way you can slide the blocks so that they are flipped ...
user avatar
  • 33.8k
56 votes
76 answers
8k views

Test a number for narcissism

A Narcissistic Number is a number which is the sum of its own digits, each raised to the power of the number of digits. For example, take \$153\$ (3 digits): \$1^3 + 5^3 + 3^3 = 153\$ \$1634\$: \$1^...
user avatar
  • 2,498
66 votes
43 answers
5k views

Write the shortest self-identifying program (a quine variant)

Write a program that will generate a "true" output iff the input matches the source code of the program, and which generates a "false" output iff the input does not match the source code of the ...
user avatar
  • 28.5k
42 votes
46 answers
18k views

Shortest code to determine if a string is a palindrome

A palindrome is some string that is spelled the same way both backwards and forwards. For instance, 'Eva, can I stab bats in a cave?' is a palindrome (EVACANISTAB | BATSINACAVE) For this code golf, ...
user avatar
10 votes
2 answers
942 views

Email validation

Write a function or program to validate an e-mail address against RFC 5321 (some grammar rules found in 5322) with the relaxation that you can ignore comments and folding whitespace (...
user avatar
  • 42.8k
14 votes
12 answers
1k views

Transposed, primes, oh my!

The task is simple: your program reads an integer as an input, and prints whether it is a prime or not. You can print "yes/no", "true/false" or anything what unambiguously ...
user avatar
  • 8,090
26 votes
59 answers
7k views

Is string X a subsequence of string Y?

Given strings X and Y, determine whether X is a subsequence of Y. The empty string is regarded as a subsequence of every string. (E.g., '' and ...
user avatar
  • 3,032
6 votes
12 answers
1k views

"First time" test

What is the shortest C expression that is defined to evaluated to false the first time and true for every time after that: Reference implementation: ...
user avatar
  • 269
17 votes
31 answers
2k views

Finding Not-Quite-Prime Numbers

Your challenge, should you chose to accept it, is to code-golf a function that returns true or false (or some similar meaningful representation of yes and no) if a number meets the following criteria: ...
user avatar
  • 2,419
4 votes
14 answers
1k views

Write the shortest code to match a tail-repeating string where one character falls off the head in each repetition

In this code-golf, you will attempt to match a string that is tail-repeating with one character falling off the head on each iteration. The code needs to be able to accept a string, and return to the ...
user avatar
11 votes
9 answers
3k views

Check if a string is a shuffle of twins

Explanation Two strings can be shuffled by interspersing their letters to form a new string, much like two piles of cards can be shuffled to form a single pile. For example, the strings ...
user avatar
  • 7,672
8 votes
2 answers
2k views

Determining the winner of a Chess game

Challenge Being someone who plays far too much chess in his spare time, I thought I'd set a code golf challenge inspired by the game of chess (with a software flavour), for those interested. The ...
user avatar
  • 197
16 votes
40 answers
2k views

Undulant numbers [duplicate]

An undulant number is a number where its digits alternate between up and down like the following number: 461902 or 708143, or even 1010101, but not 123, because 2 < 3. Write a program or function ...
user avatar
  • 341
6 votes
18 answers
5k views

Check if number is a sum of consecutive numbers or not

Write a program that checks if a given positive integer can be represented as sum of two or more consecutive positive integers. Example: 43 can be represented as 21 + 22 10 = 1+2+3+4 but 4 cannot be ...
user avatar
22 votes
28 answers
7k views

Find whether a number is happy or not?

A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (...
user avatar
  • 4,453
21 votes
4 answers
2k views

Determine if a polygon is convex

Write a program to determine if the input polygon is convex. The polygon is specified with one line containing N, the number of vertices, then N lines containing the x and y coordinates of each ...
user avatar
21 votes
46 answers
2k views

Detect rotated strings

Read two strings from stdin. Output Yes if one string is a rotated version of the other. Otherwise output ...
user avatar
  • 14.9k
8 votes
8 answers
530 views

Is this figure connected?

You are given a list of (x,y) grid coordinates. Your function should decide whether the figure obtained by coloring in the squares of the grid with the given ...
user avatar

1
10 11 12 13
14