Interesting titles in memory of scientists

Science is the most revolutionary force in the world.
– George Sarton

Canada Waterloo Mathematics Contests

https://www.cemc.uwaterloo.ca/contests/contests.html

Gauss Mathematics Contests

The Gauss Contests are an opportunity for students to have fun and to develop their mathematical problem solving ability.

Audience

All students in Grades 7 and 8 and interested students from lower grades.

Pascal, Cayley and Fermat Mathematics Contests

The Pascal, Cayley and Fermat Contests are an opportunity for students to have fun and to develop their mathematical problem solving ability.

Audience

  • Students in Grade 9 or below are eligible to write the Pascal Contest.
  • Students in Grade 10 or below are eligible to write the Cayley Contest.
  • Students in Grade 11 or below are eligible to write the Fermat Contest.

Fryer, Galois and Hypatia Mathematics Contests

The Fryer, Galois and Hypatia Math Contests are an opportunity for students to write a full-solution contest. They are fun way to develop mathematical problem solving skills through a written mathematical activity.

Audience

  • Students in Grade 9 or below are eligible to write the Fryer Contest.
  • Students in Grade 10 or below are eligible to write the Galois Contest.
  • Students in Grade 11 or below are eligible to write the Hypatia Contest.

Euclid Mathematics Contest

The Euclid Mathematics Contest is an opportunity for students to have fun and to develop their mathematical problem solving ability.

Audience

Students in their final year of secondary school or CÉGEP students and motivated students in lower grades.

FFmpeg Releases

FFmpeg is the leading multimedia framework originally developed by Fabrice Bellard.

https://www.ffmpeg.org/download.html#releases

  • FFmpeg 4.2.1 “Ada”
  • FFmpeg 4.1.4 “al-Khwarizmi”
  • FFmpeg 4.0.4 “Wu”
  • FFmpeg 3.4.6 “Cantor”
  • FFmpeg 3.3.9 “Hilbert”
  • FFmpeg 3.2.14 “Hypatia”
  • FFmpeg 2.8.15 “Feynman”
  • FFmpeg 3.1.11 “Laplace”
  • FFmpeg 3.0.12 “Einstein”
  • FFmpeg 2.7.7 “Nash”
  • FFmpeg 2.6.9 “Grothendieck”
  • FFmpeg 2.5.11 “Bohr”
  • FFmpeg 2.4.14 “Fresnel”
  • FFmpeg 2.3.6 “Mandelbrot”
  • FFmpeg 2.2.16 “Muybridge”
  • FFmpeg 2.1.8 “Fourier”
  • FFmpeg 2.0.7 “Nameless”
  • FFmpeg 1.2.12 “Magic”
  • FFmpeg 1.1.16 “Fire Flower”
  • FFmpeg 1.0.10 “Angel”
  • FFmpeg 0.11.5 “Happiness”
  • FFmpeg 0.10.16 “Freedom”
  • FFmpeg 0.9.4 “Harmony”
  • FFmpeg 0.8.15 “Love”
  • FFmpeg 0.7.17 “Peace”
  • FFmpeg 0.6.7 “Works with HTML5”
  • FFmpeg 0.5.15 “half-way to world domination A.K.A. the belligerent blue bike shed”

LeetCode - Algorithms - 54. Spiral Matrix

Problem

54. Spiral Matrix

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.

Java

solution by myself

Although it is slow, it is pass on Leetcode by myself after attempting six times.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Solution {
public List<Integer> spiralOrder(int[][] matrix) {
int m = matrix.length;
int n = m>0?matrix[0].length:0;
List<Integer> list = new ArrayList<Integer>();
for(int delta=0;delta<Math.ceil(Math.min(m, n)/2)+1;delta++) {
for(int i=delta;m>=2*delta+1 && i<n-delta;i++) {
list.add(new Integer(matrix[delta][i]));
}
for(int i=delta+1;n>=2*delta+1 && i<m-delta;i++) {
list.add(new Integer(matrix[i][n-delta-1]));
}
for(int i=n-delta-2;m>=2*delta+2 && i>=delta;i--) {
list.add(new Integer(matrix[m-delta-1][i]));
}
for(int i=m-delta-2;n>=2*delta+2 && i>delta;i--) {
list.add(new Integer(matrix[i][delta]));
}
}
return list;
}
}

Submission Detail

  • 22 / 22 test cases passed.
  • Runtime: 1 ms, faster than 6.37% of Java online submissions for Spiral Matrix.
  • Memory Usage: 34.4 MB, less than 100.00% of Java online submissions for Spiral Matrix.

better solution

盘点今年秋招那些“送命”的算法面试题 - 极客大学

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Solution {
public List<Integer> spiralOrder(int[][] matrix) {
List<Integer> result = new ArrayList<>();
int height = matrix.length, width = height == 0 ? 0 : matrix[0].length;
int size = height * width;

int[] dirX = { 0, 1, 0, -1 };
int[] dirY = { 1, 0, -1, 0 };

int x = 0, y = -1, dir = 0;
for (int step, total = 0; total < size; total += step) {
if (dir == 0 || dir == 2) {
step = width;
height--;
} else {
step = height;
width--;
}
for (int i = step; i > 0; i--) {
x += dirX[dir];
y += dirY[dir];
result.add(matrix[x][y]);
}
dir = ++dir % 4;
}
return result;
}
}

Submission Detail

  • 22 / 22 test cases passed.
  • Runtime: 0 ms, faster than 100.00% of Java online submissions for Spiral Matrix.
  • Memory Usage: 34.2 MB, less than 100.00% of Java online submissions for Spiral Matrix.

C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public class Solution {
public IList<int> SpiralOrder(int[][] matrix) {
IList<int> list = new List<int>();
int height = matrix.Length;
int width = height == 0 ? 0 : matrix[0].Length;
int size = height * width;

int[] dirX = { 0, 1, 0, -1 };
int[] dirY = { 1, 0, -1, 0 };

int x = 0, y = -1, dir = 0;
for (int step, total = 0; total < size; total += step)
{
if (dir == 0 || dir == 2)
{
step = width;
height--;
}
else
{
step = height;
width--;
}
for (int i = step; i > 0; i--)
{
x += dirX[dir];
y += dirY[dir];
list.Add(matrix[x][y]);
}
dir = ++dir % 4;
}

return list;
}
}

Submission Detail

  • 23 / 23 test cases passed.
  • Runtime: 176 ms, faster than 71.81% of C# online submissions for Spiral Matrix.
  • Memory Usage: 40.5 MB, less than 95.65% of C# online submissions for Spiral Matrix.

Why We Struggle Learning Languages - Gabriel Wyner - TEDxNewBedford - Transcript

So, there’s a myth when it comes to language. And that myth is that children are exceptionally good at learning languages and that we lose that gift when we grow up. We have good reason for believing in this myth.

Many of us have had this experience. We’ve picked a language in high school or college, studied hard for three, four, five years, and then we take a trip to France, and we meet a five-year-old French child, and she speaks way better French then we do. (Laughter) And it’s not fair. I mean, we have struggled so hard, and she has never worked a day in her life, and yet here she is correcting our grammar. And you’re right. It’s not fair. It’s not fair because you are comparing yourself to a child who has had 15,000 hours of French exposure, and you have had 100, maybe 200, maybe 50. It depends upon how much of your classes were actually spent in French instead of in English talking about French. When you make the fair comparison - you take a five-year-old child, transplant them to Spain, give them 500 hours of exposure there; adult gets a job in Spain, 500 hours of exposure - what you’ll find is that the adult beats the child every time. We are better at learning languages than children. We are smarter than them. We’ve learned how to learn. It’s one of the perks of growing up.

That’s not to say there are no advantages to being a kid; there are three. Between the ages of 6 months and 12 months, in that tiny window, children can hear sounds in new languages in a way that we lose. Significant advantage there. Advantage two, children are fearless. They will walk into any conversation, whether they know the words or not, where we will hold ourselves back; we’ll be afraid. Huge advantage. Yet neither of those two advantages outweighs our superior ability to learn. The third advantage of being a child is the advantage of time.

We don’t have 15,000 hours to spend learning French. And so, to succeed at this, we need something that works better than what children use. And to talk about what that might look like, I want to talk about some of my own experiences.

I began my language learning journey with Hebrew, in kindergarten and elementary school. I studied for seven years, and at the end of those seven years of study, I could read the Hebrew … alphabet. (Laughter) So I try it again. In junior high and high school, I was fortunate; I went to a high school that offered Russian with really good teachers, and so I took Russian for five and a half years. I studied hard; I did well on my tests; I did all of my homework; and at the end of those five and a half years, I could read the Russian alphabet. I retained, maybe, 40 words, and I came to the conclusion that this whole language thing was not for me. And then I made a poor decision. I was always a science nerd. I loved science and engineering; I wanted to be a nuclear engineer, focused on plasma physics so I could make fusion reactors. That was my thing as a kid. But I had this hobby, and that hobby was singing. I sang musical theater and opera. And as I was applying to engineering schools for college, I applied to one that had a music conservatory, and I thought, “Wouldn’t it be weird to study opera and mechanical engineering? Wouldn’t that be out there?” And so I did. One of the side effects of that is that I needed to take language courses. For that opera degree, I needed German, French, and Italian. And a French friend of mine came to me and said, “Hey, you know, you can get two semesters of credit in one summer at this school in Vermont.” And I thought, “That sounds great.” So I signed right up for this program. And the way this program works is that you sign a contract on the very first day. It says that if I speak one word that is not German, if I write anything, if I read anything, if I listen to a voicemail that’s not in German, I will get kicked out of the school with no refund. And I thought, “I guess that sounds like fun.” (Laughter) And so I went, and I signed that contract, and I realized that I did not actually speak any German, and so, I stopped talking. (Laughter) And someone came up to me, and he said, “Hallo, ich heiße Joshua. Wie heißt du?” And I said, “Eh?” (Laughter) And he said, “Hallo, ich heiße Joshua. Wie heißt du?” And I said, “Ich heiße Gabriel?” And I learned German that way. Seven weeks later, I could hold a solid conversation in the language, and I became addicted to the feeling of thinking in a completely new way. And so, I went back the following summer to reach fluency in German. In 2007, I moved to Vienna, Austria, to pursue a degree in opera and in song. In 2008, I went to Perugia, Italy, to study Italian. And in 2010, I cheated on a French test. And that’s where all of this comes from. You see, I wanted to go back to that school with the contracts in Vermont because, in a sort of stressful, masochistic way, it was actually kind of fun. And they had a Level 1 for people who weren’t familiar with French, which was appropriate for my level, but they also had Level 1.5 that was a little bit faster. And I thought, this was my third language. Italian is close to French. I can probably manage 1.5. So they sent me a placement test online, and I cheated on it as much as I possibly could. I figured me not knowing French and cheating as much as I could might get me in Level 1.5. And so, I used About.com’s “French grammar” to cheat on the multiple-choice section. I wrote an essay in Google Translate and submitted this thing. (Laughter) I sent it off. I didn’t think about any more of it. And three months later I got an email, and that email said, “Congratulations! You did really well on your placement test! We’re placing you in the intermediate level.” (Laughter) “You have three months. In three months, we’re going to put you in a room with a French speaker. We’ll talk to you for about 15 minutes to make sure you did not do anything stupid, like cheat on your placement test.” (Laughter)

And so, I panicked. And when I panic, I go to the internet because, clearly, someone there has an answer for everything, and as it turns out, there were some good answers. There are these systems called spaced repetition systems. They’re basically like flashcards. You know those cards with, like, “chat - cat” that you used in school? These are computerized versions of these, but they test you right at the optimal moment, right before you forget any piece of information, so they’re extremely efficient. Now, what people use these space repetitions programs for is they use them with translations. And I knew from my experiences with Hebrew and Russian that that wasn’t going to work for me, and so I did something else. And to explain that, let’s talk about two words. The first word, we learn in a classroom. We’re learning Hungarian. Our teacher comes to the board. She writes fényképezőgép is the Hungarian word for camera. And then she writes 39 other words on the board and says, “This will be your vocabulary for the week. You’ll have a quiz at the end of the week.” The second word, we learn quite differently. You are on an adventure with your best friend. You’re in Scandinavia. You find yourselves in an old bar. There are six grizzled old patrons. You sit at the bar, and the barkeep, he is definitely a Viking. He has a giant red beard, and he is smiling at you in a very disturbing manner as he puts out three shot glasses and pulls out a bottle, and on the bottle you see written M O K T O R, as the barkeep says, “Moktor” and starts pouring something into these shot glasses. And it’s a sort of green liquid, but not a nice, emerald green liquid; it’s a kind of brownish yellowish viscous green liquid. And he puts the bottle away, and he pulls out a white jar. From the white jar, he starts spooning out something into each shot glass. From the scent, you realize this is definitely rotting fish, as he repeats, “Moktor,” and all the patrons now are turning and looking at you and laughing. The barkeep now pulls out a match. He lights it, he lights the three shot glasses on fire, and he repeats, “Moktor,” as all of the patrons now start chanting “Moktor! Moktor! Moktor!” And your friend, your stupid friend, he picks up his shot glass and he shouts “Moktor!” and he blows it out, and he drinks it. And the barkeep, he blows his out, and he shouts “Moktor!” and he drinks it. And now everyone is staring at you, chanting “Moktor! Moktor!” And you pick up your glass - “Moktor!” - and you blow it out - “Moktor!” - and you scream “Moktor!” and you drink it. And it’s the worst thing you’ve ever had in your life. And you will remember the word moktor forever - (Laughter)

where you have already forgotten the Hungarian word for camera. (Laughter) Why? Memories are fascinating things. They’re not stored in any particular location in your brain; they’re actually stored in the connections between regions of your brain. When you saw that glass, you saw the bottle and it said M O K T O R, and the barkeep said, “Moktor,” that sound and that spelling, they interconnected; they formed a memory. Those connections connected to other sounds: the sound of moktor getting poured into those shot glasses, the sound of everyone chanting in the room “Moktor! Moktor!” All of those sounds and that spelling, they interconnected, and they also connected to images. They connected to images of this green bottle. They connected to the shot glasses. They connected to this decaying fish. They connected to the face of that barkeep; that Viking face, that is a part of that word now. And those, in turn, connect to sensory experiences, like that awful taste in your mouth, the smell of burning, decaying fish, the heat of the fire. Those connect to emotional content: to disgust, to anger at your friend, to excitement. They connect to your journey. They connect to what is alcohol, what is Scandinavia, what is friendship, what is adventure. All of these things are now a part of this word, and they make it so that that word is going to stick with you, where the Hungarian word for camera, well, you don’t even remember what it sounds like. This non-memory isn’t associated with iPhone cameras and SLR cameras and the sound of a shutter, and the feelings you get when you look at photos from your past. No, those associations exist; they’re connected to another word, to the word camera. But fényképezőgép has none of that right now. And so, you can’t hold on to it. So what can you do with this?

Well, let’s return to where I was with French. My situation was as follows: I was taking two master’s degrees, one in song, one in opera, and so I had six days of class a week. My only free time was an hour a day on the subway, Sundays, and Austrian national holidays, of which, thankfully, there were many. And during that time, I did one thing: I built and reviewed flashcards in one of these computerized spaced repetition systems. But instead of using translations on those flashcards, I began with pictures. If I wanted to learn the French word for dog, chien, then I would search on Google Images for chien, and I would find that French bloggers didn’t choose the dogs I would expect. Their dogs were smaller and cuter and, somehow, more French. (Laughter) And so, I used these dogs to learn chien and built a vocabulary out of these pictures from French bloggers. And as I built that vocabulary, I graduated over to sentences. And I started learning abstract words and grammar that way, using fill-in-the-blank sentences. If I wanted to learn a word, like, went is the past tense of to go, I would use a story. Yesterday, I blank to school - with a picture of a schoolhouse. And so, I learned my abstract grammar in that way. And then, three months later, I had that interview. And I found myself in this room with this French person, who began our conversation with “Bonjour.” And then, the first thing that came to my mind was, “Bonjour.” And she started speaking to me in French, and I realized I understood what she was saying, and what’s more, I knew what to say back. And it wasn’t fluent; it was a bit stunted, but this was the first time I had spoken French in my life, and I was speaking in French, and I was thinking in French, and we had a 15-minute conversation, and at the end of this conversation, the teacher tells me, “You know, there something wrong with your placement test. It says you should be in the intermediate level, but we’re placing you in the advanced level.” And so, over the next seven weeks, I read 10 books, I wrote 70 pages of essays, and by the end of that summer, I was fully fluent in French. And I realized that I had found something important. And so I started writing about it and creating computerized tools around it and tinkering.

In 2012, I learned Russian. I had my revenge on that language. In 2013 through 2015, I learned Hungarian. In 2015, I started Japanese, then stopped, learned Spanish, came back, and started Japanese again because Japanese is endless. In each of these experiences, I learned a lot. I learned ways of tweaking the system to find efficiency boosts here and there, but the overall concept has always remained exactly the same. If you want to learn a language efficiently, then you need to give that language life. Every word needs to connect to sounds and images and scents and tastes and emotions. Every bit of grammar can’t be some kind of abstract grammatical code; it needs to be something that can help you tell your story. And if you do this, you will find that the words begin to stick in your mind, and the grammar, it begins to stick too. And you start to realize that you don’t need some kind of language gene, some gift from God to accomplish this. This is something that everyone has both the time and the ability to do. Thank you.

What Bruce Lee can teach us about living fully - Shannon Lee - TED Salon - Transcript

Bruce Lee is my father, and he is best well-known as a martial artist and an action film star, as I’m sure most of you know. He died when I was four years old, but I have a really deep memory of him. I don’t have those long-form, storied memories that you do when you’re older, but the memory that I do have is of the feeling of him. I remember his energy, his presence, his love – the safety of it, the power of it, the radiance of it. And to me that memory is very deep and personal. And it is the memory of the quality of his essential nature.

What a lot of people don’t know about my father is that he was also a philosopher. He had a very ever-evolving philosophy that he lived, and it is that distinction – that he lived his philosophy and didn’t just espouse his philosophy – that made him the force of nature that he was, and still engages us today. His wisdom has salvaged me many times in my life: when my brother died, when my heart’s been broken, whenever I have faced a challenge to my mind, my body or my spirit, the way that he expressed himself has lifted me up. And so I come to you today not as a researcher or an educator or a guru or even a life coach, but as a student of Bruce Lee – as his daughter, and also as a student of my own life.

So … my big burning question that I want you all to consider today is … how are you? Let me elaborate. Whenever anyone would ask my mom what my father was like, she would say, “How he was in front of the camera, how you saw him in his films, how you saw him in his interviews was, in fact, exactly how he was.” There were not multiple Bruce Lees. There was not public Bruce Lee and private Bruce Lee, or teacher Bruce Lee and actor Bruce Lee and family man Bruce Lee. There was just one unified, total Bruce Lee. And that Bruce Lee had a very deep, philosophical life practice called self-actualization. You’ve probably heard that term before. It’s also known as how to be yourself in the best way possible. And that Bruce Lee said this: “When I look around, I always learn something and that is to be always yourself, and to express yourself and have faith in yourself. Don’t go out and find a successful personality and duplicate it, but rather start from the very root of your being, which is ‘How can I be me?’

Many of us have done some soul-searching or at least some incessant thinking and worrying about things like our purpose, our passion, our impact, our values and our “reason for being.” And that is sometimes considered our why. Why am I here? Why this life? What am I meant to be doing? If we can grab a little piece of that information, it can help to ground us and root us, and it can also point us in a direction, and typically what it points us to is our what. What we manifest in the world, what we have. So our job, our home, our hobbies and the like. But there’s this little space in between the why and the what that often doesn’t get our full attention, and that is our … how. How we get there and the quality of that doing. And I want to offer that this is actually the most important part of the equation when it comes to our personal growth, our sense of wholeness and even the long-term impact that we make.

How is the action that bridges the gap from the internal to the external. And bridging the gap is a very important concept for martial artists like my father. It’s how you get from point A to point B. It’s how you get from here to your target under the most vital of circumstances. And so it makes all the difference. Do you get there as an amateur? Are you sloppy? Are you wild, chaotic, sometimes you get lucky, sometimes you’re not lucky? Or are you a warrior? Are you confident? Are you focused? Are you skilled? Are you intuitive? Are you expressive, creative, aware? So I want to talk to you today about your how in your life.

So we do a little bit of – we spend a little time in existential crisis over “Why am I here? What am I meant to be doing?” and we put a ton of effort into our what – our job, our career, our partner that we have and the hobbies we pursue. But I want us to consider that our how is the expression of our why in every what, whether we’re aware of it or not. And so let’s take an example. Let’s say that I have a value of kindness. I’m all about kindness, I feel really natural being kind, I want to see more kindness in the world. Is that kindness – is that value in the result or is it in the doing? Are you trying to be kind when it’s hard to be kind? Can you do something you don’t want to do kindly, like fire someone? Can you leave a relationship with kindness? If kindness is the value, then are you trying to express it in the whole spectrum of your doing – and trying to do that? Or are you just doing it when it’s easy? So I want us to think about that for a moment and consider, you know, if we come home and we’re kind and generous and loving with our kids, but then we go to work and we are dismissive and rude to our assistant and we treat them like a subhuman, then there is a fragmentation in the beingness of our value. And so I want us to consider that how we are in our lives is in fact how we are. Meaning, if I am the kind of person that walks down the street and smiles at people and says “hi” as I walk past them on the sidewalk, then that is how I am. But if I’m also the kind of person who makes fun of my brother every chance that I get behind his back, that is also the kind of person that I am. And ultimately how we are makes up the totality of the picture of who we are. And so I want to talk about how do we unite these pieces if we have any fragmentation. I want to understand how we embody ourselves as our one and only self.

How do we actualize the whole self? My father said, “All goals apart from the means are an illusion. There will never be means to ends – only means. And I am means. I am what I started with and when it is all over, I will be all that is left.“ So you can employ a systematic approach to training and practicing, but you can’t employ a systematic approach to actually living because life is a process not a goal. It is a means and not an end. So “to obtain enlightenment” – and I’m going to say self-actualize, to be self-actualized or to obtain wholeness – “emphasis should fall NOT on the cultivation of the particular department” – all of our whats – “which then merges into the totality of who we are as a total human being, but rather, on the total human being that then enters into and unites those particular departments.” You are your how.

You – if you have some consciousness and you want to bring some practice, if you want to step into that warrior space around your how – how you express in every aspect of your life – then you get to be the artist of that expression. You get to step into that and claim it and exercise it and bring that beingness through your doingness into your havingness. And there you will find the most profound of your growth, you will find a sense of wholeness and ultimately, you will leave a lasting impact on your environment.

My father was his how. He applied the execution of who he was to every aspect of his life. He was way more than that kung fu guy from the ‘70s. He was someone who worked very hard at actualizing his inner self and expressing it out into the world. And that laid the foundation for what continues to inspire us, engage us, excite us and attract us to him. He was the embodied example of living fully. He said, “I am means.“ And there are only means.

So I’m going to ask you one more time. Thank you for listening, and please consider, for you, across the spectrum of your doing, how are you?

Thank you.


Walking Along the Bank of Lake Washington

by Bruce Lee

The breeze on the bank
Already blows cool and mild;
The distant merging of lake and sky
Is but a red trace of sunset.

The deep silence of the lake,
Cuts of all tumult from me.
Along the lonely bank
I move with slow footsteps:

Alone the disturbed frogs scurry off.
Here and there are houses,
Cool beads of light spring out from them.

A dazzling moon
Snines down from the lonely depths of the sky.
In the moonlight slowly I move to a gung fu form.
Body and soul are fused into one.

Conceptual Blockbusting - A Guide To Better Ideas

the programmer’s main problem was not so much technical as psychological: he couldn’t make progress because he was trying to solve the wrong problem. We finally solved his problem by breaking through his conceptual block and solving an easier problem. Conceptual Blockbusting by James L. Adams studies this kind of leap and is generally a pleasant prod towards more creative thinking. Although it was not written with programmers in mind, many of its lessons are particularly appropriate for programming problems. Adams defines conceptual blocks as “metal walls that block the problem-solver from correctly perceiving a problem or conceiving its solution”. - Programming Pearls, by Jon Bentley


texts below are from © Conceptual Blockbusting 4th Edition, by James L. Adams

Chapter One Introduction

We spend little time monitoring our own thinking and comparing it with a more sophisticated ideal.

Thinking form

Conceptual blocks still control us. Much of thinking is quite automatic.

The following puzzle, which originates with Carl Duncker, is taken from The Arc of Creation by Arthur Koestler.

Puzzle: One morning, exactly at sunrise, a Buddhist monk began to climb a tall mountain. A narrow path, no more than a foot or two wide, spiraled around the mountain to a glittering temple at the summit. The monk ascended at varying rates of speed, stopping many times along the way to rest and eat dried fruit he carried with him. He reached the temple shortly before sunset. After several days of fasting and meditation he began his journey back along the same path, starting at sunrise and again walking at variable speeds with many pauses along the way His average speed descending was, of course, greater than his average climbing speed. Prove that there is a spot along the path that the monk will occupy on both trips at precisely the same time of day.

Solutions to Problems That Don’t Exist

Conceptual Blocks

mental walls that blocks the problem-solver from correctly perceiving a problem or conceiving its solutions.

Once again, please do the exercises and problems. The only way you will identify your own conceptual blocks is to try activities that are impeded by their existence.

Chapter Two Perceptual Blocks

Perceptual Blocks are obstacles that prevent the problem-solver from clearly perceiving either the problem itself or the information needed to solve the problem.

One: Detecting What You Expect - Stereotyping

Context is a key element in many memory techniques.

Two: Difficulty in isolating the Problem

Three: Tendency to Delimit the Problem Area Poorly

Puzzle: Draw no more than four straight lines(without lifting the pencil from the paper) which cross through all nine dots.

the widespread nature of this block is what makes this puzzle classic.

Four: Inability to See the Problem from Various Viewpoints

Five: Saturation

Six: Failure to Utilize all Sensory Inputs

Chapter Three Emotional blocks

The Mystery of Emotion

Freud

The Humanistic Psychologists

Fear of Taking a Risk

No Appetite for Chaos

Judging Rather than Generating ideas

inability Or Unwillingness to Incubate

Lack of challenge versus Excessive Zeal

Reality and Fantasy

of Flow and Angst

Chapter Four Cultural and Environmental blocks

Taboos

Humor in Problem-Solving

Reason and Intuition

Left-Handed and Right-Handed thinking

Primary and Secondary Creativity

Everybody Should Be Just Like Me

Cyber Is Better

Adria Anuzis looked at three aspects of communication, which she called
personal(same location, personal interaction),
cultural(commonalties of interest, background, and values),
cyber(interacting electronically).
she found that the most successful professional interaction made use of all three.

the best creative work comes from people who are not only electronically interconnected, but also share cultural values and interact personally in the same physical space.

Tradition and Change

Thinking Through Blocks

Environmental Blocks

Supportive Environments

Accepting and Incorporating Criticism

Autocratic Bosses

Non-Support

Chapter Five Intellectual and Expressive Blocks

Choosing Your Problem-Solving Language

Flexibility in Your Use of Strategies

Build upDisplaySimulate
EliminateOrganizeTest
Work ForwardListPlay
Work BackwardCheckManipulate
AssociateDiagramCopy
ClassifyChartInterpret
GeneralizeVerbalizeTransform
ExemplifyVisualizeTranslate
CompareMemorizeExpand
RelateRecallReduce
CommitRecordExaggerate
DeferRetrieveUnderstate
Leap InSearchAdapt
Hold backselectsubstitute
FocusPlancombine
releasepredictseparate
forceassumeChange
relaxquestionvary
dreamhypothesiscycle
imagineguessrepeat
purgedefinesystemize
incubatesymbolizerandomize

The Computer

Importance of Correct Information

Expressive Blocks

Chapter Six Alternate Thinking Languages

Visual Thinking

Other Sensory Languages

Cognitive Diversity

The Problems of Specialization

Analysis-Synthesis

Convergence-Divergence

Deduction-Induction

Jung and the Myers-Briggs Test

Chapter Seven Kinds of Blockbusters

A Questioning Attitude

Working on the Right Problem

Time and Effort Focusers

Set Breakers

Using other People’s ideas

Crossing Disciplines

Crossing Cultures and Changing Environments

Unconscious Blockbusting

Maslow

Barron

Other Paths for Freeing the Unconscious

Chapter Eight Groups

The Process

Synectics

Affiliation / Ego Needs

Leadership

Group Membership

Proper Support

Chapter Nine Organizations

Control vs. Creativity

The Pattern of Growth

Tradition and Past Success

Reward System and Support

Psychological Rewards

Support

Culture

LeetCode - Concurrency - 1114. Print in Order

An example of multiple solutions selected from discuss.

Java

volatile

Using volatile variables reduces the risk of memory consistency errors, because any write to a volatile variable establishes a happens-before relationship with subsequent reads of that same variable. This means that changes to a volatile variable are always visible to other threads. What’s more, it also means that when a thread reads a volatile variable, it sees not just the latest change to the volatile, but also the side effects of the code that led up the change.

volatile has semantics for memory visibility. Basically, the value of a volatile field becomes visible to all readers (other threads in particular) after a write operation completes on it. Without volatile, readers could see some non-updated value.

In programming, an atomic action is one that effectively happens all at once. An atomic action cannot stop in the middle: it either happens completely, or it doesn’t happen at all. No side effects of an atomic action are visible until the action is complete.

  • Reads and writes are atomic for reference variables and for most primitive variables (all types except long and double).
  • Reads and writes are atomic for all variables declared volatile (including long and double variables).

&#91;Java&#93; Simple, yet effective. Using volatile without lock

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class Foo {
private volatile int flag;

public Foo() {
flag = 1;
}

public void first(Runnable printFirst) throws InterruptedException {
for(;;) {
if (flag==1) {
printFirst.run();
flag = 2;
break;
}
}
}

public void second(Runnable printSecond) throws InterruptedException {
for(;;) {
if (flag==2) {
printSecond.run();
flag=3;
break;
}
}
}

public void third(Runnable printThird) throws InterruptedException {
for(;;) {
if (flag==3) {
printThird.run();
flag = 1;
break;
}
}
}
}

36 / 36 test cases passed.
Runtime: 9 ms, faster than 88.93% of Java online submissions for Print in Order.
Memory Usage: 35.9 MB, less than 100.00% of Java online submissions for Print in Order.

Semaphore

Conceptually, a semaphore maintains a set of permits. Each acquire() blocks if necessary until a permit is available, and then takes it. Each release() adds a permit, potentially releasing a blocking acquirer. However, no actual permit objects are used; the Semaphore just keeps a count of the number available and acts accordingly.

Semaphores are often used to restrict the number of threads that can access some (physical or logical) resource.

[Java/Go] Implements

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.concurrent.Semaphore;

class Foo {
Semaphore semaphore1 = new Semaphore(0);
Semaphore semaphore2 = new Semaphore(0);

public Foo() {

}

public void first(Runnable printFirst) throws InterruptedException {
printFirst.run();
semaphore1.release();

}

public void second(Runnable printSecond) throws InterruptedException {
semaphore1.acquire();
printSecond.run();
semaphore2.release();

}

public void third(Runnable printThird) throws InterruptedException {
semaphore2.acquire();
printThird.run();
}
}

36 / 36 test cases passed.
Runtime: 9 ms, faster than 89.05% of Java online submissions for Print in Order.
Memory Usage: 35.7 MB, less than 100.00% of Java online submissions for Print in Order.

synchronized

The Java programming language provides two basic synchronization idioms: synchronized methods and synchronized statements.

Unlike synchronized methods, synchronized statements must specify the object that provides the intrinsic lock.

Synchronized statements are also useful for improving concurrency with fine-grained synchronization.

[Java] Basic version with just a synchronized block & a counter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class Foo {
private String mutex = new String("");
private int counter = 1;

public Foo() {
}

public void first(Runnable printFirst) throws InterruptedException {
boolean loop = true;
while (loop) {
synchronized(mutex) {
if (counter == 1) {
printFirst.run();
++counter;
loop = false;
}
}
}
}

public void second(Runnable printSecond) throws InterruptedException {
boolean loop = true;
while (loop) {
synchronized(mutex) {
if (counter == 2) {
printSecond.run();
++counter;
loop = false;
}
}
}
}

public void third(Runnable printThird) throws InterruptedException {
boolean loop = true;
while (loop) {
synchronized(mutex) {
if (counter == 3) {
printThird.run();
++counter;
loop = false;
}
}
}
}
}

36 / 36 test cases passed.
Runtime: 9 ms, faster than 89.16% of Java online submissions for Print in Order.
Memory Usage: 36 MB, less than 100.00% of Java online submissions for Print in Order.

CountDownLatch

A synchronization aid that allows one or more threads to wait until a set of operations being performed in other threads completes.

A CountDownLatch is initialized with a given count. The await methods block until the current count reaches zero due to invocations of the countDown() method, after which all waiting threads are released and any subsequent invocations of await return immediately. This is a one-shot phenomenon – the count cannot be reset.

A CountDownLatch is a versatile synchronization tool and can be used for a number of purposes. A CountDownLatch initialized with a count of one serves as a simple on/off latch, or gate: all threads invoking await wait at the gate until it is opened by a thread invoking countDown(). A CountDownLatch initialized to N can be used to make one thread wait until N threads have completed some action, or some action has been completed N times.

A useful property of a CountDownLatch is that it doesn’t require that threads calling countDown wait for the count to reach zero before proceeding, it simply prevents any thread from proceeding past an await until all threads could pass.

Another typical usage would be to divide a problem into N parts, describe each part with a Runnable that executes that portion and counts down on the latch, and queue all the Runnables to an Executor. When all sub-parts are complete, the coordinating thread will be able to pass through await.

[Java] 7ms CountDownLatch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.concurrent.CountDownLatch;

class Foo {
private final CountDownLatch L1 = new CountDownLatch(1);
private final CountDownLatch L2 = new CountDownLatch(1);

public Foo() {
}

public void first(Runnable printFirst) throws InterruptedException {
printFirst.run();
L1.countDown();
}

public void second(Runnable printSecond) throws InterruptedException {
L1.await();
printSecond.run();
L2.countDown();

}

public void third(Runnable printThird) throws InterruptedException {
L2.await();
printThird.run();
}
}

36 / 36 test cases passed.
Runtime: 9 ms, faster than 89.16% of Java online submissions for Print in Order.
Memory Usage: 35.4 MB, less than 100.00% of Java online submissions for Print in Order.

Phaser

A reusable synchronization barrier, similar in functionality to CyclicBarrier and CountDownLatch but supporting more flexible usage.

Methods arrive() and arriveAndDeregister() record arrival. These methods do not block, but return an associated arrival phase number; that is, the phase number of the phaser to which the arrival applied.

Method awaitAdvance(int) requires an argument indicating an arrival phase number, and returns when the phaser advances to (or is already at) a different phase.

Java Phaser solution, very fast

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.concurrent.Phaser;

class Foo {
private Phaser phaser;

public Foo() {
phaser = new Phaser(3);
}

public void first(Runnable printFirst) throws InterruptedException {
phaser.arrive();
phaser.awaitAdvance(0);
printFirst.run();
phaser.arrive();
phaser.arrive();

}

public void second(Runnable printSecond) throws InterruptedException {
phaser.arrive();
phaser.awaitAdvance(0);
phaser.arrive();
phaser.awaitAdvance(1);
printSecond.run();
phaser.arrive();

}

public void third(Runnable printThird) throws InterruptedException {
phaser.arrive();
phaser.awaitAdvance(0);
phaser.arrive();
phaser.awaitAdvance(1);
phaser.arrive();
phaser.awaitAdvance(2);
printThird.run();
}
}

36 / 36 test cases passed.
Runtime: 10 ms, faster than 55.92% of Java online submissions for Print in Order.
Memory Usage: 36 MB, less than 100.00% of Java online submissions for Print in Order.

妄人妄语

Twitter

The equations that evolved in the minds of geniuses are the sonnets of God. Newton’s law of universal gravitation was superseded by Einstein equations. Dirac equation was as prophetic as Maxwell–Heaviside equations.

\(\displaystyle \huge F=G{\frac {m_{1}m_{2}}{r^{2}}}\)

\(\displaystyle \huge R_{\mu \nu }-{\frac {1}{2}}Rg_{\mu \nu } = 8 \pi T_{\mu \nu } \)

\(
\displaystyle \huge
\begin{align}
\nabla \cdot \mathbf {E} &={\frac {\rho }{\varepsilon _{0}}} \\
\nabla \cdot \mathbf {B} &=0 \\
\nabla \times \mathbf {E} &=-{\frac {\partial \mathbf {B} }{\partial t}} \\
\nabla \times \mathbf {B} &=\mu _{0}\left(\mathbf {J} +\varepsilon _{0}{\frac {\partial \mathbf {E} }{\partial t}}\right)
\end{align}
\)

\( \displaystyle \huge (i\hbar \gamma ^{\mu }\partial _{\mu }-mc)\psi =0 \)

Many men have had intuitions well ahead of their time … Gibbs rather than Einstein or Heisenberg or Planck to whom we must attribute the first great revolution of twentieth-century physics. (Norbert Wiener)

Science has no national borders. National boundaries are not evident when we view the Earth from space. (Carl Sagan)

There are two avenues by which opinions are received into the soul, which are its two principal powers: the understanding and the will. (Blaise Pascal)

Two things fill the mind with ever-increasing wonder and awe, the more often and the more intensely the mind of thought is drawn to them: the starry heavens above me and the moral law within me. — Immanuel Kant, Critique of Practical Reason (1788)

The world won’t care about your self-esteem. The world will expect you to accomplish something before you feel good about yourself. (Charlie Sykes)

whereas in thinking of God, a man must abstract Him from all substance, and not think of Him as a form of extension, but as an order of events. God was no Being, but pure Act — the principle of a transcendental world-order. — Heinrich Heine, Reisebilder

人念及上帝时,应该把祂抽离一切实在,而不将祂想象为占空间的形式,上帝不是存在,而是世易时移之力,一个形而上世界的秩序的原素。— 海涅,《游记》

For we are mistaken when we look forward to death; the major portion of death has already passed. Whatever years be behind us are in death’s hands. (Seneca the Younger)

Before you were born your parents weren’t as boring as they are now. They got that way paying bills, cleaning your room, and listening to you tell them how idealistic you are. … — Charles Sykes(author of DUMBING DOWN OUR KIDS)

Democracy is the worst form of government, except for all the others. ― Winston S. Churchill

Winston Churchill: The empires of the future are the empires of the mind.

Winston Churchill: The price of greatness is responsibility.

Winston Churchill: Where there is great power there is great responsibility.

责任体现伟大之价值(丘吉尔)

American Dream: that dream of a land in which life should be better and richer and fuller for everyone, with opportunity for each according to ability or achievement. - The Epic of America, James Truslow Adams

To die is only to be as we were before we were born; [on the fear of death] (William Hazlitt)

司马贺:实践和思考,是学生学到知识的途径,也是唯一的途径。

Anyone who is not shocked by quantum theory has not understood it. - Niels Bohr

Debugging sucks. Testing rocks!

A wealth of information creates a poverty of attention. — Herbert A. Simon

We are all of us more or less the slaves of opinion. - William Hazlitt

Newton was far from the crude thought that explanation of phenomena could be attained by abstraction. — Bernhard Riemann

The word hypothesis has now a somewhat different significance from that given it by Newton. We are now accustomed to understand by hypothesis all thoughts connected with the phenomena. — Bernhard Riemann

Natural science is the attempt to comprehend nature by precise concepts. — Bernhard Riemann

I have always depended on the kindness of strangers. — Blanche DuBois in play A Streetcar Named Desire

Nothing will work unless you do. — Maya Angelou

I started to realize that maybe Thomas Edison did a lot more to improve the world than Karl Marx and Neem Karoli Baba put together. — Steve Jobs

万般带不走,唯有业随身
Men are judged by what they do. A man must take the consequence of his own deeds.

There isn’t time, so brief is life, for bickerings, apologies, heartburnings, callings to account. There is only time for loving, and but an instant, so to speak, for that. — Mark Twain

Here is my secret. It is very simple: It is only with the heart that one can see rightly; what is essential is invisible to the eye.
But the eyes are blind. One must look with the heart…
— The Little Prince

I don’t know who my grandfather was; I am much more concerned to know what his grandson will be. - Abraham Lincoln

Aristotle: The totality is not, as it were, a mere heap, but the whole is something besides the parts. Euclid: The whole is greater than the part.

人的情绪有一种类似植物顶端优势的机制,一旦一种情绪盘踞心头,别的情绪在当下就被边缘化。调节情绪就像认识自我一样不容易。性格,它左右我这一生。情绪,它主宰我每一天。

居里夫人在给她女儿的信中写道:我的亲爱的女儿,愿你们每天都愉快地过着生活,不要等到日子过去了才找出它们的可爱之点,也不要把所有特别合意的希望都放在将来。

I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
― Albert Einstein

第三次世界大戰將要使用的武器我並不知道,但是第四次世界大戰將會用木棍和石頭開戰。(愛因斯坦)

Internet的确产生了大众文化,但是我们不应该忽略,它也可能降低创造性,因为许多人在寻求信息,而自己却没有时间进行思考。 – Ilya Prigogine

前乌克兰党魁伽弗里洛夫是个业余数学家,20世纪60年代利用大权在握,设法让他给出的黎曼假设的错误证明发表出来,蓋爾范德为此差点心脏病发作,因为他认为这一黎曼假设错误证明的发表,对苏联的数学造成了很大的伤害。

‘It’s really hard to find maintainers…’ Linus Torvalds ponders the future of Linux

Science is the only news. — Stewart Brand

John Polkinghorne suggests that the mechanistic explanations of the world that have continued from Laplace to Richard Dawkins should be replaced by an understanding that most of nature is cloud-like rather than clock-like.

René Descartes is a philosopher who created analytic geometry, by contrast, Hegel is just a philosopher who was ignorant in mathematics, ‘Such things are nowhere more at home than among philosophers who are not mathematicians’,as Gauss put it. Schopenhauer is better than Hegel.

A Time for Leadership by Margaret Thatcher - China will not become a superpower to match the United States — at least, not while it is held back by the deadweight of socialism.

The tides caused by the moon are key to life forming on earth. As Maggie concluded “the moon is the mother of us all

Your smartphone is making you stupid, antisocial and unhealthy. So why can’t you put it down?

In the fight against climate change, we pay now or our children pay later

Facebook

Our main business is not to see what lies dimly at a distance, but to do what lies clearly at hand.

今天的我是昨天的我选择的结果,明天的我将是今天的我选择的结果,我们就这样在一天天地选择着未来的自己,我的选择就是我的未来,我的习性就是我的选择。

大多数人,都是自己的热情和欲念的奴隶。

所谓的活着,不过是在消耗粮食污染环境。

豆瓣

“民科”和“民哲”不仅在思维、心理上高度相似,就像是同一个心理物种,而且甚至可以相互转化,成为相同的社会物种。

我是宇宙的一块拼图,体量上也许微不足道,但个性上可能独一无二。

伽罗瓦:扩域。黎曼:解析延拓。Cohen:力迫,扩张模型。朗兰兹:数学分支奇妙的内在联系

电视时代,沙发上的土豆。触屏时代,低头的屏奴。娱乐至死的时代。唯一能安慰我们之可悲的东西就是消遣,可是它也是我们可悲之中的最大的可悲。……若是没有它,我们就会陷于无聊,而这种无聊就会推动我们去寻找一种更牢靠的解脱办法了。可是消遣却使得我们开心,并使我们不知不觉地走到死亡。

乔治·华盛顿曾经说过:”如果被剥夺了言论自由,我们就会变得愚笨沉默,如绵羊般被拉向屠宰场。”

我们这些没本事的平庸之人,只能堕入“拿命换钱,拿钱续命”的有限循环螺旋式死亡之旅。

衰老是慢性病?

约西亚·威拉德·吉布斯:科学存在一种建设力,能从混沌中重建次序;科学存在一种分析力,能够区分真实与虚假;科学存在一种整合力,能看到一个真理而没哟忘记另一个真理;拥有这三种才能的,才是真正的科学家。 天才敬天才,麦克斯韦和爱因斯坦都赞赏吉布斯。

Bitcoin has evolved to become better-suited to being an asset than being a means of exchange.

手游让我们娱乐至死

你的兴趣,是痴心迷恋的真兴趣?还是叶公好龙的假爱好?

Well-being and happiness never appeared to me as an absolute aim. I am even inclined to compare such moral aims to the ambitions of a pig.

David Hilbert: Every boy in the streets of our mathematical Göttingen understands more about four-dimensional geometry than Einstein. Yet, despite that, Einstein did the work and not the mathematicians.

陈省身:我不久即看到爱因斯坦所遭遇的问题之极度困难以及数学与物理的不同,数学中有名的问题通常是已经提得很明确的,但在物理学中,问题的提法也是问题的一部分。不知道他试图实现统一场论的物理学洞见如何?手头的数学工具也就那样。丛和联络这两个几何概念都很简洁,我相信爱因斯坦会喜欢它们。

余英时: 西方经典《赞愚》中就说,越是愚钝的人越有智慧,愚钝的人不是言词辩诘,而是对人生有某些很深的体验。越聪明的人越是糟糕,聪明等于是一个工具,就像科技一样… - 精神空虚的中国没有大师

许知远: 利润,如今变成了连接这个国家的纽带,看看今天中国人信仰的庸俗哲学吧:一切都是利益驱动的,一切现象都可以通过利益来解释。 - 价值的真空

欧拉全集84卷,黎曼全集1卷,欧拉是高斯的祖父辈,欧拉比高斯大了整整七十岁,高斯是黎曼的伯父辈,高斯比黎曼大四十九岁。黎曼为了证明高斯关于素数密度可以用对数积分来估计的猜想,把欧拉乘积恒等式推广到复域,提出了zeta函数及其函数方程,为素数定理的证明理清了理路。

浮生若梦,人生几何?有首流行歌曲叫《光阴的故事》,有部情景喜剧叫《成长的烦恼》

耶稣会的教士都接受过良好的欧洲人文教育并经受过准军事训练,利玛窦、汤若望、南怀仁都是这一组织中出类拔萃的人才,他们身后有足够的支持,供他们以精密的仪器、华美的书籍、先进的技术赢得中国上流社会的青睐。

有时我觉得自己学习中文非常有益,陶冶性灵,但更多的时候,我觉得自己是中毒太深,不敢再把情绪放纵到诗与文里面,以免如梦如幻,贻误终身。

西奥多·罗斯福把这些喜欢揭露社会阴暗面的记者称为“扒粪者”(muckraker),但他肯定了这些揭露社会黑暗的记者们的价值,认为只有把丑恶暴露在阳光下,社会才可能改善。前后持续十几年的“扒粪运动”,有效地净化了美国的政治和商务生态,也给美国新闻行业建立了“调查”和“批评”的传统。

弗里曼·戴森认为博士制度令人讨厌, Freeman Dyson没有博士学位。
博士制度是在19世纪为了教育德国教授而发明的,它适合那些少数将要终身当教授的人,但现在却变成了为了工作而必须获得的某种会员卡,无论是成为教授还是从事其它职业。它迫使人们浪费许多年的时间和生命,去假装做一些他们其实完全不适合的研究。

民科的命操牛顿的心

工作撵跑三个魔鬼:无聊、堕落和贫穷。

浮生若梦,人生最大的痛苦是梦醒了发现自己无路可走。

微博

《道德经》中“修之于身,其德乃真”的本义,似乎不是在嘲笑那些伪君子言行不一“说一套、做一套”、仁义道德嘴把式,而是:尽管你认同那些更有利于使你“做最好的自己”的种种道理,你却不能够把它们身体力行,这些能够“德润身”的道理就只是些虚的道理,而坏习惯依旧像鬼魂一样形影不离地跟随着你。 ​​​​

明-洪应明-菜根谭:迷则乐境成苦海,悟则苦海为乐境。John Milton, Paradise Lost: The mind is its own place, and in it self Can make a Heav’n of Hell, a Hell of Heav’n.

“饭吃七分饱”的富兰克林表达法:在我见到的人中,饿死的人寥寥无几,撑死的人倒有成千上万。 Eat not to Dulness. Drink not to Elevation.

相当一部分中国公民以经济为惟一生活目标。科名之心不可有,经济之才不可无。Money talks. In God we trust, the rest pay cash. Money changed hands. ​​​​

有没有一个科学的价值观?什么样的价值观能让我不卑不亢?什么样的价值观能让我心平气和?什么样的价值观能让我泰然自若?内隐的价值观,挥之不去的内心指令,根深蒂固的核心假设,心理捷径累积成思维定势,生活的磨砺在内心深处的沉淀,价值的迷失是全盘的迷失,是注定要误入歧途、无可救药的迷失。

子不语怪、力、乱、神。知之为知之,不知为不知,是知也。子曰:未知生,焉知死?未能事人,焉能事鬼?敬鬼神而远之。~ 疑邻偷斧,疑心生暗鬼。~ 精气为物,游魂为变。~ 一念之善,吉神随之;一念之恶,厉鬼尾之。~ 暗示能作用于心理,人的知觉伴生错觉甚至幻觉,居心不良的人就有可能在其中搞鬼。 ​​​​

德裔美籍数学家 Hans Lewy(烈伟,1904~1988,R.柯朗(D.希尔伯特的学生)的学生)曾以数学家的口吻说道:“在许多方面分析(即逻辑严谨的微积分)比其它一些数学分支更接近于生活。”意思好像是说数学分析的问题不管是陈述、前提,还是结论、趋势都不是那么清晰明了,需要下功夫,如同生活的真面目。

E.T.BELL数学三清最得意的成就:① Αρχιμήδης:球的体积计算公式,被刻在其墓碑上和菲尔兹奖章背面;② Newton:用三棱镜发现光的色散,牛顿自称:“在我看来,如果那不是迄今对自然的演变所作的最重要的发现,也是最有趣的发现。” ③ Gauß:高斯-博内公式,高斯称其为Theorema Egregium。

19世纪并肩齐名的数学与物理的集大成者:黎曼(G.F.B.Riemann, 1826~1866),师承高斯、狄利克雷,黎曼几何、黎曼zeta函数等关键数学概念的首创者,堪称现代数学的摩西;麦克斯韦(James Clerk Maxwell,1831~1879),师承开尔文勋爵、斯托克斯爵士,巨著《电磁通论》指引人类步入电气时代的康庄大道。 ​​​​

德鲁克(管理学的Guru)针对知识社会的重要课题【自我管理】提了几个问题:1. 我的优势是什么?不要试图改变自己,这样做是不能成功的。相反,你需要用心改进做事的方式方法。不要采用你做不到或做得不好的方法来做事。2. 做事的方式方法?3. 价值观?4. 取舍?5. 我能贡献什么?6. 建设性的人际关系

科学精神希冀人类的理性能够逼近三位一体的神所走的无穷的道路,于是有了集合论中的悖论和量子力学中的佯谬。罗素理发师悖论:朴素集合论经不起推敲;巴拿赫-塔斯基悖论:选择公理会变魔术;波粒二象性佯谬:实相无相,微妙法门;测量佯谬:波包一测就塌缩。薛定谔的猫到底是活着还是死了?这很难说。 ​​​​

科学家的临终憾事:爱因斯坦:统一场论,规范场纲领已经形式上统一了电弱强这三种基本力,但引力很难纳入规范场纲领;海森堡:湍流,虽然以测不准原理而闻名于世,但海森堡的博士论文却是 -《关于流体运动的层流和湍流》;哈代:黎曼假设,我敢说没有一种微积分和伽罗瓦理论那样的新思想新方法,甭想证明RH。

美国很有创造性的微分几何学家 H.惠特尼对数学的研究与学习的方法论方面有相当独到的见解,他认为最好的学习方法是学以致用,没有自己的想法那不是真正的学习,他对研究过程的描述相当吻合认知心理学关于知识的心理表征、认知地图、图式、问题解决与创造性的观点。​

在科学天才的头脑中进化着的科学方程,是造物主的十四行诗。牛顿以横绝一世的数学才能综合出让天文学家奉为圭臬的万有引力定律,爱因斯坦以彰显理性思维极致的广义相对论引力场方程超越之。麦克斯韦与赫维赛德提炼出以对称之美著称的电磁场方程组,狄拉克以魔法般的相对论性量子电动力学方程组令人叹为观止。

《社会的管理》结尾写道:从机械的宇宙向生物的宇宙的转变,最终将需要一种新的哲学综合。康德也许会把它叫做Einsicht或叫做一种“纯粹洞察批判”。这是Peter F. Drucker的原话,还是选编者 Atsuo Ueda(笃男植田)添油加醋的话?

针对物理学家 Eugene Wigner(尤金·维格纳,1902—1995)“数学在物理学中不可思议的有效性”的说法,数学家 Israïl Moseevich Gelfand(I.M.盖尔范德,1913—2009)说了句饶舌的俏皮话:这世上惟一比“数学在物理学中不可思议的有效性”更加不可思议的是“数学在生物学中不可思议的无效性”。

科学精神的理念旨在寻求自洽、贯通、循序的理路,它的困难在于要借助最终展现为逻辑链路的思维去探究一个非线性的、无穷维自由度的、混沌的世界,它的稳妥、公信力与继往开来式发展使它永远存在着揭不开的谜团,它寻求的是“人同此心,心同此理”的道与理,而非“只可意会,不可言传”的感与悟。

只有科学的进步才像太阳的光辉一样普照芸芸众生。

工作是银,健康是金。1992年世界卫生组织在加拿大维多利亚召开的国际心脏健康会议上发表的关于保健的《维多利亚宣言》认为健康的四大基石是:1、均衡膳食,2、戒烟限酒,3、适量运动,4、心理平衡。

1976年愚人节,乔布斯和沃兹尼克、Ronald Wayne 一起创建了苹果公司,11天后 Ronald Wayne 选择了退出,并把他名下如今价值220亿美元的10%股权以800美元卖给了乔布斯和沃兹尼克。 ​​​​有个CNN记者采访了与巨额财富失之交臂的 Ronald Wayne,Ronald Wayne 说道:”What can I say? You make a decision based on your understanding of the circumstances, and you live with it, But when you’re at a focal point of history, you don’t realize you’re at a focal point of history.”

React Native Cheat Sheet

Accessing console logs

  • react-native log-ios
  • react-native log-android

xcrun simctl list devices

  • react-native run-ios –simulator “iPhone 8”
  • react-native run-android

Sometimes you may need to reset or clear the React Native packager’s cache. To do so, you can pass the –reset-cache flag to the start script:

  • npm start – –reset-cache
  • yarn start – –reset-cache

人人都能用英语 - 李笑来

怎样才能学好英语?
一个字:“”。

digested from © 人人都能用英语

不要再 “学” 英语,你就该 “用” 英语!

你英文发音再难听,听的人也不会因此猝死;你英文语法错误再多,读的人也不会因此疼痛;别人对你说英文你没听懂或者给你看英文你没读懂,若非极端情况,你也不会因此就从此真的无颜见人。
只 “学” 不 “用”(这是大多数中国学生的写照)的下场就是在十几年之后依然在学依然无用(这是大多数中国学生的现实)。
只有不断地 “用”,才能真正地 “学”,因为所有技能的习得,都要靠试错(Trial and Error)。很多人宁愿 “学一辈子”,却坚持 “一辈子不用” 的原因就在于害怕犯错。儿时犯错往往招致惩罚,成年之后,就算没有来自他人的惩罚,还有因为犯错而导致自己自卑和尴尬,所以,很多人是 “不惜一切代价” 避免出错的。然而,要知道知识的习得过程离不开试错,没有试错,就不可能有全面而真实的进步。所以,要知道犯错是正常的,甚至是不可或缺的。做事的时候,出错是必然的,如果正在做事却一点错都没有,那不是做事──那是在做梦。

我是如何摆脱哑巴英语的?

我以前总以为学生的问题是 “不知道怎么说”(HOW)──我曾以为我自己的问题也是如此;现在我认为学生所面临的问题不仅仅是这个,更重要的是他们 “没什么话可说”(WHAT)。
后来我就养成了习惯,不再指望自己能够脱口而出,而是希望自己有备无患。每当我遇到一些要讲英文的正式场合,我一定会提前花时间先写 “逐字稿”,不会写的就去查查词典,查词典查不到的,就用 Google 搜索,连 Google 都搜不到,那就想想看有没有可替代的说法 …… 而后再花时间修订,熟悉,复述。如此这般之后,到了现场,基本上能够做到 “自如” 应对。
请允许我重复一遍:你的问题也许不在于你不会说,而在于你没什么话可说。

其实连哑巴英语都并不那么坏

说得形象点,说不出像哑巴,听不懂像聋子,读不懂像瞎子;而写不出呢?——大多数文化并不默认一个人写不了字是一种残疾。先不管能否写得出,只谈哑巴、聋子和瞎子。如果你必须成为这三种 “残疾” 中的一种,你会选哪个?我认真想过,我会选 “聋子” —— 因为不瞎不哑,起码还保留了输入和输出的渠道。我最怕成为 “瞎子” —— 因为那是最重要的输入手段,尤其是因为文字输入几乎占所有有效输入的绝大部分。某种意义上来说,学习一门外语最大的公用莫过于增加一个不一样的信息获得渠道。从这一点上来看,哑巴比聋子、瞎子强多了,而后两者之中,瞎子又远不如聋子。

发音很重要,但显然不是最重要的

中国学生往往不是不会说英文,也不是不愿说英文,更不是不能说英文,基本上都是不敢说英文。为什么不敢呢?很多原因。其中有一个是最普遍的,害怕自己的发音不标准。可是第二语言习得者发音不准不是很正常的事情么?就算是母语,我们都是花了很长时间才可以做到基本上说清楚的。当你能够用母语清楚地表达自己的时候,多大了?那凭什么一个人可以从一开始就能用第二语言做到清楚准确表达呢?并且还要 “发音标准”?
全世界所有的语言都是如此,每种语言都有各种各样的口音。英语也许是地球上口音最多的语言。在美国,南加利福尼亚和北加利福尼亚的口音就已经非常不同,大 抵上相当于在中国山东人之间山西人讲中文的差异。纽约人和底特律人的发音当然也非常不一样。在伦敦,东部和南部的口音差异就已经非常明显。更不消说还有 “苏格兰口音”、“加拿大口音”、“澳大利亚口音”、“新西兰口音”、“印度口音”……
为将英语作为第二语言使用的人,完全不必因为自己的发音不标准、不好听、不清楚感到自卑,那其实是正常的、自然的、不可避免的。而语言使用,本质上以沟通为目的。要知道仅仅发音标准,并不意味着说就肯定可以有效沟通。有效沟通还需要用词、文法、逻辑、内容等等更多因素,而后面提到的所有这些因素,无一不比 “标准发音” 更重要。想像一下吧,联合国开会的时候,难道每个国家的发言人都用的是 “标准英音”?或者 “标准美音”?尽管每个国家的发言人都要用英文发言,但全都用掺杂自己特定口音,可是从未影响有效沟通。

多听多听再多听

最有效的方法其实是零成本的 —— 大幅度提高听觉输入量。
我常常建议自己的学生不要把自己的输入材料只限制于 “标准美音” 或者 “标准英音”;其实无所谓的,连颇具特色的 “黑人英语” 都可以听,甚至,越杂越好。我常常推荐的是CNN的广播,里面有各种各样腔调的英语,真的可以大开 “耳” 界。
有一个小技巧,听英语音频的时候不要两只耳朵全都戴上耳机 —— 只用一只耳朵戴耳机。因为自然语音输入和耳机输入是不一样的。在自然环境中,我们听到的语言语音从来都不是 “单独” 的 —— 总是伴随着各种各样的背景声音。戴着耳机的时候却基本上就只有 “纯粹的语音” 了,这对我们重建自己的语音过滤器来说并不是好事。只用一只耳朵戴耳机的另外一个好处是可以经常换着耳朵听,不至于损伤耳朵。
至少要坚持六个月,我个人建议每天的输入时间不要低于四个小时 —— 只要开始做,就会发现其实并不难,因为 “哪怕听不懂都无所谓”。听得多了,听得久了,早晚有一天想听不懂都不太容易。当然,即便是最初的时候,为了效果更佳,可以有意识地渐渐提高文本难度,并且最好配合精读。这期间几乎所有的人都会感觉没什么进步,但是,这种 “感觉” 是不靠谱的 —— 事实上,我们的感觉几乎总是极不靠谱。

一定要学会音标

中国学生学习音标还有另外一个苦恼。我们的课本里大多所使用的是 D.J.音标(英音),但这并不是唯一的音标体系。除了 D.J.之外,有些地方的教材使用的是 K.K.音标(美音);牛津词典和剑桥词典尽管都声称自己使用的是 IPA 国际音标,但多多少少各不相同;而有些学生在准备 SAT 或者 GRE 的时候,根据学长的建议开始使用 Merriam-Webster 词典,结果发现里面是彻头彻尾另外一个体系的音标 —— 事实上,几乎市面上所有的词典都在使用各不相同的音标体系。原本就不太好学的东西却又有那么多的版本 —— 当然更加令人气馁。

跟读训练具体步骤

拿来跟读材料之后,第一步是精读文本。不认识的词全部都要查过,然后确定该单词在当前句子中的确切含义,而后抄写在文本边上。当然,今天我们还有 MS Word,可以很方便地在文本上添加 “批注”。而在 Word 里,还有一个内建的词典,非常好用 …… 如果每个单词全都查过,却依然搞不懂句意,那么往往应该是有词组存在,再逐一查过。
查每一个生词的时候,都要记录重音和元音长度(必要时把整个音标写下来,也可以使用简化标记法)。
第二步是反复听录音,做自然语流修正标记。
第三步了。反复跟读。刚开始可以录音放一句,自己跟几遍,细心纠正自己的前提是大声朗读。熟悉了之后再录音放一句就跟一句,再熟悉一点之后就 “异步” 朗读。所谓的异步朗读,就是 “慢一拍跟读”。听到录音说了一个词之后我们再开始,嘴里重复的是录音里刚刚说完的那个词,而耳朵里同时听到的是自己的声音和录音里所说的下一个词,然后循环往复,在录音说完一句话的时候,我们再说一个词也就正好结束。这种训练可以很微妙地提高我们的英语瞬间记忆力。再熟悉到一定程度的时候,就可以 “同步” 朗读了。
第四步是录音矫正。每隔一段时间,可以把自己的朗读声音录下来存好,过上一个星期之后再翻出来听。很多人事倍功半的原因是录下来之后马上就去听,但这样的话,基本上没有什么矫正余地 —— 因为录音之后和录音之前的你还没有任何变化呢。当时你就觉得那么说是对的所以才那么说的,仅仅两三分钟之后,你不可能有什么巨大的或者哪怕是足够的进步;于是,没有变化的你,其实根本听不出自己哪儿不对了,也没有能力为自己进行矫正。但是,你一直在练,每天都在练,一个星期之后,你的进步就算不是巨大也是足够,于是你可能就会很容易地听出若干出过去出错的地方。

朗读

朗读是语文教育的最古老、最普及、成本最低、效果最好的训练方式。
说来可惜,但大多数人确实并不重视朗读训练 —— 无论是母语还是外语的习得过程中都是如此。朗读训练既简单又有效,并且可以解决很多许多人花很多钱去各种各样的培训班解决不了的问题。
朗读训练是提高文字理解能力的最有效方式。
朗读训练会潜移默化地提高阅读理解速度
不必专门练习听力,朗读就够了
大量的朗读训练,可以使学生不必专门练习 “听力”。某种意义上,很多学生花费时间去专门练习听力其实非常荒谬。不聋不哑的正常人是没必要专门训练什么听力的,事实上也没办法专门练 —— 大家的耳朵构造是相同的,怎么练耳廓也不会增大,耳膜也不会变得更薄……
其实道理很简单,只要说得出,就能听得懂 —— 不管是哪一种语言。所以,只需要练说,而没必要专门练听。很多人所谓的 “听力不好” 其实是说得不好造成的,然而,他们舍本求末,就是不说,而后专门练听,这不是荒唐是什么?事实上,哪怕说得不好,也一样能够听懂。举例来说,我国有很多地区的人普通话说得并不标准,讲话掺杂着浓重的本地口音,甚至使用大量的本地特有词汇,但是,你遇到过他们之中的哪一个向你抱怨说中央电视台的新闻联播听不懂么?
听写训练几乎是最浪费时间最无效果的所谓方法了。
朗读训练可以提高语言文字记忆能力
朗读训练能够提高表达能力
朗读训练可以提高语言文字模式识别能力

词典

查词典与朗读一样是提高阅读理解能力的最直接有效的手段之一。
英语老师与学生最大的不同可能只有一个,英语老师必须查词典(如果还有别的话,就是语法书之类的参考书),而学生却有除了查词典之外的另外一个选择 ——参加各种各样的课程。英语课上老师做什么呢?其实大抵上只不过是把昨天晚上他查过的单词、词组,以及他通过查词典(以及其它的工具书)再动脑才搞明白的句子给学生们讲一遍。而学生呢?做在下面听。学生们倒是听了,然而,本质上却没有参与阅读理解的过程 —— 那个过程里应该有苦恼、迷失、无助、慌张(人人都讨厌这些)和恍然大悟(人人都想只要这个);所以大多学生根本就没有动脑,于是顶多是以为自己搞懂了(事实上,没有之前的两个境界的铺垫,“蓦然回首” 根本看不见 “那人站在灯火阑珊处” 的。)
查词典并不难。但多一点点细心和耐心,却并不像想象得那么容易。
中国学生为什么总是疏于去查 “phrasal verb dictionary” 或者 “dictionary of idioms”
关于 Merriam-Webster 的权威性,基本上不容置疑。Merriam-Webster 的电子版,目前在网上可以找得到的有两种版本:2.5 版和 3.0 版。我个人认为 3.0 版并没有什么真正有意义的改进。2.5 版反倒相对更好用一些。
Merriam-Webster 电子版的 “真人发音”,是我个人认为目前可以找到的所有电子版词典中制作最为精良的 —— 发音最清晰(准确当然不用提),音量最稳定。
最后,Merriam-Webster 最牛的地方在于它有一个 “Spelling Help”。查找英文单词的时候,一个常见的窘境是,我们只知道某个单词的发音却不知道拼写,于是无法查到那个单词。然而,有了 “Spelling Help”,就非常方便了。
Collins Cobuild – Lexicon on CD-ROM我所推荐使用的是这部词典电子版的第三版,而非最新的第五版。

把 Word 打造成英语学习利器

对中国学生来说,MS Word 不仅仅是 “字处理工具”,更是一个非常强大的学习利器。
MS Word 2007 的 “鼠标取词” 功能
MS Word 2007 的 “词典面板”
MS Word 2007 的 “同近义辞典”(Thesaurus)
MS Word 2007 的 “英语助手”
为 MS Word 2007 设置单词朗读功能
用 Word 2007 为自己定制阅读文章词汇列表

LeetCode - Algorithms - 215. Kth Largest Element in an Array

It seemed that every leetcode algorithms problem has mulple solutions, so do this one. I just verified solutions of other peer.

Java

Quickselect

© Quickselect: Kth Greatest Value

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Solution {
private void exch(int[] a, int i, int j) {
int swap = a[i];
a[i] = a[j];
a[j] = swap;
}

private int partition(int[] a, int lo, int hi) {
int pivot = lo + new Random().nextInt(hi - lo + 1);
exch(a, hi, pivot);
for (int i = lo; i < hi; i++) {
if (a[i] > a[hi]) {
exch(a, i, lo);
lo++;
}
}
exch(a, lo, hi);
return lo;
}

private int quickselect(int[] a, int left, int right, int k) {
if (left <= right) {
int pivot = partition(a, left, right);
if (pivot == k) {
return a[k];
}
if (pivot > k) {
return quickselect(a, left, pivot - 1, k);
}
return quickselect(a, pivot + 1, right, k);
}
return Integer.MIN_VALUE;
}

public int findKthLargest(int[] nums, int k) {
return quickselect(nums, 0, nums.length - 1, k - 1);
}
}

Submission Detail

  • 32 / 32 test cases passed.
  • Runtime: 1 ms, faster than 98.04% of Java online submissions for Kth Largest Element in an Array.
  • Memory Usage: 39.3 MB, less than 11.22% of Java online submissions for Kth Largest Element in an Array.

Solution 1: sorting

1
2
3
4
5
6
7
8
import java.util.Arrays;

class Solution {
public int findKthLargest(int[] nums, int k) {
Arrays.sort(nums);
return nums[nums.length - k];
}
}

Submission Detail

  • 32 / 32 test cases passed.
  • Runtime: 3 ms, faster than 84.58% of Java online submissions for Kth Largest Element in an Array.
  • Memory Usage: 35.7 MB, less than 98.57% of Java online submissions for Kth Largest Element in an Array.

Solution 2: min heap

1
2
3
4
5
6
7
8
9
10
11
12
13
import java.util.PriorityQueue;

class Solution {
public int findKthLargest(int[] nums, int k) {
PriorityQueue<Integer> minHeap = new PriorityQueue<Integer>(k);
for(int i : nums) {
minHeap.offer(i);
if (minHeap.size()>k)
minHeap.poll();
}
return minHeap.peek();
}
}

Submission Detail

  • 32 / 32 test cases passed.
  • Runtime: 8 ms, faster than 51.68% of Java online submissions for Kth Largest Element in an Array.
  • Memory Usage: 35.7 MB, less than 98.37% of Java online submissions for Kth Largest Element in an Array.

Solution 3: a similar method like quick sort

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class Solution {
public int findKthLargest(int[] nums, int k) {
if (k < 1 || nums == null) {
return 0;
}
return getKth(nums.length - k + 1, nums, 0, nums.length - 1);
}

private int getKth(int k, int[] nums, int start, int end) {
int pivot = nums[end];
int left = start;
int right = end;
while (true) {
while (nums[left] < pivot && left < right) {
left++;
}
while (nums[right] >= pivot && right > left) {
right--;
}
if (left == right) {
break;
}
swap(nums, left, right);
}
swap(nums, left, end);
if (k == left + 1) {
return pivot;
} else if (k < left + 1) {
return getKth(k, nums, start, left - 1);
} else {
return getKth(k, nums, left + 1, end);
}
}

private void swap(int[] arr, int i, int j) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}

Submission Detail

  • 32 / 32 test cases passed.
  • Runtime: 22 ms, faster than 37.24% of Java online submissions for Kth Largest Element in an Array.
  • Memory Usage: 37.5 MB, less than 94.43% of Java online submissions for Kth Largest Element in an Array.