-
Mar 9th, 2015, 03:52 AM
#1
Thread Starter
New Member
How to solve as quick as possible
I have struggeled with this for a long but here it is:
there are only 16 teams and 4 groups of 4
i had 4 listboxes and tried it with a random
but there may only 4 teams in a group( so in a listbox)
how can i do this?
-
Mar 9th, 2015, 05:23 AM
#2
Re: How to solve as quick as possible
You will need to be much clearer about what you are asking. What you posted doesn't really give anyone enough information to try and help. Explain what you are trying to acheive in small steps. Perhap post what you have done so far.
Please remember next time...elections matter!
-
Mar 9th, 2015, 05:33 AM
#3
Re: How to solve as quick as possible
Are you trying to randomly assign 16 teams to 4 groups of 4 teams and then display the groups in 4 listboxes?
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
-
Mar 12th, 2015, 01:04 PM
#4
Thread Starter
New Member
Re: How to solve as quick as possible
exactly funnydexter,
16 teams, there are 4 groups, and in each group there must be 4 teams. I want those in 4 listboxes, compeletly random
-
Mar 12th, 2015, 01:19 PM
#5
Re: How to solve as quick as possible
Depending on what teams are, take a look at this example:
Code:
Imports System
Imports System.Linq
Public Module Module1
'Declare a new random
Private r As New Random()
Public Sub Main()
'Create a group of numbers from 1 - 16
Dim exclusive_numbers() As Integer = Enumerable.Range(1, 16).OrderBy(Function(n) r.Next(1, 17)).ToArray
Dim group1(3), group2(3), group3(3), group4(3) As Integer
'Set the first four exclusive numbers to group1, second four exclusive numbers to group2, etc...
For x As Integer = 1 To 4
group1(x - 1) = exclusive_numbers(x - 1)
group2(x - 1) = exclusive_numbers(x + 4 - 1)
group3(x - 1) = exclusive_numbers(x + 8 - 1)
group4(x - 1) = exclusive_numbers(x + 12 - 1)
Next
Console.WriteLine("Group1")
For Each item As Integer In group1
Console.WriteLine(" Team: " & item.ToString())
Next
Console.WriteLine("Group2")
For Each item As Integer In group2
Console.WriteLine(" Team: " & item.ToString())
Next
Console.WriteLine("Group3")
For Each item As Integer In group3
Console.WriteLine(" Team: " & item.ToString())
Next
Console.WriteLine("Group4")
For Each item As Integer In group4
Console.WriteLine(" Team: " & item.ToString())
Next
End Sub
End Module
Last edited by dday9; Mar 12th, 2015 at 02:19 PM.
-
Mar 12th, 2015, 05:57 PM
#6
Re: How to solve as quick as possible
here's an alternative:
Code:
Public Class Form1
Dim r As New Random
Dim teams() As String = Enumerable.Range(1, 16).OrderBy(Function(x) r.NextDouble).Select(Function(x) "Team " & x.ToString).ToArray
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.Items.AddRange(teams.Take(4).ToArray)
ListBox2.Items.AddRange(teams.Skip(4).Take(4).ToArray)
ListBox3.Items.AddRange(teams.Skip(8).Take(4).ToArray)
ListBox4.Items.AddRange(teams.Skip(12).Take(4).ToArray)
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 16th, 2015, 02:55 AM
#7
Thread Starter
New Member
Re: How to solve as quick as possible
Thank you, i'll try it out
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|