Qbasicnews.com

Full Version: Word Scrambler (kind of) Challenge
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Quote:Heheh this submission was posted while I was still in the process of writin g the challenge, and obviously doesn't meet some of the challenge criteria. Very impressive, though! >o.O;<

Thanks, I had it lying around, so that's ok :wink:
Quote:Hello, Meg.

Hmm, you won't get both efficiency and one-function-code.

One should set goals, not the programming styles (except for very rare cases).

If we are to limit ourselves to "number of functions," then we will end up with spaghetti code. If we are to squeeze actions into functions, the golden "granularity rule" is broken...

The more it breaks down into functions, the better.

Looking for another entries here, too.

I find antoinos code a LOT more efficient then yours, yours is a mess, whereas Antonios is easily understood, and editable.

Calling a function is slow btw, so less functions = more efficient.
Without my trick of the "sentinel" you must call the scrambler from two points of the program, so using an auxiliar function is very handy.

There is another possible trick: Meg forgot speaking about GOSUBS in her rules....Wink
Compare
Quote:I find antoinos code a LOT more efficient then yours, yours is a mess, whereas Antonios is easily understood, and editable.
of Zire, and
Quote:' Use that StrTok$ right away and think about its past.
of mine.

Mine meant a lot to those who got the POINT, as that StrTok$ belonged to Microsoft (those proficient in QB: find it in your original installation disks).

Compare
Quote:The more it breaks down into functions, the better.
of mine to that of
Quote:Calling a function is slow btw, so less functions = more efficient
from Zire.

Do you call "less functions"="efficiency"? Where were you?

Yes, we all have some children in ourselves, but let's hope that those children won't make us sink that low, as to become an illiterate, or arrogant.

That should be all there is to it.

*Peace*, I repeat.
Quote:Yes, we all have some children in ourselves, but let's hope that those children won't make us sink that low, as to become an illiterate, or arrogant.

...

How many exactly? :lol:
Quote:"Behold, I teach you the superman."
- Thus Spake Zarathustra, The 'Miracle Man' Series.

Talking rubbish? Anyway, evening, y'all...
There are different types of efficieny. Speed and size. Lets not have driveby comments and such, constructive cristiscm is lot harder but a lot better.
What I'm looking for is neat, easy-to-follow code which is contained in one function. The reason for keeping this to one function is simple: it's a CHALLENGE. Sure there's ways of doing this which results in calls to one-task functions, each one more refined than the last. That's standard programming procedure. But this is limited because it's supposed to make people think outside of the "usual." That's why it's a challenge.

So, do your best within the limitations. It's not that complex a task.

Antoni, I went ahead and wrote my own entry to this contest after I'd posted it, and now that I look I realize that mine's VERY close to the one you entered! ^_^

My entry doesn't count, of course. So far Antoni is the only valid entry. Let's see if anybody can do better!

This was mine:
Code:
DECLARE FUNCTION Jumble$ (t$)

LINE INPUT InputText$
PRINT Jumble$(InputText$) + "-"

FUNCTION Jumble$ (InputText$)

InputText$ = InputText$ + " "
Ends$ = "0123456789!$&() ,.?';:" + CHR$(34)

FOR Position% = 1 TO LEN(InputText$)
     Letter$ = MID$(InputText$, Position%, 1)

     IF INSTR(Ends$, Letter$) THEN
          IF Word$ > "" THEN
               J$ = J$ + LEFT$(Word$, 1)
               Word$ = RIGHT$(Word$, LEN(Word$) - 1)
               WHILE LEN(Word$) > 1
                    x% = INT(RND * (LEN(Word$) - 1)) + 1
                    J$ = J$ + MID$(Word$, x%, 1)
                    Word$ = LEFT$(Word$, x% - 1) + RIGHT$(Word$, LEN(Word$) - x%)
               WEND
               J$ = J$ + Word$
               Word$ = ""
          END IF
          J$ = J$ + Letter$
     ELSE
          Word$ = Word$ + Letter$
     END IF
NEXT Position%

Jumble$ = LEFT$(J$, LEN(J$) - 1)

END FUNCTION

*peace*

Meg.
Efficient code is when you can read it easily, and it's fast, and get's the job done.

Easy code, is when you can understand it and follow it easily by reading it.



It's like this:
"How do I play a wav file in QB?"
"Duh, Call DQB.PlayWavFile(File$)"

EDIT: (Above is NOT easy, sure, easy, but not easy as in easy to understand HOW YOU ACTUALLY DO IT!, kid)



And read my entire posts you clown!
"Calling a function is slow btw, so less functions = more efficient"

Code:
If program = slow Then efficient = FALSE


*slap slam, kick, rip, tear!*
This clown went on an educational trip to beautiful Ankara city, but sees that the issue is pursued.

Let us see
Quote:And read my entire posts you clown!
"Calling a function is slow btw, so less functions = more efficient"
and
Code:
If program = slow Then efficient = FALSE
Here's Zire's matchless logic:
Code:
IF program = slow THEN efficient = false SO efficient = fast
What's your profession, Zire? Do you hold a degree? Hope not.

Word "efficient" deals with "how" you do the task, whereas "fast" deals with the time you need to complete it. If efficiency dealt with time taken [as in your bare logic(!) ], things would have been tad easier.

So, note to self: Send Zire a dictionary for his/her very next birthday.

Viewers: Please do not get this to be a problematic approach to the subject, and I have nothing to do with Zire -either good or bad- and am sure, neither does he/she.

There are hundreds ways of naming things, but for the humane, they -for sure- aren't "clown"s, "kid"s, or "mess"es.

Got it, Zire?
Pages: 1 2 3