The strange thing is that pradsham just asked the same thing.
Are you in the same class?
"Livet är hårt" sa bonden.
"Grymt" sa grisen...
| [reply] |
If you really have attempted to solve this on your own and are still scratching your head, try the perldsc documentation. Wait, it's conveniently located here at perldoc.com. | [reply] |
I threw it into a short bit of code.
It don't print the results, but it gets you the data
structure. I cut out the \s in case it is homework,
don't want to make it too easy :)
while (<DATA>){my($s,$c,$dl)=split(':');
$sd=~s/^\s+|\s+$//;@sd=split(' ',$dl);
@sd=sort{$a<=>$b}@sd;$r{$s}{$c}{'h'}=pop@sd;
$r{$s}{$c}{'l'}=shift@sd}
__DATA__
CA:San Francico: 56 45 53 35 42 24 89 67 85 45 65 45 87 64
CA:Freemont: 87 78 67 65 98 78 78 43 98 45 82 48 78 47
Texas:Houston: 98 67 101 78 92 56 89 57 83 45 76 46 76 29
Texas:Dallas: 78 45 79 54 89 56 82 54 76 46 73 45 65 56
| [reply] [d/l] |
What I threw together below below seems to work, and includes sample data (including data to cause the multiple-city temperature case). I know it can probably be done better, however, and I would hope other, more experienced monks would comment so we all might learn from their experience. Good luck in finding your solution.
begin 664 test8.pl
M(R$O=7-R+V)I;B]P97)L("UW"G5S92!S=')I8W0["G5S92!W87)N:6YG<SL*
M"FUY("5R97-U;'1S(#T@*"`B;6EN(B`]/B`M,2P@(FUA>"(@/3X@,2`I.PIM
M>2`H)6UI;FUA>"P@)&QI;F4L("1L;V-A;&4L("1C:71Y+"`D<W1A=&4L("1R
M97-U;'0L($!T96UP<RD["@IW:&EL92`H)&QI;F4@/2`\1$%403XI('L*"6-H
M;VUP*"1L:6YE*3L*"2@D;&]C86QE+"!`=&5M<',I(#T@<W!L:70H+UQS*R\L
M("1L:6YE*3L*"2@D<W1A=&4L("1C:71Y*2`]('-P;&ET*"\L+RP@)&QO8V%L
M92P@,BD["@H)>PH)"2,@4V]R="!T:&4@=&5M<&5R871U<F5S"@D);7D@0'-T
M96UP<R`]('-O<G0@>R1A(#P]/B`D8GT@0'1E;7!S.PH)"4!T96UP<R`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(#,T(#8W(#,X(#8V(#,T(#4V(#,Q(#8W(#0U(#<Q(#0U(#8U(#0R
M(`I4>"Q(;W5S=&]N(#(X(#,P(#,Q(#,Q(#,T(#,V(#4Q(#<R(#<U(#<U(#<W
M(#<Y(#@Q(#@X"E1X+$1A;&QA<R`R."`R."`S,B`T,R`T-2`T-2`T-B`W-B`W
1."`W.2`X,R`X-"`X-B`X-PH`
`
end
Update: After finding shortly after posting this that there was a high probability this was indeed homework (compare with How do i sort), I was quite angry, and in my anger posted it to both, thinking perhaps they might at least get caught in their attempt to dupe those willing to help. Perhaps it was poor etiquite of me to post the solution on both questions, and if so, I appologize to the other monks herein. For a while, I considered removing my code altogether, but was unsure if that would be appropriate either. I am grateful for the sage advice of tilly, jeffa, and others, who suggested another course of action. The block that has now replaced the code above is actually the code, as I tested it, UUEncoded. Perhaps it only slows down those who would take advantage of the willingness to help found here, perhaps not. It is my hope that damage to trust by those involved is realized. It is sad to think that now, with each post I read and consider, the question in my mind will be, "is this a real request for help, or homework?" | [reply] [d/l] |