Magician's issue of licensing and the problem of Latin phalanx

Source: Internet
Author: User

Magician Licensing Issues

Problem Description:

The magician used a deck of 13 black label, pre-lined them up and stacked together, face down. Said to the audience: "I do not look at cards, only a few can guess what each card is, I loudly count, you listen, do not believe?" Live demonstrations. "The magician put the top card number at 1, turn him over. It is a spade a, put the spades a on the table, the second number 1, 2, the first card placed under these cards, the second card turned over, just the Spades 2, also put it on the table in turn will be 13 cards all turned out, accurate.

Question: How is the start order of the cards arranged?

The idea is to use a circular list to solve the problem,

    1. Initializes a circular linked list with a length of 13, and the initialization value of each node is 0
    2. Count = 1~13 times, counting the number of cards to the corresponding count, for example, starting with head 1, then two times, head = Head.next.next, that is, the third is 2, and in the process of counting, the value of the node will not be counted.

Question of the Latin phalanx

The Latin phalanx is a nxn square in which there are n different elements, each of which has exactly n, and each element appears once in a row and column. The famous mathematician and physicist Euler used the Latin alphabet as a symbol of the elements of the Latin phalanx, and the Latin phalanx was thus named.

For example, a 3x3 Latin phalanx:

Ideas:
    1. First, the first row and the first column are set to 1~n, and then each row is populated by the Loop list method
    2. For example, the second line starts with 2, then the remaining padding is 3, 4, ... , n,1
    3. The third line starts with 3, then the remaining padding is 4, 5, ... , n,1,2, etc.

Magician's issue of licensing and the problem of Latin phalanx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.