ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old June 9th, 2003, 02:10 PM
pshah pshah is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 1 pshah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question ASP 2 dim array not working perfectly

I've been playing with this 2 dimensional array for weeks and i think i've finally run out of ideas on what more to try. Basically it's a 2 dimensional array that i want to randomize by both rows and by columns. So looking either horizontally or vertically, i should not see any repeat numbers from 1-10. It works, but only in one way, either vert. or horiz. but not both ways (you can comment out the colgood = false or rowgood = false to see one of the pieces of code working, so currently colgood is disabled and so rows wise all the numbers should be unique) Could it be taking too long to process (script always times out) or is my code faulty ? thanks for looking and attempting, below is my code and below that is couple examples:


<%

dim random_number(9,9) '(10 columns,10 rows)
dim Rows, Columns, checkRows, checkColumns, colgood, rowgood

randomize

For Rows = 0 to 9
For Columns = 0 to 9

colgood = "true"
rowgood = "true"

random_number(Columns,Rows) = Int(Rnd * 10) + 1

for checkColumns= 0 to Columns - 1
if random_number(checkColumns, Rows)= random_number(Columns, Rows) then
'colgood = "false"
end if
next

if colgood = "true" then
for checkRows= 0 to Rows - 1
if random_number(Columns,checkRows) = random_number(Columns,Rows) then
rowgood = "false"
end if
next
end if

if (colgood = "false" OR rowgood = "false") then
Columns=Columns-1
end if
next
next

For Rows = 0 to 9
For Columns = 0 to 9
response.write random_number(Columns,Rows) & " "
next
response.write("<br><br>")
next
%>





here is the output when you comment out "colgood = false" (pick any column and you'll see random unique numbers from 1-10)

1 6 1 10 9 3 2 6 1 1

6 10 9 6 5 2 4 7 4 2

2 4 2 7 8 6 6 5 3 4

9 8 6 8 2 9 7 2 7 10

4 5 7 5 3 7 3 8 5 5

7 3 4 1 6 8 5 10 8 9

8 1 8 9 10 5 1 9 6 6

5 2 5 4 1 1 10 3 10 8

3 9 3 3 4 4 9 1 9 7

10 7 10 2 7 10 8 4 2 3

Comment: see how looking horizontally they repeat ?


now here is the code when you disable the "rowgood=false" line:
8 2 10 7 5 3 1 6 4 9

2 10 7 5 1 6 4 9 3 8

10 3 2 4 8 1 6 5 9 7

9 10 4 8 2 7 3 6 5 1

3 9 7 8 10 6 4 1 2 5

5 8 7 3 2 1 9 4 10 6

3 7 6 5 9 8 10 2 4 1

8 5 7 1 2 9 10 6 3 4

1 4 5 8 7 10 3 6 9 2

5 3 6 10 9 7 1 4 8 2

Comment: now if you look horizontally, they're unique, but vertically they are repeating

**i want it unique in both ways, no matter which row or column you choose**

this is just my version of the algorithm, if anyone knows of a pre-existing one, please please let me know

thanks much,
-PS

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > ASP 2 dim array not working perfectly


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway