Random Number problems(math)

Hay once more
well l have searched ur database and found one thing that is wat l want but there happens to be a problem l don’t have appleworks 6 (l think that was the program)
well basiclly l kinda want a script that spits out 100 random numbers onto a word or other mac osx program as both of my parents are teachers(l’m 14) and they would very much like something that would do that for them
thanx in advance
-killsquad92-

Model: Mac osx 10.4 G4
AppleScript: 1.10? or version 2.1(80)?
Browser: Safari 412
Operating System: Mac OS X (10.4)

Hi killsquad,

hey, we have something in common :wink: (parents = teachers) …

here’s an attempt to solve the job - you can easily modify the the generated list with altering the options of makeRandomNumbersString:

1st option: length of the number list
2nd option: maximum value of the generated numbers
3rd option: delimiter to be used to separate the numbers in the list.

the result is a list of random numbers as string in the pasteboard - you can simply hit paste in any application after running the script.

Hope that helps …

Dominik

do shell script ("echo " & (quoted form of (my makeRandomNumbersString(100, 50, ", "))) & " | pbcopy")


on makeRandomNumbersString(arraySize, numberMax, numberDelimiter)
	set rndArray to {}
	repeat with n from 1 to arraySize
		set rndArray to rndArray & ((random number (numberMax) as integer) as string)
	end repeat
	set {olddelims, text item delimiters} to {text item delimiters, numberDelimiter}
	set retVal to rndArray as string
	set text item delimiters to olddelims
	return retVal
end makeRandomNumbersString

um…yea l trued that script u made and well nothing happened
…am l missing something?

  • l’m pretty new to scripting but l do know the basics but l can read it and l learn fast
    yea l got it if u can down load the mulisheet 2.1 l think …its a program that is wat l was talking about in my last post and well look @ it and try to modify it for me plz
    l had a try and got no where so yea
    look for 100 math
    in… um…wheres the place…l think it is scripted something or other…l forget u could try searching for it on the site via other ways though…um well yea good luck
    -killsquad92-
    u deserve a medal if u understand wat l just wrote

Sure you read what I wrote above? The result of the script is in the pasteboard - until you haven’t entered a ‘paste’ command somewhere nothing happens … :wink:

Ok - but if you want to have it automatically pasted in an other application - here’s an example for TextEdit:

set randList to my makeRandomNumbersString(100, 50, ", ")
tell application "TextEdit"
	make new document
	set text of document 1 to randList
end tell


on makeRandomNumbersString(arraySize, numberMax, numberDelimiter)
	set rndArray to {}
	repeat with n from 1 to arraySize
		set rndArray to rndArray & ((random number (numberMax) as integer) as string)
	end repeat
	set {olddelims, text item delimiters} to {text item delimiters, numberDelimiter}
	set retVal to rndArray as string
	set text item delimiters to olddelims
	return retVal
end makeRandomNumbersString

Hi,

Try this. Do you want the numbers to be integers?

--Make empty string.
set myList to ""
--repeat 100 times
repeat with x from 1 to 100
	--Add a a random number and return to the text.
	set myList to myList & (random number) & return
end repeat
tell application "TextEdit"
	activate
	--Make new window in TextEdit.
	set myWindow to make new document
	-- Name it.
	set name of front window to "Random Numbers"
	--Add the text.
	set text of myWindow to myList
end tell

John M

Unfortunately, some parents are not always good teachers.

True they could be evil and eat the children…
-killsquad92-
u put the fun in dysfunctuional

Dominik and kel and john m
l tryed ur scripts and they work but l don’t think u understand wats l’m asking…
yes ur spits out random number but the kids are in yr 3-4 not 12

  • there seposed to be times tables …
    yea so basiclly
    l need tha scripts u guys wrote to make a number between 1 - 12 x another random number between 1- 12

and if it’s possible can they be in 2 lines down the one page

thanx
but ur scripts did work so good job
-killsquad92-

Do you want something like this?

set numList to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
set theMult to ""
repeat 50 times
	set theMult to theMult & (((((some item in numList) as string) & " x " & (some item in numList) as string) & " = ") & return & return)
end repeat
tell application "TextEdit"
	activate
	set myWindow to make new document
	set name of front window to "Random Numbers"
	set text of myWindow to theMult
end tell

j

Yes precisly that except the ? at the end
thanx to all that helped
-killsquad92-

actually can u put it into 2 lists?
for me
thanx
-killsquad92-

I just edited it in my post (not that you couldn’t have done that yourself.)

l did
any progress on tha 2 coloums?
-killsquad92-

Oops, we were posting at the same time - do you mean 2 columns each of 25 problems?

yea we gotta be posting @ tha same time
l changed ur script a little just two 100 problems and no ? at the end
and yea l kinda want that so it fits on one page
thanx
-killsquad92-

All right now, I read this several times, but my “dude” days are in the past. I understand “no ? at the end”
Could you translate that to “Old Dude?” :wink:

Unless you figured it out yourself already…

7 x 4 = 10 x 4 =
3 x 5 = 7 x 6 =

u getting tha point?
yea… 2 coloums
-killsquad92-
which did u like more ‘dude’ or old dude?
like more?

I still speak “pidgin Dude” and give me a few minutes… my typing isn’t much better than hunt and peck.

thats a very intellegent way of putting “l carn’t type fast!”
l’ll give u some more time
but can we actually talk about tha script with the 2 coloums plz l really want that
-killsquad92-

l gotta cruze l’ll be back later can u have the script done bye then?
well try to for me
-killsquad92-