Questions tagged [counting]

For challenges regarding counting the number of occurrences of some characteristic.

Filter by
Sorted by
Tagged with
2
votes
1answer
150 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 ...
22
votes
43answers
4k views

Character Frequency in a String [duplicate]

Given a string of printable ASCII, output the frequency of each character in that string. The Challenge Input is given as a string of printable ASCII characters (decimal ...
24
votes
21answers
5k 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 ...
0
votes
0answers
58 views

Fizz Buzz game code golf [duplicate]

In the game Fizz Buzz, players generally sit in a circle. The player designated to go first says the number "1", and each player thenceforth counts one number in turn. However, any number divisible by ...
43
votes
23answers
5k views

Covering a Skyline with brush strokes

Given a non-negative integer skyline height list, answer how many uninterrupted 1-unit-high horizontal brush strokes are needed to cover it. [1,3,2,1,2,1,5,3,3,4,2]...
0
votes
0answers
110 views

Count the score of a Code Golf code [duplicate]

My challenge is to make a Java method(s) that is given a String (another code in Java), removes any unnecessary characters, counts and returns the score, and displays the cleaned-up code in a way that ...
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 ...
19
votes
3answers
364 views

Count cyclically self-describing lists

Cyclically self-describing lists A list \$L\$ of positive integers is cyclically self-describing, if the following conditions hold. \$L\$ is nonempty. The first and last elements of \$L\$ are ...
6
votes
12answers
852 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 ...
17
votes
18answers
4k views

Longest Repeating Subsequence of a Single Digit

Challenge: Given a positive integer, output the longest single-digit subsequence that occurs at least twice, AND has boundaries of another digit (or the start/end of the integer). An example: Input:...
5
votes
3answers
444 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 ...
-9
votes
19answers
290 views

How long is this string?

It's strange this question hasn't been asked yet, so here it is: Calculate the length of a string given through STDIN Rules As said, your string will be given through STDIN, not via command line ...
16
votes
10answers
2k 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 ...
33
votes
21answers
3k views

Alphabet Histogram

Given an input sentence consisting of one or more words [a-z]+ and zero or more spaces , output an ASCII-art histogram (bar ...
20
votes
21answers
1k 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 ...
3
votes
2answers
75 views

Count stacking sequences [duplicate]

Given a list of stack heights, calculate the number of ways those heights could have been arrived at by stacking blocks one at a time. Shortest code wins. Test cases: ...
24
votes
25answers
1k 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 <...
35
votes
24answers
3k views

Plus Primes vs Minus Primes

Most of us know... that all primes p>3 are of the form But, how many are the Plus Primes (6n+1) and how many are the ...
16
votes
11answers
797 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 ...
24
votes
28answers
2k views

Count forth and back then double up

Let's count... Count up to 2 and back to 1 Count up to 4 and back to 1 Count up to 6 and back to 1 ... ok you got it... put all these together and you'll get the following sequence ...
25
votes
9answers
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: ...
20
votes
19answers
3k views

How much reputation does a steam user have? [closed]

Introduction For those not familiar with steam - or at least this particular aspect: Often on peoples' profiles, people leave comments saying either "+rep _____" or "-rep _____". These are an ...
11
votes
11answers
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 ...
7
votes
1answer
303 views

Count # of Cookie Chocolate Chips

Note: this is my first post here. The Challenge The challenge is to count the number of chocolate chips in a cookie. A cookie in this case is a circle with dots (the chips) in it. Given any square ...
24
votes
47answers
4k 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 ...
17
votes
8answers
2k views

How Many Holes?

Challenge Given a graphical input of a shape, determine how many holes there are in it. Not Duplicate This question was marked as a possible duplicate of Count Islands. I believe this challenge is ...
23
votes
5answers
492 views

How great is your land?

In this challenge, you'll calculate how great your land is. Write a program or function that calculates the size of your land, given a wall you have built. You're given a non-empty input string ...
10
votes
18answers
1k views

Round the string

Some decimal numbers cannot be precisely represented as binary floats due to the internal representation of the binary floats. For example: rounding 14.225 to two decimal digits does not result in 14....
35
votes
53answers
5k views

How much do I have to write?

Writing out numbers is among the Hello worlds of programming, often the numbers 1-10. I want to write out many numbers! Many, Many numbers. But how many numbers do I have to write? Task Given an ...
6
votes
14answers
425 views

Find the frequency of triplets in a phrase

For context, this problem is based on a old chat-bot project I did. Problem: Given a string of words containing any of the characters: ...
58
votes
25answers
5k views

Cantor's unspeakable numbers

An unspeakable number is a number which is divisible by seven or has seven as one of its digits. A children game is to count skipping unspeakable numbers ...
20
votes
20answers
1k views

Find the “Recursive Size” of a List

Inspired by Find the “unwrapped size” of a list. Define the Recursive Size, RS, of a list containing no lists as its length (number of items contained) and the ...
12
votes
33answers
2k views

Find the “unwrapped size” of a list

Let's define the "unwrapped size" function u of a nested list l (containing only lists) by the following rules: If ...
59
votes
54answers
3k views

Count trailing truths

Inspired by, and in memory of, my dear friend and colleague, Dan Baronet, 1956 – 2016. R.I.P. He found the shortest possible APL solution to this task: Task Given a Boolean list, count the number ...
47
votes
23answers
9k views

Count down from “Infinity”

Seems like an impossible task right? Well, it's actually not that hard. If we write the word Infinity as 8-bit binary ASCII code, we'll get: ...
21
votes
20answers
6k views

A penny saved is a penny

...counted! You will pass your program a variable which represents a quantity of money in dollars and/or cents and an array of coin values. Your challenge is to output the number of possible ...
-5
votes
3answers
104 views

Get dimension of a list [duplicate]

Find out the dimension of a simple nested list: [] -> 1 [[]] -> 2 [[[]]] -> 3 ... List taken as input, dimension as output. No counting length of ...
35
votes
24answers
7k views

Checkmate (aka the urinal problem)

My Precalc teacher has one of his favorite problems that he made up (or more likely stole inspired by xkcd) that involves a row of n urinals. "Checkmate" is a ...
37
votes
15answers
5k views

How long is a Welsh word?

Write a program or function which receives as input a string representing a Welsh word (UTF-8 unless otherwise specified by you). The following are all single letters in Welsh: a, b, c, ch, d, dd, ...
34
votes
16answers
6k views

Count to 100 in Danish

Print all the numbers from 0-100 in the right order using the Danish way of counting How they count Like English, they have dedicated words for 0-20, 30, 40 and 100 Instead of saying ...
11
votes
7answers
360 views

Create an unlimited counterstring

A counterstring is some sort of self-describing test data that is used in software testing. Not sure it was actually invented by James Bach, but I know it from there. The idea is as follows: the test ...
40
votes
24answers
4k views

How many lights are on?

You are little speck on a Cartesian plane. Pondering your existence, you decide to roam around your plane and touch things. You notice that every coordinate pair you visit has a light switch. To ...
7
votes
1answer
266 views

Count blocks in a 2D grid

Challenge description Let's define an W x H grid as a two-dimensional array of length H ...
22
votes
14answers
2k views

Prime Wednesdays

Prime Wednesdays Your task is to count the number of Wednesdays that fall on a prime day of the month in a particular year. For instance, 7-13-16 is a prime ...
39
votes
34answers
4k views

Detriplicate a string

A lot of languages have built-in ways to get rid of duplicates, or "deduplicate" or "uniquify" a list or string. A less common task is to "detriplicate" a string. That is, for every character that ...
7
votes
20answers
946 views

Character Counting System [duplicate]

GOAL : To Implement a character counting program This is how this counting system works : input of the program is a set of printable ASCII characters . the program counts each type of character , ...
10
votes
3answers
294 views

Ways to get to the number

Given the input of the first number and the second number (both positive integers, zero exluded), determine in how many ways could you make the second out of the first, using following actions: ...
26
votes
12answers
2k views

7-segment differences

I think most people around here know what a 7-segment display for digits is: ...
-2
votes
2answers
200 views

Restricted average (arithmetic mean) – i.e. without obvious built-ins [closed]

Introduction The arithmetic mean is defined as being equal to the sum of the numerical values of each and every observation divided by the total number of observations. Symbolically, if we have a ...
10
votes
1answer
372 views

How many shapes are in this picture?

Children are very good at classifying objects and counting them. Computers seem to have more trouble. This is a simplified version of this problem. Can you write a small program that can classify and ...