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

learn more… | top users | synonyms

10
votes
1answer
122 views

Find the Fenceposts

Background An atomic bomb has exploded near the fencepost factory! Since fenceposts are essential for the survival of our civilization, we must rescue as many as possible. We are sending ...
7
votes
2answers
176 views

Non-crossing X's and crossing non-X's

You should write a program or function which given a text as input outputs or returns the sum of the following three integers: Number of lowercase x's which are not part of a cross-formation. Number ...
15
votes
6answers
665 views

Overlapping circle

You should write a program or function that given an N by N equally spaced square grid and a solid inscribed circle outputs or returns the number of grid squares which are overlapped partially or ...
4
votes
7answers
504 views

N-gram histogram

Given a text and a number N, output, in a human readable format, the set of the character N-grams with their respective percentages. The smallprint The text can be read from a file, stdin, passed ...
8
votes
36answers
3k views

Count the number of ones in unsigned 16 bit integer

Write some statement(s) which will count the number of ones in an unsigned sixteen bit integer. For example, if a variable s = 1337, then set ones to 6 because 1337 as a sixteen bit binary number is ...
2
votes
1answer
186 views

count number of valid, unique sequences for moving on a 1xn board [closed]

There's a board with n squares in a horizontal row. You start in the leftmost square, and roll a 3-faced dice. 3 possible outcomes for a single roll of the die: Left: you move 1 step to the left, ...
11
votes
2answers
968 views

The number of reachable snake orientations

This challenge is not about the game Snake. Imagine a 2d snake formed by drawing a horizontal line of length n. At integer points along its body, this snake can rotate its body by 90 degree. If we ...
4
votes
0answers
76 views

Resistent counter [duplicate]

You just have to ouput exactly all the numbers from 1 to 10 separated by spaces. Your programme should work all the times even if a random character is deleted before compiling/interpreting. This is ...
36
votes
14answers
5k views

Into how many pieces can you cut this string?

Consider a piece of string (as in "rope", not as in "a bunch of characters"), which is folded back and forth on the real line. We can describe the shape of the string with a list of points it passes ...
13
votes
3answers
1k views

Computer: you do the math

This challenge is partly an algorithms challenge, involves some math and is partly simply a fastest code challenge. For some positive integer n, consider a uniformly random string of 1s and 0s of ...
63
votes
9answers
6k views

Counting Grains of Rice

Consider these 10 images of various amounts of uncooked grains of white rice. THESE ARE ONLY THUMBNAILS. Click an image to view it at full size. A: B: C: D: E: F: G: H: I: J: Grain ...
7
votes
4answers
362 views

Line numbering - implement nl

Your task is to implement a program similar to the nl command-line tool from the GNU core utilities. Standard loopholes are banned. You may not use any built-in or external function, program or ...
15
votes
13answers
1k views

Display a tally (in varying bases)

Tallying is a simple counting system that works in base 5. There are various different tallying systems used around the world, but the one that is used in most English-speaking countries is perhaps ...
13
votes
2answers
586 views

How many characters per character?

At http://shakespeare.mit.edu/ you can find the full text of each of Shakespeare's plays on one page (e.g. Hamlet). Write a script that takes in the url of a play from stdin, such as ...
21
votes
19answers
3k views

How many IP addresses are in a given range?

Inspired by... Networking - How can I work out how many IP addresses there are in a given range? Write a program or function that takes two strings as input, each being an IPv4 address ...
37
votes
24answers
7k views

Fast, Cheap, and Good - Choose any Two

As programmers, we all know the saying: "You can have it fast and good, but it won't be cheap, you can have it cheap and good, but it won't be fast, or you can have it fast and cheap, but it won't be ...
51
votes
34answers
11k views

Avoid the evil integers!

You are developing some code to generate ID numbers. Policy requires that no ID numbers include the digit sequence 666. Create a function (or your language's equivalent) which takes a positive ...
0
votes
11answers
609 views

Count the unique fractions with only integers

Count the number of unique fractions with numerators and denominators from 1 to 100, and print the counted number. Example: 2/3 = 4/6 = ... Rules: You must actually count in some way. Only integers ...
13
votes
38answers
2k views

Count occurrences of an integer

Based on the question How many positive integers < 1,000,000 contain the digit 2?. I'm looking for the most creative solution to count all the Integers from X to Y containing the Integer Z. Z can ...
12
votes
35answers
3k views

Display number of occurrences for every character in an input string

The code should take a string as input from keyboard: The definition of insanity is quoting the same phrase again and again and not expect despair. The output should be like this(not sorted in any ...
0
votes
8answers
480 views

Create a programs that counts the 0's in numbers from 0 to a billion [duplicate]

This will be my very first post on stackexchange so bear with me. Create a program that counts from 0 to 1,000,000,000. Now the trick is to not print all these characters but to only print how many ...
-4
votes
6answers
382 views

Return the number of digits in any given number, without strings [closed]

Objective Given any terminating, rational number, return the number of digits the number contains. Do not count zeros if they're the last digits. Examples 0 returns 1 -1 returns 1 6.23 returns 3 ...
8
votes
7answers
797 views

Count the number of cyclic words in an input

Cyclic Words Problem Statement We can think of a cyclic word as a word written in a circle. To represent a cyclic word, we choose an arbitrary starting position and read the characters in ...
5
votes
17answers
2k views

Calculate the nth term of Golomb's self-describing sequence

Inspired by the previous question. Golomb's self-describing sequence g(n) is a sequence where any natural number n is repeated within the sequence g(n) times. The first few numbers in the sequence ...
7
votes
4answers
607 views

Convert from binary to unary in 7x7 Manufactoria

In the game manufactoria, take in a binary number and output that number of red pieces. The catch? The board-size is only 7x7: Here's the manufactoria code for the problem: ...
6
votes
8answers
551 views

Square-free semiprime counting

Definition A square-free semiprime is a natural number that is the product of two distinct prime numbers. The task Given a natural number n, count all square-free semiprimes less than or equal ...