In 3.6, there is a principle: The more general problem may be easier to solve. In order to solve a 23-case problem directly, writing a general n-case version and applying it to n = 23 is much easier.
Well, I might direct shoot the author. You want to prove 4 is a sum of two primes. A easier and more general version is
Every even integer greater than 2 can be expressed as a sum of two primes.
If you solve this general version problem, CONGRATULATIONS, then you solved Goldbach’s conjecture right?
Let’s solve the problems in 3.7
2. Find a1 to am in a easy way.
This remind me of optimization of some dynamic programming problem. The easiest version is Fibonacci series or sequence whatever…
F[n] = F[n-1] + F[n-2]
It is clear that we only need the last 2 numbers in the sequence. So, instead of storing the whole list, we are supposed to keep 2 variables, one is x, the other one is y.
y, x = x+y, y
This general version question is the same. We use k variables to store the value you need currently.
4. Date and week
I knew this equation or congruence or whatever since high school. I was solving a OI problem. It gave you a date, and you need to tell him what day in a week is that day. So I just used this congruence.
But I am not clear about this principle.
the months are numbered from 3 for March to 14 for February
So the 29th Feb for any leap year will be the last day for this year. And, you can take it as 0 day of next year. Quite brilliant right?
There are a lot of ways to calculate dates and days, look here
5. Find suffix.
I suggest built a Trie for all suffixes, of course, in a reverse order.
8. SSD — Seven Segment Display. [Are you from EEE? or are you a computer engineer?]
Look here.
Please join NTU! You ganna learn SSD for at least 3 years. LoL…
Email me when Programmers Don’t Read Books publishes stories
