Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cross-language challenge (of POSSIBLE interest)

Status
Not open for further replies.

WMK

Programmer
Jun 2, 2003
325
US
A complete "idiot" (I won't tell you what others call him) has posted a challenge in the PL/I newsgroup - based on his post in the Fortran newsgroup - in response to a C++ challenge <G>.

I responded in the PL/I newsgroup, that I wouldn't bother with this until it was asked by a valid COBOL programmer in the the COBOL newsgroup, but after looking at it, I thought it *MIGHT* be fun for some of us to actually come up with a COBOL soltuion. (Depending upon table size restrictions, I think that an UNSTRING and SEARCH solution should be medium easy to do).

Anyone interested in trying? (Besides requested timing, also include your compiler and OS used in the solution)

P.S. <joke> Extra credit for using ANSI/ISO ('85, '89, or '02) conforming syntax - except for processing of Line Sequential input/output.

> ------------- below posted in comp.lang.fortran ----------
> Want to give this a shot?
> Get the text file at: > Using a text editor (notepad) remove text before
> Book 01 Genesis and text after last word in Revelations, (amen)
> producing bible.txt file containing
> 4,947,047 chars.
>
> The challenge is to process bible.txt file into words array and count unique
> word occurances in count array.
> (this challenge was initiated by LR, whose C++ source/results will be posted
> later, along with my own source/results)..
>
> In this processing, convert all punctuation and numbers to blanks, and
> uppercase to lower.
> One punctuation exception is ' (within a word) is deleted leaving wife's
> as wifes
>
> When bible.txt is "thusly" processed I expect you shud get following outputs
> total words = 789781
> unique words = 12691
> xx.xx Sec ?.?? Ghz PC
>
> Pls post your time and PC speed..
>
> ! A few template statements in this word-processing benchmark challenge to
> get started are:
> ! -----------------------------
> program count_word_occurances ! in bible.txt
> implicit none
> integer,parameter :: maxw = 65536 ! or lower if possible
> character(24) :: words(maxw)
> integer :: i, n, counts(maxw)=0, t1(8), t2(8)
>
> call date_and_time(values=t1) ! get benchmark start time
>
> ! open file='bible.txt' ...
>
> ! process word occurances into the 2 arrays words,counts
> ! until EOF as per your word-processing algorithm
>
> call date_and_time(values=t2) ! get benchmark stop time
>
> n = 0 ! count unique words found
> do i = 1,maxw
> if (counts(i) /= 0) n = n+1
> end do
>
> write (*,*) 'total words =',sum(counts)
> write (*,*) 'unique words =',n
>
> write (*,'(f0.2,a)') (t2(5)*3600.+t2(6)*60.+t2(7) +t2(8)/1000.) &
> -(t1(5)*3600.+t1(6)*60.+t1(7) +t1(8)/1000.), ' Sec <- 2.8 Ghz PC'
> end program
>
>


Bill Klein
 
I tried it. It doubled the time. So 16-bit would have credence.

Also for those who are interested, a SEARCH table solution on my system is 2:22.64
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top