Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Combinations of Points

Name: Anonymous 2012-05-14 13:56

I have a set of 8 unique points, and I need to cycle through all possible routes between those points, [preferably] using recursion.

How do I go about a problem like this?

Name: Anonymous 2012-05-14 14:11

You write a recursive function that cycles through all possible routes between your points.

Name: Anonymous 2012-05-14 14:13

>>2

Thanks. 0/10.

I'm not particularly well versed in recursion, so it's all a bit strange to me... where do I start?

Name: Anonymous 2012-05-14 14:17

Write a function like funct(point) and have it do a for loop for all of the points that are connected to that one point and each one calls the same funct(their point). Then the starting point just calls funct(point) and it loops through all of the points just like that

Name: Anonymous 2012-05-14 14:30

>>3
I'm not particularly well versed in recursion, so it's all a bit strange to me... where do I start?
Start with Google you stupid piece of shit, /prog/ isn't for CS101 questions.

Name: Anonymous 2012-05-14 14:32

>>4

So it'd be something like this?


    private void CyclePoints(Point pt)
    {
        for (int i = 0; i < 8; i++)
        {
            CyclePoints(pt + 1);
        }
    }

Name: Anonymous 2012-05-14 14:34

>>5

lol recursion isn't exactly for newbie programmers you sped

Name: Anonymous 2012-05-14 14:38

>>7
Yes it is you stupid piece of shit.

Name: Anonymous 2012-05-14 14:39

>>8

says the guy who probably doesn't understand it him/her/itself

Name: Anonymous 2012-05-14 14:40

>>9
Is this your idea of a troll? It's a piss poor attempt, you're so fucking unintelligent you probably think you're clever or something.

Name: Anonymous 2012-05-14 14:42

>>10

man, sure is mad in here

I guess the realization that you're no better of a programmer than any other idiot on this board must sting a little.

Name: OP !neAe92srE6 2012-05-14 14:43

>>11

OP here, all I wanted was a little help, not a debate about who's dumber....

Name: Anonymous 2012-05-14 14:53

>>8
>>10
ignore this guy, he's an illiterate russian, that has never contributed anything, he's pretty much the cancer of /prog/

Name: Anonymous 2012-05-14 14:57

>>13
I'm not a Russian you fucking moron, I just find it hilarious that you guys think recursion is a difficult concept, it's like you didn't even pass CS 101.

Name: Anonymous 2012-05-14 15:01

>>14

If you're so smart and such an expert programmer, why not just offer a bit of help? It's because you have no fucking idea what you're talking about.

Name: Anonymous 2012-05-14 15:01

hey OP, your recursive functions' nice and all but you need a real stoppage condition, something like


private void CyclePoints(Point pt)
{
    pt.HasAlreadyBeenCycled = true;
    for (int i = 0; i < 8; i++)
    if(pt[i].HasAlreadyBeenCycled == false)
        CyclePoints(pt);
}


also what language is that? that type Point looks fucked

Name: Anonymous 2012-05-14 15:02

>>14
implying that i really care what you are,lol, i'm just pointing out the pattern to trace the cancer of prog, shithead
now bugger off

Name: Anonymous 2012-05-14 15:03

>>15
don't feed the cancer new guy!!

Name: Anonymous 2012-05-14 15:03

>>16

I'm doing it in Java, I was just using "Point" as filler. I'm using the JFreeChart library, so each point is an "XYSeries" with an X and Y coord.

Name: Anonymous 2012-05-14 15:06

>>16

Thanks.

I don't really have to store more than 1 extra set, because it's basically just checking to see if the total distance between the points is lower than the previous total distance, and if it is it updates it on the window.

Name: Anonymous 2012-05-15 2:48

here ya go op!


#include <stdio.h>

void main() {
  int i1;
  for(i1 = 0; i1 < 8; i1++)
    {
      int i2;
      for(i2 = 0; i2 < 8; i2++)
        {
          if(i2 != i1)
            {
              int i3;
              for(i3 = 0; i3 < 8; i3++)
                {
                  if(i3 != i1 && i3 != i2)
                    {
                      int i4;
                      for(i4 = 0; i4 < 8; i4++)
                        {
                          if(i4 != i1 && i4 != i2 && i4 != i3)
                            {
                              int i5;
                              for(i5 = 0; i5 < 8; i5++)
                                {
                                  if(i5 != i1 && i5 != i2 && i5 != i3 && i5 != i4)
                                    {
                                      int i6;
                                      for(i6 = 0; i6 < 8; i6++)
                                        {
                                          if(i6 != i1 && i6 != i2 && i6 != i3 && i6 != i4 && i6 != i5)
                                            {
                                              int i7;
                                              for(i7 = 0; i7 < 8; i7++)
                                                {
                                                  if(i7 != i1 && i7 != i2 && i7 != i3 && i7 != i4 && i7 != i5 && i7 != i6)
                                                    {
                                                      int i8;
                                                      for(i8 = 0; i8 < 8; i8++)
                                                        {
                                                          if(i8 != i1 && i8 != i2 && i8 != i3 && i8 != i4 && i8 != i5 && i8 != i6 && i8 != i7)
                                                            {
                                                              printf("(%d, %d, %d, %d, %d, %d, %d, %d)\n", i1, i2, i3, i4, i5, i6, i7, i8);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Name: Anonymous 2012-05-15 4:01

>>7,9,11,12,15,17,18
Same person and we have been trolled constantly.

Name: Anonymous 2012-05-15 5:38

>>21
[quote]void main() {[/quote]

Newb_t *lol_what_a_noob = posts[20].author;

Name: Anonymous 2012-05-15 6:42

>>22
let me guess, you've been here less than 2 days

Name: Anonymous 2012-05-15 6:44

>>21
VIP QUALITY

Name: Anonymous 2012-05-15 9:05

>>24
Let me guess, you've seen Cher piss pan more lays.

Name: bampu pantsu 2012-05-29 4:57

bampu pantsu

Don't change these.
Name: Email:
Entire Thread Thread List