Questions tagged [counting]
For challenges regarding counting the number of occurrences of some characteristic.
130 questions
3
votes
1
answer
303
views
Count number of families of sets satisfying a list of criteria
CHALLENGE
This problem has a math background.
For n=1,2,3,4 we want to count the number of families of sets with maximum n elements that satisfy many criteria of the form:
$$\bigoplus_{k\in A,A\in \...
33
votes
21
answers
3k
views
Count the fish in a school
Go Fish!
Given a school of fish, for example:
...
-1
votes
1
answer
190
views
Golomb's self-describing sequence problem [duplicate]
Inspired by this problem.
Golomb's self-describing sequence g(n) is a sequence where any natural number n is repeated within the sequence g(n) times.
Given an input of \$ n \$, output: $$ \left( \sum_{...
31
votes
50
answers
3k
views
Replace 0s In a String With Their Consecutive Counts
Challenge
Given a string of any length which contains only digits from 0 to 9, replace each consecutive run of the digit ...
10
votes
1
answer
419
views
Counting overlapping objects
Consider a NxN pixel grid with up to M objects drawn on it, either squares or diamonds:
square
diamond
The objects may overlap, so recognition is hard. The task is to give the minimal possible ...
34
votes
30
answers
2k
views
Converge to a number
Your challenge is to, given a positive integer n, count up to each digit of it, giving the effect of converging on it.
Basically, count up to the first digit of n by its place value (\$⌊\log_{10}\left(...
19
votes
2
answers
648
views
Counting and so on
Content
You count numbers every day (I think), and most of you know how to count properly, the one next to 1 is 2, and the next ...
33
votes
55
answers
2k
views
Replace all items with their counts
Task:
Given an array of numbers as input (you can choose what subset, such as integers or natural numbers), replace all items with the number of times they appear within the array. As an example, <...
13
votes
10
answers
1k
views
Autogrammatic pairs
For today's task, we have two programs, P and Q, both in the same language. Each of them receives a single-character input.
If P receives character K, P says how many times K appeared in Q. (You can ...
23
votes
2
answers
2k
views
Eye test - How many squares are in this picture?
The picture:
Sick of the same old grid where the answer is simply a square pyramidal number?
Accept the challenge and write a program that given a positive integer \$n\$ counts how many squares are in ...
13
votes
6
answers
510
views
Number of solutions to a binary weight equation
We define \$a(n)\$ as the 1-indexed position of \$n\$ in the sequence of positive integers with the same binary weight, i.e. the same number of 1's in their binary representation. This is A263017.
...
20
votes
1
answer
819
views
Acyclic orientations of an n-dimensional cube
The goal of this challenge is to check and extend the OEIS sequence A334248: Number of distinct acyclic orientations of the edges of an n-dimensional cube.
Take an n-dimensional cube (if n=1, this is ...
5
votes
19
answers
473
views
How many spaces are there? [duplicate]
Your task is to input a string, and output the number of spaces in the string.
This is code-golf, so least number of bytes win. Your
Test Cases
Double quotes are not part of the test cases.
...
3
votes
1
answer
255
views
Black and white shirt 2
This is a more complicated version of this puzzle. The premise is the same but a few rules differ in a few key places, making for a more complex problem.
Assume I have some number of black shirts and ...
29
votes
23
answers
6k
views
A scene of Jimmy diversity
As you probably know, there have been multiple lovely Jimmy challenges recently popping up. In these challenges, you were challenged with our beloved friend's acrobatics skills. Now we've got a ...
20
votes
32
answers
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, ...
8
votes
14
answers
7k
views
Recursively count lines of code, excluding empty lines and comments
Requirement: Write a program (in any language) that counts the number of lines of code in files matching *.sh in the directory tree starting from the directory that ...
11
votes
5
answers
826
views
Saddle points in a matrix
A matrix can be thought of as the altitudes of a surface in 3D space.
Consider the 8 neighbours (orthogonal and diagonal) of a cell as a cyclic sequence in clockwise (or anticlockwise) order. Some ...
16
votes
10
answers
3k
views
Assign Airliner Seats
Inspired by last week's APL lesson.
Given an uppercase 2D seat map and a 1D list of customers, return the seat map and the customer list but modified as follows (to indicate occupied seats and seated ...
22
votes
21
answers
2k
views
Count the Matchsticks
Most people here are familiar with seven segment displays, which are also used in matchstick puzzles. Below are the digits 0 through ...
27
votes
29
answers
2k
views
Count edits accounting for grace period
When you edit a post on SE, any further edits within a 5-minute grace period are merged into it. Given a list of times you edit a post, count the edits not in a grace period.
Say you edit at minutes <...
16
votes
11
answers
935
views
Sequence Without Sevens [duplicate]
This challenge is based on a drinking game. I advise against alcohol consumption while programming.
In this game, the players count up in turns: the first player says ...
26
votes
10
answers
1k
views
Number Lockers!
Given a positive integer < 100 (from 1 to 99, including 1 and 99), output that many lockers.
A locker is defined as the following:
...
12
votes
11
answers
2k
views
Count how many months are having a full 31 days by counting knuckles
How many of you that still use your own knuckle to determine whether a month is having a full 31 days or less?
You job is to write a program to count how many months, in a month range, are having a ...
36
votes
68
answers
5k
views
GET your dubs together
On 4chan, a popular game is get. Every post on the site gets a sequential post ID. Since you can't influence or determine them, people try to guess (at least a part of) their own post number, usually ...