Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

81%
+7 −0
Challenges Word Count Tool

In Google Docs, the word count tool looks like this: Pages would not make sense, but your goal is to implement every other count. Definitions Words are strings of text separated by any amount ...

9 answers  ·  posted 3y ago by Quintec‭  ·  last activity 2y ago by torres‭

Question code-golf string
#5: Post edited by user avatar General Sebast1an‭ · 2021-08-12T19:02:52Z (over 2 years ago)
Word Count Tool
  • In Google Docs, the word count tool looks like this:
  • ![Word count](https://codegolf.codidact.com/uploads/Howm5Y9o42uzdnEsnNrU1PHb)
  • Pages would not make sense, but your goal is to implement every other count.
  • # Definitions
  • **Words** are strings of text separated by any amount of whitespace (spaces, tabs, newlines).
  • **Characters** are all printable bytes*. For the sake of this challenge, you may assume all inputs will consist of printable bytes. Note that Google Docs does not count newlines in its character count, so you must do the same.
  • *I define printable bytes as the variable string.printable in Python, which is shown below.
  • ```
  • >>> string.printable
  • '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
  • ```
  • # Input
  • A string of text, or a list of strings instead of a multiline string if you wish.
  • # Output
  • The 3 counts (words, characters, characters without spaces) in any order, and in an array if you like.
  • # Examples
  • ```
  • Input -> [words, characters, characters without spaces]
  • "Hello world" -> [2, 11, 10]
  • "H3ll0 w0r1d" -> [2, 12, 10]
  • "Hello \t\nworld" -> [2, 12, 11]
  • "\n\n\n" -> [0, 0, 0]
  • " " -> [0, 3, 0]
  • ```
  • This is code golf, so shortest code wins.
  • In Google Docs, the word count tool looks like this:
  • ![Word count](https://codegolf.codidact.com/uploads/Howm5Y9o42uzdnEsnNrU1PHb)
  • Pages would not make sense, but your goal is to implement every other count.
  • # Definitions
  • **Words** are strings of text separated by any amount of whitespace (spaces, tabs, newlines).
  • **Characters** are all printable bytes*. For the sake of this challenge, you may assume all inputs will consist of printable bytes. Note that Google Docs does not count newlines in its character count, so you must do the same.
  • *I define printable bytes as the variable string.printable in Python, which is shown below.
  • ```
  • >>> string.printable
  • '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
  • ```
  • # Input
  • A string of text, or a list of strings instead of a multiline string if you wish.
  • # Output
  • The 3 counts (words, characters, characters without spaces) in any order, and in an array if you like.
  • # Examples
  • ```
  • Input -> [words, characters, characters without spaces]
  • "Hello world" -> [2, 11, 10]
  • "H3ll0 w0r1d" -> [2, 12, 10]
  • "Hello \t\nworld" -> [2, 12, 11]
  • "\n\n\n" -> [0, 0, 0]
  • " " -> [0, 3, 0]
  • ```
  • This is <a class="badge is-tag">code golf</a>, so shortest code wins.
#4: Post edited by user avatar Razetime‭ · 2021-06-21T14:59:29Z (almost 3 years ago)
fix last test case minus
Word Count Tool
  • In Google Docs, the word count tool looks like this:
  • ![Word count](https://codegolf.codidact.com/uploads/Howm5Y9o42uzdnEsnNrU1PHb)
  • Pages would not make sense, but your goal is to implement every other count.
  • # Definitions
  • **Words** are strings of text separated by any amount of whitespace (spaces, tabs, newlines).
  • **Characters** are all printable bytes*. For the sake of this challenge, you may assume all inputs will consist of printable bytes. Note that Google Docs does not count newlines in its character count, so you must do the same.
  • *I define printable bytes as the variable string.printable in Python, which is shown below.
  • ```
  • >>> string.printable
  • '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
  • ```
  • # Input
  • A string of text, or a list of strings instead of a multiline string if you wish.
  • # Output
  • The 3 counts (words, characters, characters without spaces) in any order, and in an array if you like.
  • # Examples
  • ```
  • Input -> [words, characters, characters without spaces]
  • "Hello world" -> [2, 11, 10]
  • "H3ll0 w0r1d" -> [2, 12, 10]
  • "Hello \t\nworld" -> [2, 12, 11]
  • "\n\n\n" -> [0, 0, 0]
  • " " > [0, 3, 0]
  • ```
  • This is code golf, so shortest code wins.
  • In Google Docs, the word count tool looks like this:
  • ![Word count](https://codegolf.codidact.com/uploads/Howm5Y9o42uzdnEsnNrU1PHb)
  • Pages would not make sense, but your goal is to implement every other count.
  • # Definitions
  • **Words** are strings of text separated by any amount of whitespace (spaces, tabs, newlines).
  • **Characters** are all printable bytes*. For the sake of this challenge, you may assume all inputs will consist of printable bytes. Note that Google Docs does not count newlines in its character count, so you must do the same.
  • *I define printable bytes as the variable string.printable in Python, which is shown below.
  • ```
  • >>> string.printable
  • '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
  • ```
  • # Input
  • A string of text, or a list of strings instead of a multiline string if you wish.
  • # Output
  • The 3 counts (words, characters, characters without spaces) in any order, and in an array if you like.
  • # Examples
  • ```
  • Input -> [words, characters, characters without spaces]
  • "Hello world" -> [2, 11, 10]
  • "H3ll0 w0r1d" -> [2, 12, 10]
  • "Hello \t\nworld" -> [2, 12, 11]
  • "\n\n\n" -> [0, 0, 0]
  • " " -> [0, 3, 0]
  • ```
  • This is code golf, so shortest code wins.
#3: Post edited by user avatar Quintec‭ · 2021-06-21T03:36:40Z (almost 3 years ago)
  • In Google Docs, the word count tool looks like this:
  • ![Word count](https://codegolf.codidact.com/uploads/Howm5Y9o42uzdnEsnNrU1PHb)
  • Pages would not make sense, but your goal is to implement every other count.
  • # Definitions
  • **Words** are strings of text separated by any amount of whitespace (spaces, tabs, newlines).
  • **Characters** are all printable bytes*. For the sake of this challenge, you may assume all inputs will consist of printable bytes. Note that Google Docs does not count newlines in its character count, so you must do the same.
  • *I define printable bytes as the variable string.printable in Python, which is shown below.
  • ```
  • >>> string.printable
  • '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
  • ```
  • # Input
  • A string of text.
  • # Output
  • The 3 counts (words, characters, characters without spaces) in any order, and in an array if you like.
  • # Examples
  • ```
  • Input -> [words, characters, characters without spaces]
  • "Hello world" -> [2, 11, 10]
  • "H3ll0 w0r1d" -> [2, 12, 10]
  • "Hello \t\nworld" -> [2, 12, 11]
  • "\n\n\n" -> [0, 0, 0]
  • " " > [0, 3, 0]
  • ```
  • This is code golf, so shortest code wins.
  • In Google Docs, the word count tool looks like this:
  • ![Word count](https://codegolf.codidact.com/uploads/Howm5Y9o42uzdnEsnNrU1PHb)
  • Pages would not make sense, but your goal is to implement every other count.
  • # Definitions
  • **Words** are strings of text separated by any amount of whitespace (spaces, tabs, newlines).
  • **Characters** are all printable bytes*. For the sake of this challenge, you may assume all inputs will consist of printable bytes. Note that Google Docs does not count newlines in its character count, so you must do the same.
  • *I define printable bytes as the variable string.printable in Python, which is shown below.
  • ```
  • >>> string.printable
  • '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
  • ```
  • # Input
  • A string of text, or a list of strings instead of a multiline string if you wish.
  • # Output
  • The 3 counts (words, characters, characters without spaces) in any order, and in an array if you like.
  • # Examples
  • ```
  • Input -> [words, characters, characters without spaces]
  • "Hello world" -> [2, 11, 10]
  • "H3ll0 w0r1d" -> [2, 12, 10]
  • "Hello \t\nworld" -> [2, 12, 11]
  • "\n\n\n" -> [0, 0, 0]
  • " " > [0, 3, 0]
  • ```
  • This is code golf, so shortest code wins.
#2: Post edited by user avatar Quintec‭ · 2021-06-20T22:28:40Z (almost 3 years ago)
  • In Google Docs, the word count tool looks like this:
  • ![Word count](https://codegolf.codidact.com/uploads/Howm5Y9o42uzdnEsnNrU1PHb)
  • Pages would not make sense, but your goal is to implement every other count.
  • # Definitions
  • **Words** are strings of text separated by any amount of whitespace (spaces, tabs, newlines).
  • **Characters** are all printable bytes. For the sake of this challenge, you may assume all inputs will consist of printable bytes. Note that Google Docs does not count newlines in its character count, so you must do the same.
  • # Input
  • A string of text.
  • # Output
  • The 3 counts (words, characters, characters without spaces) in any order, and in an array if you like.
  • # Examples
  • ```
  • Input -> [words, characters, characters without spaces]
  • "Hello world" -> [2, 11, 10]
  • "H3ll0 w0r1d" -> [2, 12, 10]
  • "Hello \t\nworld" -> [2, 12, 11]
  • "\n\n\n" -> [0, 0, 0]
  • " " > [0, 3, 0]
  • ```
  • This is code golf, so shortest code wins.
  • In Google Docs, the word count tool looks like this:
  • ![Word count](https://codegolf.codidact.com/uploads/Howm5Y9o42uzdnEsnNrU1PHb)
  • Pages would not make sense, but your goal is to implement every other count.
  • # Definitions
  • **Words** are strings of text separated by any amount of whitespace (spaces, tabs, newlines).
  • **Characters** are all printable bytes*. For the sake of this challenge, you may assume all inputs will consist of printable bytes. Note that Google Docs does not count newlines in its character count, so you must do the same.
  • *I define printable bytes as the variable string.printable in Python, which is shown below.
  • ```
  • >>> string.printable
  • '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
  • ```
  • # Input
  • A string of text.
  • # Output
  • The 3 counts (words, characters, characters without spaces) in any order, and in an array if you like.
  • # Examples
  • ```
  • Input -> [words, characters, characters without spaces]
  • "Hello world" -> [2, 11, 10]
  • "H3ll0 w0r1d" -> [2, 12, 10]
  • "Hello \t\nworld" -> [2, 12, 11]
  • "\n\n\n" -> [0, 0, 0]
  • " " > [0, 3, 0]
  • ```
  • This is code golf, so shortest code wins.
#1: Initial revision by user avatar Quintec‭ · 2021-06-20T21:44:44Z (almost 3 years ago)
Word Count Tool
In Google Docs, the word count tool looks like this: 

![Word count](https://codegolf.codidact.com/uploads/Howm5Y9o42uzdnEsnNrU1PHb)

Pages would not make sense, but your goal is to implement every other count.

# Definitions

**Words** are strings of text separated by any amount of whitespace (spaces, tabs, newlines).
**Characters** are all printable bytes. For the sake of this challenge, you may assume all inputs will consist of printable bytes. Note that Google Docs does not count newlines in its character count, so you must do the same.

# Input

A string of text.

# Output

The 3 counts (words, characters, characters without spaces) in any order, and in an array if you like.

# Examples

```
Input -> [words, characters, characters without spaces]
"Hello world" -> [2, 11, 10]
"H3ll0  w0r1d" -> [2, 12, 10]
"Hello \t\nworld" -> [2, 12, 11]
"\n\n\n" -> [0, 0, 0]
"   " > [0, 3, 0]
```

This is code golf, so shortest code wins.