Forum: Ruby autoreferential letter count

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
22610bf26fbc5bd949c8ba4646ceb006?d=identicon&s=25 p.capriotti (Guest)
on 2005-11-18 18:01
(Received via mailing list)
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
912c61d9da47754de7039f4271334a9f?d=identicon&s=25 mental (Guest)
on 2005-11-18 18:16
(Received via mailing list)
Quoting Paolo Capriotti <p.capriotti@gmail.com>:

> 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
4299e35bacef054df40583da2d51edea?d=identicon&s=25 james (Guest)
on 2005-11-18 20:29
(Received via mailing list)
On Nov 18, 2005, at 11:15 AM, mental@rydia.net 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 Gray II
3cb4fdcf13aad6a7dcae83876b0e784e?d=identicon&s=25 jupp (Guest)
on 2005-11-20 21:35
(Received via mailing list)
Hi!

At Sat, 19 Nov 2005 01:59:59 +0900, Paolo Capriotti 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
This topic is locked and can not be replied to.