Thread: Latin square

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    151

    Post Latin square

    Can you give me a logic of how I could print a latin square using recursion for any number of 'n'.

    Example for Latin square for 3x3

    1 2 3
    2 3 1
    3 1 2

    Please adivse soon

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Have you tried printing all permutations of an array length n?

    It might help you to find out what permutation means, and after that, implement it as your solution.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    151

    Post Re:

    I'm not sure how to perform permutation .
    Could you give me a heads up
    Thanks.

  4. #4
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Permutation via Mathworld. Might be of some use to you.

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    151

    Post

    Im not sure of what you are saying.

    I need to know the method to do Latin squares with 'recursions'. I really hate doing recursions, even though it makes tasks faster.

    Please advise.

  6. #6
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by Ron
    Im not sure of what you are saying.

    I need to know the method to do Latin squares with 'recursions'. I really hate doing recursions, even though it makes tasks faster.

    Please do my work for me.
    You already know what a Latin square is. If you read the source kermit gave you, you'd know what permutation is. Permutation is easily made recursive. What is stopping you from opening up your compiler and trying to get these ideas to work in programming?
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    static void swap(int *a, int *b) {
    /* the code */
    }
    
    static void latin_square(int *array, size_t place) {
    /* the code */
    }
    
    int main(int argc, char *argv[]) {
    ...

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    151
    Kool, I got it.
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tic Tac Toe Comp Move help
    By swgh in forum C++ Programming
    Replies: 5
    Last Post: 09-24-2008, 11:05 AM
  2. Loop seg error
    By Zishaan in forum Game Programming
    Replies: 2
    Last Post: 03-28-2007, 01:27 PM
  3. Forced moves trouble!!
    By Zishaan in forum Game Programming
    Replies: 0
    Last Post: 03-27-2007, 06:57 PM
  4. Help with my draughts game
    By Zishaan in forum C++ Programming
    Replies: 9
    Last Post: 03-24-2007, 07:33 AM
  5. C++ Checkers Game
    By SnS CEO in forum C++ Programming
    Replies: 9
    Last Post: 09-07-2005, 01:21 AM