Computer Science Canada

Shortening this code? or easier to write it?

Author:  SpaceDude [ Tue Jun 08, 2004 8:23 pm ]
Post subject:  Shortening this code? or easier to write it?

anyone know how i can shorten this code up? or write it easier?

code:
var Names : array 1..100  of string

Names (1) := "Bob"
Names (2) := "Albert"
Names (3) := "Patrick"
.
.
.
.
.
Names (98) := "Sam"
Names (99) := "Thomas"
Names (100) := "Raymond"

Author:  aside [ Tue Jun 08, 2004 8:46 pm ]
Post subject: 

you can store the names in a file and call it, then use get with your variables.

Author:  SpaceDude [ Tue Jun 08, 2004 8:49 pm ]
Post subject: 

what if it has to be all done in one turing file, like no side files and etc?

Author:  aside [ Tue Jun 08, 2004 8:51 pm ]
Post subject: 

well, you can simplify it a little by this:
code:

var names: array 1..100 of int :=init("bob", "mjkjk", ...."kdj")

and why does it have to be done in one file?

Author:  SpaceDude [ Tue Jun 08, 2004 8:53 pm ]
Post subject: 

cuz is a project lol, i have to submit it, so basically it has to be all done in this turing file and no sidefiles

Author:  aside [ Tue Jun 08, 2004 8:56 pm ]
Post subject: 

well, that's just stupid. and why do you need all these names?
anyway, ignore me.

Author:  SpaceDude [ Tue Jun 08, 2004 8:57 pm ]
Post subject: 

o the file is similar to this is not the same though lol

so basically there is no other way to shorten this code up?

Author:  aside [ Tue Jun 08, 2004 9:01 pm ]
Post subject: 

well, you have to include all the names somehow, think about it, it is already simple enough.

Author:  SpaceDude [ Tue Jun 08, 2004 9:11 pm ]
Post subject: 

i guess lol thanks
if any 1 else have any ideas or suggestions just post it here i wanna see if there is other ways, cuz it is very very long lol

Author:  Tony [ Tue Jun 08, 2004 9:47 pm ]
Post subject: 

random name generation! Laughing
code:

function randomName () : string
    const v : string := "aeiouy"
    const c : string := "bcdfghjklmnpqrstvwxz"
    var r1, r2, r3 : int
    r1 := Rand.Int (1, length (c))
    r2 := Rand.Int (1, length (v))
    r3 := Rand.Int (1, length (c))
    result c (r1) + v (r2) + c (r3)
end randomName

for i : 1 .. 10
    put randomName ()
end for

Author:  SpaceDude [ Wed Jun 09, 2004 12:02 am ]
Post subject: 

lol tahts pretty amazing lol
but their not really names lol

Author:  Tony [ Wed Jun 09, 2004 2:34 pm ]
Post subject: 

i'm sorry, but that's as close as you can get to real names without the use of any kind of external dictionary... Some names generated are preaty good actually Laughing

Author:  SpaceDude [ Wed Jun 09, 2004 3:09 pm ]
Post subject: 

lol ic
i guess so lol

Author:  Paul [ Thu Jun 10, 2004 6:27 pm ]
Post subject: 

Just get one of those name lists, put it into a text file, then load them up into an array using a loop, and randomly choose some names.

Author:  naoki [ Fri Jun 25, 2004 4:25 pm ]
Post subject: 

apprently, either spacedude sucks or whoever's teaching him sucks

why in god's name would a teacher demand 100 names from a student, without the use of textfiles, and won't accept anything with improv like random name generation?

now, you could do something like whenever you take a name, and put it into an array, take the next array space, and using the same name, catenate "ina" to the end, to make it seem like a girls

code:

for x : 1 .. 100 by 2
      put "input a name"
      get name : *
       namelist (x) := name
      namelist (x+1) := name + "ina"
end for

Author:  cbc [ Wed Jul 07, 2004 8:04 pm ]
Post subject: 

justinina?
bobina?
simonina?
i dont think so

Author:  AsianSensation [ Wed Jul 07, 2004 9:10 pm ]
Post subject: 

cbc wrote:
justinina?
bobina?
simonina?
i dont think so


I'd subtract bits from you, until I realized you have none......

This means quit spamming in help sections, go to general discussion or something.


: