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 [counting]

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

0
votes
0answers
92 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
354 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
607 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
403 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
18answers
269 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 ...
32
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
74 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
793 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 ...
12
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
275 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 ...
24
votes
5answers
474 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 ...
11
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 ...
7
votes
14answers
405 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 ...
17
votes
14answers
795 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 ...
46
votes
22answers
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
102 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 ...
32
votes
21answers
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 ...
36
votes
14answers
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
5k 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
355 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 ...
33
votes
17answers
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
264 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 ...
38
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
902 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
293 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
195 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
350 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 ...
18
votes
9answers
925 views

The Back-and-Forth Sequence

Imagine a path made up of < and > and ending in a @, e.g. ...
12
votes
10answers
760 views

Permutations with Indistinguishable Items

Given a list of integers, output the number of permutations of the integers, with indistinguishable permutations counted once. If there are n integers, and each ...
19
votes
5answers
2k views

Are there More Hard Objects or Soft Objects

Tangentially inspired by the opening to the What-If book. The input is a rectangle of spaces as a string, list of string, etc., with objects made of #'s inside: <...
50
votes
38answers
4k views

Stretch the word

The input is a word of lowercase letters not separated by whitespace. A newline at the end is optional. The same word must be output in a modified version: For each character, double it the second ...
17
votes
5answers
389 views

Go to opposite corner of rectangle in all directions - Harder

This is essentially the same thing as this question, except harder. You are again to write a program that gets from the lower-left corner of a rectangle to the upper-right corner. However, this time ...