# Autoreferential letter count

**URL:** <https://www.ruby-forum.com/t/autoreferential-letter-count/48298>\
**Category:** Ruby\
**Created:** [November 18, 2005, 6:01pm UTC](https://www.ruby-forum.com/t/autoreferential-letter-count/48298 "2005-11-18T18:01:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![p.capriotti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/49beb7/32.png) [@p.capriotti](https://www.ruby-forum.com/u/p.capriotti)\
**Post date:** [November 18, 2005, 6:01pm UTC](https://www.ruby-forum.com/t/autoreferential-letter-count/48298/1 "2005-11-18T18:01:51Z")

</div>

I propose the following for the next week quiz:

Write a ruby program that takes a sentence as its input an produces an  
output that autoreferentially describes the letters found in the  
sentence _and_ the description itself.

This is an example in italian:

Questa nota contiene esattamente: cinque A sette C nove D diciotto E  
dodici I due M otto N undici O tre Q due R sei S diciotto T sette U  
due V.

That means:

This note contains exactly: five A’s seven C’s nine D’s eighteen E’s  
twelve I’s two M’s eight N’s eleven O’s three Q’s two R’s six S’s  
eighteen T’s seven U’s two V’s.

(which is false, but its’ true in the italian version).

I’m sorry I don’t have an English example at the moment, but I hope  
that the problem is quite easy to understand anyway.

Paolo

---

<div class="post-metadata">

**Author:** ![p.capriotti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/49beb7/32.png) [@p.capriotti](https://www.ruby-forum.com/u/p.capriotti)\
**Post date:** [November 18, 2005, 6:16pm UTC](https://www.ruby-forum.com/t/autoreferential-letter-count/48298/2 "2005-11-18T18:16:57Z")

</div>

Quoting Paolo C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I propose the following for the next week quiz:
> 
> Write a ruby program that takes a sentence as its input an  
> produces an output that autoreferentially describes the letters  
> found in the sentence _and_ the description itself.

Interesting. This is basically equivalent to writing a function  
which takes a message and produces a combined message + header,  
where the header includes a checksum/digest of the combined message

- header.

I don’t believe that’s possible in general, but it may be in  
specific cases, depending on the properties of the particular  
checksumming algorithm chosen.

-mental

---

<div class="post-metadata">

**Author:** ![p.capriotti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/49beb7/32.png) [@p.capriotti](https://www.ruby-forum.com/u/p.capriotti)\
**Post date:** [November 18, 2005, 8:29pm UTC](https://www.ruby-forum.com/t/autoreferential-letter-count/48298/3 "2005-11-18T20:29:47Z")

</div>

On Nov 18, 2005, at 11:15 AM, removed\_email\_address@domain.invalid wrote:

> Interesting. This is basically equivalent to writing a function  
> which takes a message and produces a combined message + header,  
> where the header includes a checksum/digest of the combined message
> 
> - header.
> 
> I don’t believe that’s possible in general, but it may be in  
> specific cases, depending on the properties of the particular  
> checksumming algorithm chosen.

Hmm, I’m not sure that makes a great quiz then, unless we supply a  
good number of test cases known to work.

James Edward G. II

---

<div class="post-metadata">

**Author:** ![p.capriotti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/49beb7/32.png) [@p.capriotti](https://www.ruby-forum.com/u/p.capriotti)\
**Post date:** [November 20, 2005, 9:35pm UTC](https://www.ruby-forum.com/t/autoreferential-letter-count/48298/4 "2005-11-20T21:35:37Z")

</div>

Hi!

At Sat, 19 Nov 2005 01:59:59 +0900, Paolo C. wrote:

> I propose the following for the next week quiz:
> 
> Write a ruby program that takes a sentence as its input an produces  
> an output that autoreferentially describes the letters found in the  
> sentence _and_ the description itself.

As long as one restricts oneself to a single language that is no  
problem but as soon as several languages are involve things become  
naughty. Dutch 'coördinatie" (coordination) contains

1 a, 2 c, 1 d, 1 e, 2 i, 1 n, 2 o, 1 r, 1 t

while German “Diätplan” contains

1 a, 1 ä, 1 d, 1 i, 1 l, 1 n, 1 p, 1 t

You see that depending on the language the trema either introduces a  
new letter or not.

Even if a German sentence contains no umlaut (ä, ö, ü) at all, the  
count still may because 5 reads ‘fünf’ (as a result the  
‘ü’ iscontained in any number containing the digit ‘5’), and 12 reads  
"zwölf’.

Tot ziens,

Josef ‘Jupp’ Schugt
