Re: Data file from one format to another.



From: Nobody Imparticular <forcrimanysakes@xxxxxxxxx>
Hi any and all;

I am having a heck of time getting my head around a
little problem I have run into; I got this question
during an interview recently and, well, failed
miserably. Now I am crazy to figure out the answer
since the answer seems like it would be easy, but
isn't (to me).

Lets say I have the following data in a text file;

A B C D E F G
A B C D E F H
A B C D E F I J
A B C D K L
A B C D M N
A B C D O P
A B C D Q R
A S T
A S U

I need to massage the data and print it out (to the
screen or file) as follows:

A
B C D
E F
G
H
I J
K L
M N
O P
Q R
S
T
U

I'm really at a loss for what to do. I've tried a
myriad of things (recursive calls to build a hash, to
build an array, to build a string) and basically I
could never fully get there .

I think the codeword is "trie". Have a look at the Text::Trie module
on CPAN.

You will need to massage the datastructure created by the module a
bit for that output, but I think it will help.

Jenda
===== Jenda@xxxxxxxxxxx === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

.



Relevant Pages

  • Data file from one format to another.
    ... I am having a heck of time getting my head around a ... during an interview recently and, well, failed ... build an array, to build a string) and basically I ...
    (perl.beginners)
  • Re: Long time......
    ... Hmm, perhaps in the course of the banging your head, you ... perhaps you'd like to recall your failed attempt to have me ... how could I have forgotten the breast massage? ...
    (alt.med.fibromyalgia)
  • Re: The Eyes Have It -- Part 2
    ... I have to admit a soft head massage I can tolerate but it is becoming so ... I do have a headache. ...
    (sci.med.transcription)
  • Re: arthritis in neck
    ... When my shoulders and/or neck act up/become tense, ... headaches,usually in the back of the head between the ears. ... Have you tried massage? ... I can slip mychin into and apply 6 to 10 pounds traction ...
    (alt.support.arthritis)
  • Re: Vet Tech Journals: Good and Bad News
    ... interview and you are not required to disclose any. ... So I need to go get my back evaluated again and see what the doctor ... I'm trying to exercise to lose weight. ... A physiotherapist can also give you ultrasound massage. ...
    (rec.pets.cats.anecdotes)