Wednesday, June 24

Sudoku programming: Adding logic into the already-logically-perfect program

As I already have a backtracking program that can perfectly solve any solvable sudoku, I am ready to add logic reasoning into it, after the board is loaded, before the backtracking trysudoku() function is called. Yes, as the last resort, the trysudoku() will be in action if the sudoku is not completely solved after the logic reasoning part is deployed.

The new function is called preset(). Apparently when I was writing this part, I only thought of it as a preprocess before running the main course trysudoku(). Anyway, in the second commit of the project, you can see this new present() function has these logic reasoning parts:

Part 1, walk though all empty cells to determine whether only one possible number suitable (not conflict with other elements). If there is only one possible number, then set this number. 

        count = 0
	for i in range(9):
        for j in range(9):
            if board[i][j] != 0:
                continue
            onlyonefit = false
            fitnum = 0
            for trynum in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
                if not conflict(board, i, j, trynum):
                    if onlyonefit == false:
                        onlyonefit = true
                        fitnum = trynum
                    else:
                        onlyonefit = false
                        break   #jump out of trynum
            if onlyonefit == true:
                board[i][j] = fitnum
		count += 1


Yes this simple logic works for some sudoku games.  I should make this part as a function and call it repeatedly until there is no cell being set (count == 0). 

Part 2, for each row, loop thought number [1..9]. If the number already exists in this row, forget it; otherwise, count how many possible cells this number is possible to be set in. If there is only one cell this number can set in (in this row), then the number has to be set in this cell.


    for i in range(9):
        for trynum in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
            possiblesitenum = 0
            possiblesite = 0
            Found = False
            for j in range(9):
                if type(board[i][j]) is int:
                    if board[i][j] == trynum:
                        Found = True
                        break   #found the number.
                else:   #is a set
                    if trynum in board[i][j]:
                        possiblesitenum += 1
                        possiblesite = j
            if Found == False and possiblesitenum == 1:
                logging.info("This num {} can only be in one site {} of this column {}".format(trynum, possiblesite, i))
                board[i][possiblesite] = trynum
                count += 1

After checking each row, do the same checking to each column, and each block.

Again, this is also simple logic: Each [1...9] number must show up in a row once, and only once. If there is only one cell available for a number for one row/column/block, then the number must be in this cell.

Aha, after reading the program again, I found I did call the preset() function (including the Part 1 and Part 2) repeatedly until there is no cell being set (count == 0). 

Done with this logic, I am able to commit this code, and get back to paper sudoku to learn more logic. To be continue.

Labels: ,

Grand National Betting Locations | Mapyro
Find the 포천 출장샵 best Grand 충청남도 출장안마 National Betting locations in the United Kingdom. 김제 출장샵 Great location for betting & 논산 출장안마 gambling in our online guide. Great What is Grand National Betting?How often can I bet on 동해 출장안마 the Grand National?
 

Tuesday, October 10

Random Number Generator

A computer can not create random number, because everything is under control--except the Blue Screen of Death.

So, the "random number" in the computer actually is "pseudo random number". It is generated following some function. If you know the function and some other conditions, you can actually predict what will be the next "random" number. A simple function is:
xn+1 = (xn)2 Mod M
where M is a large number. For example, if we know M equals to 1,000,000, and the last number generated is 8372, we can calculate and know the next "random" number will be 90384, and the one next to it will be 267456. Pretty simple, isn't it?

Another question is: Each time you get "8372", the next number must be 90384. We can know the whole sequence of random number. If this random number generator is applied in a game, you can predict computer's next step when the last step is familiar. The game is not fun at all?!

So the number M must be changed every time. The next number after "8372" will be something else. We give an initial "seed", and the sequence will be different, if the initial seed is different.

The standard method to initialize a random number generator is C language is:
srand ( time(NULL) );
when the time() function creates a long number which is the colapsed seconds from midnight of Jan, 1, 1970. This number increases every second, so you can never get the same random number sequence.

Some new programmers forget to initial seed before using rand() function, and the function creates the same sequence of numbers. That is funny. XJ takes advantage of this feature, use the same seed to create the same sequence of random numbers, so that he can trace his code again and again during debuging.

One parameter to justify if a function is a good random number generator is the distribution of generated numbers. The created number should be randomized enough. If you are creating numbers between 1 and 1000, then the chance that one number is between 100 and 200 should be the same as the chance that is is between 500 and 600.

One online gambling website publiced its source code to convince its players that the game was fair, there was no trick in this website. Three yeas ago an MIT PHD student found a bug in the random number generator. After he got several cards, he could guess what the "seed" was, then the next "random" number and the next card would not be a secret to him. The more cards he got, the more accurate his guess would be. He could have won big money using his knowledge. Instead, he published his research :D That is how a real researcher works.

So if an intruder knows the algorithm, the seed, and historic number, he can easily calculate the whole sequence of the number and predict the next one. That's why it is always a "pseudo random number". It's hard to hide the algorithm, because sometimes an intruder can get your source code. The intruder can be an insider, or the programmer who creates this software. So make sure you hide the seed perfectly. Some algorithms can create random numbers in good distribution, but people can guess the seed from historic numbers. This kind of algorithms can't be used in security area then.

Labels:

I intentionally create the same random sequence over and over again to make sure I get the same "random" sample so that my results will be the same. You don't want to revise your table again and again whenever you rerun the program. This is also a good practice to generate reproducible analysis.

To generate a good sample, there is a simple but excellent algorithm called KISS--a double random generator.
 
I've never though of using the random numbers in this way. That's creative. Using the same seed can guarantee to get the same sequence of number.

How can I find this "KISS" generator? This name is so normal, and I got millions of pages from Google.
 
google George Marsaglia and KISS random number generator
 
--a computer can not create random numberS.
--the random number in the(A) computer actually is (A) pseudo random number.
--it is generated (BY) following some function. (not it following, so you should add 'by')
--we can know the whole sequence of random numberS.
--Jan. 1st, 1970
--publice?
--historic numberS
--
 

Friday, October 7

Technology of Keyboard Sniffer

Suppose you sit close to me, and you can hear my keyboard stroke. Can you tell what I am typing from the sound of keyboard stroke?

"That is IMPOSSIBLE!", you say.

Assume we are using MSN Messenger now, although we are sitting close, we don't want to break the quiet. So you ask me a question from the MSN Messenger:
"Is today Thanksgiving?"

Then you hear I hit the keyboard 3 times follow by a big stroke, before the message actually send to your computer (because of the God-damned network delay, maybe), you know I am typing:
"yes" and Enter.

or
"yep" and Enter.

If you hear I hit the keyboard only twice and Enter, then it must be
"no" and Enter

At the beginning you said it is IMPOSSIBLE to tell from the sound of keyborad stroke, but now you are doing great!

Combined with the context and a dictionary and the word pattern, Keyboard sound recognition is possible. Sept 18, CNN reported Computer eavesdropping yields 96 percent accuracy rate, I can imagine the technology behind it.

First of all, the sound of keyboard stroke for different key are not exactly the same. When people hit the "Enter" key, usually people hit it hard, so the sound is different from others. Also, the "Space" is very different from others too.
People use different strength in different fingers: index finger, middle finger, ring finger, little finger. Also, left hand and right hand have different strength. It is possible for a computer using a good algorithm to tell the difference between them because the volumn will be different. According to CNN's report, the computer had an accuracy of about 60 percent for characters and 20 percent for words.

Second, The pattern of words can help to identify the typing characters. "After spelling and grammar checks were deployed, the accuracy for individual letters jumped to 70 percent and words to 50 percent."

To Be Continued...

Labels: ,

Yush:
我看了你的blog,挑点儿刺:
1. 文章开始举的msn的例子不合适。
"Is today Thanksgiving?"
"yes"/"no"
问句并不是已知,也同样是“猜”出来的。

2. 漏了最终结果
In the end, it could accurately detect 96 percent of characters and 88 percent of words.

3. 击键声音的不同,原因还可能是:各键在键盘上的位置不同,因此机械特性不同,声音频率上就有区别。

4. 由于各键的空间位置不同,击键声音及附近物体的回声传到话筒的传输路径不同,话筒接收到的“直达”声音和回声的关系也可以作为一个重要特征。

这项研究所采用的技术应该跟语音识别相同,也是hidden markov model。IBM的先期研究对应于“特定人语音识别”,Berkeley的则对应于“非特定人语音识别”。最终达到的精确度有点儿令人吃惊。
采用的技术肯定不是“简单的字典匹配”。

Ben's Reply:
我想的也差不多
我还没有写到最终结果,因为写到现在那个地方,就应该插入“恢复法庭文档”的例子,但是我没找到它,所以就停下来了。

HMM呢还是NN? 我觉得这个技术突兀的地方,并不在于这一点,所以在我的blog中只用一句话就带过去了:
It is possible for a computer using a good algorithm to tell the difference
我觉得,
1,居然每个键的声音还不一样,这是以前想不到的(手指力量、机械特性)
2,根据声音还分不出来的时候,用词典甚至语法来补充。After spelling and grammar checks were deployed, the accuracy for individual letters jumped
当然不是简单的字典匹配,而是把原本看来毫不相关的字典匹配引入到这个项目中,以及引入到“恢复法庭文本”之中,令我豁然开朗。至于HMM和NN,本来就应该是在这一行(pattern recognition)的,所以没有什么奇怪。

第一个问题,问句并不是“听”出来的,只有答复是听出来的。我只是先举个例子,表示在特定上下文环境中,你真的能听出击键的内容。
 

Monday, June 6

Datamining Workshop

McMaster CampusI went to a Datamining Workshop in McMaster University last week. SVM (Support Vector Machines) clustering and Bioinformatics are the two hot topics in this conference. Although their talks are full of formulas, too mathematical for me, some talks did make me think deeper.

My talk is about Constraint Satisfaction Problem. You can see no formula in my slides :)

Labels: ,

Thursday, April 7

Result of ACM Collegiate Programming Contest World Finals

ACM

The 29th ACM International Collegiate Programming Contest World Finals, hosted by China's Shanghai Jiao Tong University, are now over and the results are in. Congratulations to the top 4 teams who will be walking away with gold medals. They are Shanghai Jiao Tong University, Moscow State University, St. Petersburg Institute of Optics and Mechanics, and Canada's University of Waterloo (coming in at 1, 2, 3, 4 respectively. The top 4 get gold medals). Regional champions are: University of Waterloo, Canada (North America); Moscow State University, Russia (Europe); University of Cape Town, South Africa, (Africa and the Middle East); Instituto Tecnologico de Aeronautica, Brazil (Latin America); Shanghai Jiaotong University, China (Asia); and University of New South Wales, Australia (South Pacific).

----
The team from Waterloo is the winner in our Regional Contest (http://acm.ashland.edu/). Congratulations!

You can visit an old blog for some more info about ACM Contest.

Labels: ,

Thursday, January 20

Paper Analyzer

Paper Analyzer: Use database to organize the collected paper, and create Cross-Link Reference.

Download: paper.zip. (paper.exe and 510reference.mdb) (Mirror Site)

System Requirement: MS Access, MS Visual Basic 6.

I am considering to make it open-source.

Labels: ,

Monday, January 10

Algorithms for CSP

Constraint Satisfaction Problem (约束满足问题) is known as an NP-complete problem. We can’t find a polynomial time algorithm until we can prove P=NP, but we’ve developed some algorithm to accelerate the process to find the solution of CSP.


algorithm

Algorithm 1: BackTracking

BackTracking is the basic algorithm to solve CSP. In every step, find a valid value to assign to current variable. If a valid value is found, assign it to current variable and go to next step. If there’s no any valid value, back-track to the last variable to assign another value, expect another value of the last variable can lead to success of finding valid value for current variable. A valid value for current variable is a value that is not conflict with any assigned variable.

For example, in the Chart 1, Variable C can’t find valid value, then we back-track to Variable B to change the value, then check Variable C again.

BackTracking is a Depth-First Search algorithm in search-space. Time complexity: O(bd), when b is the average tightness of constraints, which is the branching factor of the searching tree, and d is the number of variables, the depth of the searching tree.

Algorithm 2: Forward Check

Forward Check sign an invalid value in the search space for future variables when current variable is assigned a valid value. If there’s no any valid value for current variable, back-track to the last variable to assign another value. A valid value for the current variable is a value that is not signed invalid from the assigned variables.

For example, in the Chart 1, Values of Variable C is signed invalid and Values of variable D is signed invalid too because of the assignment of A and B, then we back-track to Variable B to change the value, change the related value of C and D again, then check Variable C again.

Forward Check has the same time complexity as BackTracking, and it’s slower than Backtracking. Because Forward Check exam the same nodes as BackTracking, but waste time to assign future nodes that may never been used. For example, because all the value of Variable C is invalid, it doesn’t matter if values of Variable D are valid or not, but the values are already checked and signed when assign values for Variable A and B.

Algorithm 3: Back Jump

Forward Check is slower than BackTracking, but the idea is good. Actually, if we find all the values of Variable C are invalid because they are conflict with the value of Variable A, then we don’t need to change the value of B to check C again. We can directly jump to another value of Variable A, skip other values of B (under A1 value). After we assigned another valid value for A, we check B1 again. This is the Back Jump algorithm.

Back Jump skipped some nodes, so theoretically it’s faster than BackTracking and Forward Check.

Algorithm 4: Dynamic Backtracking

Dynamic Backtracking’s idea is: When we back jump from C to A, if variable B is not conflict with A, then it’s unnecessary to change B’s value after A is re-assigned. In color-mapping problem, assume we assigned color of E1, E2 cities in east, then assigned color of W1, W2, W3 cities in west and return to assign color for E3, E4, E5 cities in east. When working in east cities E3, E4, E5, we found we have to change color of E2, using Back Jump we will have to change the color of the western cities too; But deploying Dynamic Backtracking algorithm, we can leave W1, W2, W3 alone, since they’re not conflict with any of the east city.

This algorithm is faster than above algorithms, especially for CSPs have many variables.




Continue Reading...

Labels:

Friday, January 7

A programming problem.

A program:


     ...

again:n=a();
if (n>0) {
n=b;
goto again;
}
...


You know, goto is not a good style in programming. How to get rid of "goto" in this code?
try:
// wrong program.

do{
n=a();
}while(n>0);


Where is "n=b"?

Need Help!


Damon gave a neat solution:

n=a();
while(n>0){
n=b;
n=a();
}
It's very beautiful.

Now my question changed to:
...
again:n=a();
if (n>0) {
n=b;
goto again;
}
else{
n=c();
}
...
???

Labels:

again:n=a();
if (n>0) {
n=b;
goto again;
}
else{
n=c();
}

我不太看得懂这段程序是什么意思,就我看来,直接改成这样:

n=c();

因为当a()返回值总大于0时,这是一个死循环。只有在a()返回值小于等于0时,n=c()。

其实前面的程序就有问题:

n=a();
while(n>0){
n=b;
n=a();
}

这一段程序执行完毕之后,n无论如何不可能为b,看不出有何意义。
 
Actually, "n=a()", "n=b", "n=c()" only mean "Command 1", "Command 2", "Command 3" in the post. I'm thinking of the 流程 of the program, not the detail command.

The last code can be changed as:

n=a();
while(n>0){
n=b;
n=a();
}
n=c();
----------------------
As I said, it means:
...
Command 1;
while (n>0){
Command 2;
Command 1;
}
Command 3;
...
 

Tuesday, December 7

Teach Yourself Programming in Ten Years

Peter Norvig is one of the authors of Artificial Intelligence: A Modern Approach, a popular AI book in Computer Science. In Teach Yourself Programming in Ten Years, he told us how to study programming:

  1. Get interested in programming, and do some because it is fun. This is the most important thing in programming. You learn programming because it's fun and you love it.
  2. Talk to other programmers; read other programs. Learn from others.
  3. Program. Learn from practice.
  4. If you want, put in four years at a college (or more at a graduate school). Norvig said a deploma or a degree would help you to gain more experience. I say the 4 years study can help you to understand 7, 8.
  5. Work on projects with other programmers. Learn from others.
  6. Work on projects after other programmers. Learn and create from others.
  7. Learn at least a half dozen programming languages. Understand language.
  8. Remember that there is a "computer" in "computer science". Understand computer.
  9. Get involved in a language standardization effort. Understand the creation of language.
  10. Have the good sense to get off the language standardization effort as quickly as possible. But you don't have to follow all the standards.

Those are good advice, and I've practise most of them :) and I've been programming more than 10 years. So, it's time for me to become a good programmer now. But first of all, let me finish reading the Artificial Intelligence: A Modern Approach. I borrowed it in September, but I havn't finished reading Chapter 1. :(


Labels: ,

Friday, November 19

My answer for the Prime Ring


// Problem A: Prime Ring

#include 〈 stdio.h>
#include 〈 math.h>
int ring[16];
int m;

bool NotInRing(int iPos, int iNum)
{
int i;
for(i=0; i〈 iPos; i++){
if (iNum == ring[i]){
return false;
}
}
return true;
}

int GetNumber(int iPos, int iNumber)
{
int i;
for(i=iNumber+1; i〈 =m; i++){
if (NotInRing(iPos, i))
return i;
}
return 0;


}

bool IsPrime(int iNum)
{
int i;
for (i=2; i〈 =sqrt((double)iNum); i++) //sqr/sqrt
{
if (iNum == ((int)iNum/i)*i) // (inum%i == 0)
return false;
}
return true;
}


bool FindNumber(int iPos)
{
int iNumberTwo, iTotal;
if(iPos〈 1)
return false;

if (iPos == m)
{
iTotal = ring[iPos-1] + ring[0];
if (IsPrime(iTotal))
{
for(int j=0; j〈 m; j++){
printf("%d ", ring[j]);
}
printf("\n");
return true;
}
else
return false;
}


iNumberTwo = GetNumber(iPos, 0);
while(iNumberTwo != 0){
ring[iPos] = iNumberTwo;
iTotal = ring[iPos]+ring[iPos-1];
if (IsPrime(iTotal)){

// printf("Now in %d, try %d, and %d is prime\n", iPos, ring[iPos], iTotal);
// for(int i=0; i〈 =iPos; i++)
// printf("%d ", ring[i]);
// printf("\n\n");

if (FindNumber(iPos+1) == true){
// iPos --;
}
}
iNumberTwo = GetNumber(iPos, iNumberTwo);
}
return false;
}

main()
{
int i, j, k;
// int ring[16];
ring[0] = 1;

while (scanf("%d", &m)){
if (m == 0)
break;

// printf("Get %d\n", m);
if (FindNumber(1) == true)
{
for(j=0; j〈 m; j++){
printf("%d ", ring[j]);
}
printf("\n");
}
}// end while.
}



Labels: ,

Tuesday, November 16

About ACM Competition.

This year my team ranked 38 out of 131 in the 2004 ACM East Central North AmericaRegional Programming Contest. This competition is funded by IBM, and the winner will go to the 2005 ACM Final in Shanghai. There're 72 colleges and universities throughout western Pennsylvania, Ohio, Michigan, eastern Ontario, and Indiana (excluding the Greater Chicago Metropolitan Area) in this competition.

You can read the problem set I met in this competition. Usually the problems are easy to understand, but hard to solve. For example, Prime Ring is a classic ACM problem:




Prime Ring Problem

A ring is composed of n (even number) circles as shown in diagram. Put natural numbers 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.



Note: the number of first circle should always be 1.

Input
n (1 -- 16)

Output
The output format is shown as sample below. Each row represents a series of circle numbers in the ring beginning from 1 clockwisely and anticlockwisely. The order of numbers must satisfy the above requirements.


You are to write a program that completes above process.

Sample Input

6
8

Sample Output

Case 1:
1 4 3 2 5 6
1 6 5 2 3 4

Case 2:
1 2 3 8 5 6 7 4
1 2 5 8 3 4 7 6
1 4 7 6 5 8 3 2
1 6 7 4 3 8 5 2



There're 8 problems in the competition, and you have 5 hours to work on them. You can use C, C++ or JAVA to solve the problems. Usually the source code of the answer is NO longer than 2 pages. You can visit a PROBLEM SET ARCHIVE at http://online-judge.uva.es/problemset/ and you can even submit your answer, and get feedback from the judges.

Every year Dr. Kobti organizes 2 seminars, in March and in September. In October, there'll be a Local Contest, and the first 2 teams can go to Oakvill for the Region Competition. If any of you are interested in the contest, you can find 2 friends and start working on it now.

You can read my answer for the Prime Ring.

Labels: ,

Thanks, Albert. When will you build your blog?
 

Tuesday, November 9

About IBM Linux Scholars Challenge

keso: 你联结中有一个数字部落的"IBM linux奖赛", 里面提:
IBM举办了一个Linux知识大奖赛,参加者要解决IBM在利用Linux时遇到的29个挑战。

我懒得在她那里注册. 这是yahoo新闻的翻译:consists of a 1,200-word essay that can describe the solution to one of 29 Linux-related challenges IBM poses as part of the competition. "Can"被翻译成"要".
但是yahoo的下一句是:aren't limited to these challenges and can suggest and solve their own problems.
而且ibm的官方网站上也只是把这29个题目叫做"examples of challenges."
所以数字部落的说法不正确.

我是关注了这个比赛一段时间,差点就报名参加了;所以看到数字部落的说法很惊讶,就想澄清一下.

Labels: ,

对于这个状态特别显着的混合与真正的暴露。 我最适合地制作了适当的情况。 这不是对那些曝光的观点的考虑。 相反,理解表明这种方法令人惊叹。
 

Tuesday, November 2

Quote: P=NP? Knuth said:

(1995)

P=NP is the most famous unsolved problem in computer science, analogous to Fermat's Last Theorem, although the P=NP problem has only been around for about 30 years, 25 maybe. In the context of combinatorial algorithms, it says: Are we going to be able to solve problems that would require going through 2^n cases? Can we actually do those in n^10, or something like that, if we knew the best method? if P=NP, the answer would be "yes", with some polynomial: we could reduce all these exponential problems to polynomial problems. If not, the answer is "no", we'll never to able to reduce them.

I have a feeling that someone might resolve the problem in the worst possible way, which is that following. Somebody will prove that P is equal to NP because there are only finitely many obstructions to it not being equal to NP. [laughter] The result would be that there is some polynomial such that we could solve all NP problems in polynomial time. However, we won't know what the polynomial is; we'll just know that it exists. So maybe the complexity will be n to the trillionth or something like that --- but it'll be a polynomial. In such a scenario we'll never be able to figure it out because it would probably take too long to find out what the polynomial is. But it might exist. Which means that the whole question P=NP was the wrong question![laughter] It might go that way. You see, even if you have a method that takes 2^n steps and you compare it to a method that takes n^100, then at least you can use the 2^n one for n up to 20 or 30. But the n^100 you can't even do for n=2. So the degree of that polynomial is very important. There are so many algorithms out there, the task of showing that no polynomial algorithms exist is going to be very hard. Still, I really thought that Fermat's Theorem was a similar kind of thing, where it was more important to have the problem than to solve it. Therefore, my real feeling about Wiles's Theorem is that he did a marvelous wonderful piece of work, but I wish he'd solved something else! [laughter]

A lot of people think that as soon as a problem is shown to be in this class NP, they shouldn't work on it, because it means that there's probably no polynomial way to solve the problem. But before we studied NP, we had unsolvable problems --- problems for which there didn't exist any algorithms at all. No matter how long you worked, you could never solve the problem. To tell whether a given Turing machine ever stops: This problem is unsolvable by any algorithm, in general, no matter how long you give yourself. In the days before NP became famous, people would stop working on a problem as soon as it was proved to be unsolvable in general. But that was a bad strategy, because almost every problem we ever solve is a special case of some unsolvable problem.

Take calculus, for example --- the problem of taking a formula, a function of n, and saying: "Is the limit as n goes to infinity equal to zero or not?" That's an unsolvable problem. But its unsolvability doesn't imply that we shouldn't study calculus. I mean, limits of lots of useful functions do go to zero, and therefore people were able to develop calculus. But the general problem is unsolvable. I mean, you could define f of n --- it only takes a few lines to make a formula that is equal to zero if a given Turing machine is stopped at time n, and it's equal to 1 if the Turing machine is still going at time n. And so the limit is equal to zero if and only if that Turing machine stops. It's unsolvable.

A similar thing happens with NP. That is, we have lots of special cases of problems that are NP-hard that we can solve efficiently; just knowing that something is NP doesn't mean that it's a good idea to give up on it or to stop trying to get good heuristic methods for it.

Labels: ,

Thursday, October 21

Magic Cube (魔方)

Have you ever played Magic Cube (魔方) before? I do like it. Actually, I'm pretty good at it though. I can make 6 surface perfectly. No, no, I'm not telling you how to play Magic Cube in this blog.

14 years ago, when I was in highschool, I went to "Olymipc Information Competition" Local Contest, and the question is to build a Magic Cube, and I didn't have any idea how to do it, until yesterday.

Yesterday I was reading papers about backtracking in CSP problem, then a lightning hit me: This is exactly what I should have use in that contest, to build a Magic Cube! Make the initial state, then try every steps. Depth-First Iterative Deeping will get the optimal solution for this problem efficiently! (Of course the solution is exponential, that's why the question was marked: only 3 steps to the solution. I can still remember that after 14 years.)

I've learned much, but I didn't know how to use it. Now I'm on the right track.


Labels: ,

Saturday, October 16

ACM Competition, CSSA server

Today in the ACM local programming competition, I solved 3 problems. Because my team is in the 2nd position in the competiion, I will go to Oakview for Regional competiion on 5, Nov. Wish me good luck!

Leon's team is still the best in competition. They are really good at that. Congratulations!

Finally, CSSA's server is back. But it's weired that in one night, someone posted a message talking about WingLi again, and 7 follows and 500 clicks! I don't understand why so many people are staying at night. :)


Labels: