Patience źTurkish Handkerchief╗

Valery Ochkov (Russian text, Another articles)

The part of the Book źMathcad 8 Pro for Students and Engineers
CompuretPress Public House, 1999
Solving some problem we sometimes have difficulties. The problem can have two alternate solutions, and all ź
for╗ equal all źagainst╗. What do we have to do in this case? Do you have to go to business trip? Do you buy one more hard disk for computer? Our life sets us difficult problems!

Someone throws a coin, other thinks about man or woman and looks through the window and waits, who first will appear. But all these are not scientific methods. The coin can roll somewhere, and there is no one in he street except a cat for hours...

But there is method of decision-making that is verified by centuries. It is enough to play patience. If it coincide, the solution is made, otherwise it is not. We can find other reasons for its advantage and make a reality of it.

To make a decision such way sometimes very difficult, there is not always a pack of cards, and you can not play patience during working day. But you can do it on the screen of the display. In Windows, for example, there are plays-patiences; but we think out something new, but the main thing it will be more entertaining and instructive. We play the ancient patience ôTurkish Handkerchiefö in Mathcad. There are three reasons for it:

1.To know better the program, we have to try to solve some problem. The problem must be very unsuitable. One can say it is distortion, but see etude 3 of the Book.

2.In childhood every normal man broke toys for looking how they work. And we look how the park of cards is shuffled and played patience too.

3.By tradition to guess on cards and to play patience, it is allowed only at Christmastide[1]. Our patience is numeric puzzle and we can play it the year round.

Mathcad-document (see GIF-Picture and Mathcad WorkSheet) allows to play the patience źTurkish handkerchief╗ by next rules. From one shuffled pack of cards (52 cards) is put five lines by 10 cards in every line. Last two cards are put in six inexact line, in any place, for example, in first or second columns. We have to straighten the źhandkerchief╗, putting off from different columns for one step two lower cards ľ kings, queens, aces and etc.

For putting cards off, it is necessary to copy right part of the operator P = ... (it is the matrix) on free place, and to make the cursor to necessary text constant (to a card) and to click left button of the mouse and to press the button Delete. There is an empty square instead of a number.

From played patience we put off two twain. Then we can put off two eight, two kings or two ten (question- what do we put off from three pairs). After it new cards will open. If we can open all 52 cards, it means that I have to go to business trip and I have to buy a hard disk.

Compiling the program formed the matrix P (play patience) is useful for learning the base notions, for example, vector, matrix, of linear algebra. When we compiling the matrix P, the matrix Suit transposes (matrix with one line transforms to matrix with one column, that is a vector). Then with help of the function stack new non-shuffled pack of cards is formed, where one sorted out suit follows the other (vector Pack). In cycle with parameter (for...) with help of the cycle while[2] and the function rnd, shuffled pack of cards is formed, that is the vector Shuffled_Pack, that double cycle with two parameters (for... for...) in the end of the program is put by layers to the matrix Patience.

The program formed the matrix P, we can develop, make this program to reject not solved layout, for example, in one column there are three or four identical cards. There is more difficult not solved layout, two pairs of cards criss-cross cover each other. It will be useful for working in Mathcad with matrix operators and functions. But there is more difficult task for readers: to form the program that itself played patience or at the worst it informed that the patience could be solved by putting off any pair of open cards. More clever policy is choice of a card from three or four identical open cards.

Besides linear algebra our program affects other interesting parts of mathematics: probability theory, statistician (see function rnd, that generate pseudorandom numbers). Next question is interesting too: can we form a program calculating probability of convergence of some patience? It is considered that the patience źSolitaire╗, including to the standard Windows, is solved all time and it does not depend on initial layoutsů

Very often one can do everything perfect when one do it playing and with great pleasure, for example, walks, speaks, swims and etc. Author, for example, learned to count before school with help of pack of cards. Queen is three, king is four and so on. Now author tells to his students, that the main thing you get from study is pleasure and only after it knowledge. Man spends his life all for nothing if he does not get pleasure from his work, study. For example, if you cannot understand linear algebra, then you have to relax and try to get pleasure.

To begin to study vectors and matrices (data file) in course of information science one can meet with built-in functions and operators of a program. But one can play patience.

[1] During between Christmas and Epiphany the program was written by author (was sent for Mathcad 8) 11 January 1998. So everything is all right.

[2] Here it is better to apply the post checking cycle, but there is not this cycle in Mathcad.