Maxim(至理名言)

事实上我们全都是些集体性人物,不管我们愿意把自己摆在什么位置,严格地说,可以看成我们所特有的东西是微乎其微的,就像我们个人是微乎其微的一样。我们全都要从前辈或同辈那里学习到一些东西,就连最大的天才,如果单凭他所具有的内在的自我去对付一切,他也决不会有多大成就。我们的发展要归功于广大世界千丝万缕的影响,从这些影响中,我们吸收我们能吸收的和对我们有用的那一部分。(歌德)

Mendelssohn plays to Goethe, 1830: painting by Moritz Oppenheim, 1864

But, in fact, we are all collective beings, let us place ourselves as we may. For how little have we, and are we, that we can strictly call our own property? We must all receive and learn both from those who were before us, and from those who are with us. Even the greatest genius would not go far if he tried to own everything to his own internal self.

I by no means owe my works to my own wisdom alone, but to a thousand things and persons around me, who provided me with material. There were fools and sages, minds enlightened and narrow, childhood, youth, and mature age - all told me what they felt, what they thought, how they lived and worked, and what experiences they had gained; and I had nothing further to do than to put out my hand and reap what others had sown for me.

Johann Wolfgang von Goethe, Goethe’s Works


任何个人要想突然做出惊人的发现 ,这是不符合事物发展的规律的 。科学是一步一个脚印地向前发展 ,每个人都要依赖前人的工作 。当你听说一个突然的 ,意想不到的发现 ——仿佛晴天霹雳时 ,你永远可以确信 ,它总是由一个人对另一个人的影响所导致的 ,正是因为有这种相互影响才使科学的进展存在着巨大的可能性 。科学并不依赖于某一个人的思想 ,而是依赖于千万人的集体智慧 ,千万人思考着同一个问题 ,每一个人尽他自己的一份力量 ,知识的大厦就是这样建造起来的 。(卢瑟福)

Ernest Rutherford

It is not in the nature of things for any one man to make a sudden violent discovery; science goes step by step, and every man depends on the work of his predecessors. When you hear of a sudden unexpected discovery—a bolt from the blue, as it were—you can always be sure that it has grown up by the influence of one man on another, and it is this mutual influence which makes the enormous possibility of scientific advance. Scientists are not dependent on the ideas of a single man, but on the combined wisdom of thousands of men, all thinking of the same problem, and each doing his little bit to add to the great structure of knowledge which is gradually being erected.
Ernest Rutherford


我曾经为知识领域添瓦加砖,也曾帮别人添枝加叶;这些东西的价值,比起身后留下某种纪念物的大数学家或任何其他大大小小的艺术家们创造的价值,只是程度上有所不同,性质上并无差异。(哈代)

Hardy, c. 1927

The case for my life, then, or for that of any one else who has been a mathematician in the same sense which I have been one, is this: that I have added something to knowledge, and helped others to add more; and that these somethings have a value which differs in degree only, and not in kind, from that of the creations of the great mathematicians, or of any of the other artists, great or small, who have left some kind of memorial behind them.
– A Mathematician’s Apology, G. H. Hardy


每个人都是混账、坏蛋,只有耶稣基督除外。爱因斯坦也是个坏蛋,因为在原子弹被引爆之后,他并没有离开美国,尽管他曾极力反对使用原子弹。
最终,通过事物之间的普遍联系,一个人会以这样或那样的方式,在深浅不等的程度上与世界上发生的所有事物都扯上干系。如果一个人可以对任何一个事件施加任何影响,那么他就要为此承担责任。(亚历山德罗夫)

A. D. Aleksandrov in 1954

Everyone is a bastard, everyone is bad, with the possible exception of Jesus Christ. Einstein is bad too, because he did not leave America after the nuclear bomb was detonated over his objections.In the end, through the general interconnectedness of events, a person becomes, in some way or another, to a greater or lesser extent, party to everything that happens in the world, and if he can exert any influence whatsoever on any event, then he becomes responsible for it.
Aleksandr Danilovich Aleksandrov

How Terence Tao learn Javascript and gamify logic

QED - an interactive textbook


Terence Tao

Terence Tao is a starlike mathematician of our time. he is also a geek mathematician.


Repository for the QED interactive text and possible extensions
https://github.com/teorth/QED


Gamifying propositional logic: QED, an interactive textbook

It took a while for me to come up with a workable game-like graphical interface for all of this, but I finally managed to set one up, now using Javascript instead of Scratch (which would be hopelessly inadequate for this task); indeed, part of the motivation of this project was to finally learn how to program in Javascript, which turned out to be not as formidable as I had feared (certainly having experience with other C-like languages like C++, Java, or lua, as well as some prior knowledge of HTML, was very helpful).

QED version 2.0: an interactive text in first-order logic

I feel though that there could be more that could be done with this sort of framework (e.g., improved GUI, modification to other logics, developing the ability to write one’s own texts and libraries, exploring mathematical theories such as Peano arithmetic, etc.). But writing this text (particularly the first-order logic sections) has brought me close to the limit of my programming ability, as the number of bugs introduced with each new feature implemented has begun to grow at an alarming rate. I would like to repackage the code so that it can be re-used by more adept programmers for further possible applications, though I have never done something like this before and would appreciate advice on how to do so.

LeetCode - Algorithms - 210. Course Schedule II

only when I combined two man’s solutions did it pass on Leetcode.

Problem

210. Course Schedule II

topological sort of DAG.

Java

DFS

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;

class Solution {
public int[] findOrder(int numCourses, int[][] prerequisites) {
int[] tp = new int[numCourses];

List<Edge> edges = new ArrayList<Edge>();
for(int i=0; i<prerequisites.length; i++) {
edges.add(new Edge(prerequisites[i][0],prerequisites[i][1]));
}
Graph graph = new Graph(edges, numCourses);

if (!isDAG(graph, numCourses))
return new int[]{};

List<Integer> tplist = new ArrayList<Integer>();
Stack<Integer> stack = new Stack<Integer>();

boolean visited[] = new boolean[numCourses];
for (int i = 0; i < numCourses; i++)
visited[i] = false;

for (int i = 0; i < numCourses; i++)
if (visited[i] == false)
topologicalSortUtil(i, visited, stack, graph);
while (stack.empty() == false)
tplist.add( stack.pop() );

Collections.reverse(tplist);
for(int i=0; i<tplist.size();i++)
tp[i] = tplist.get(i);

return tp;
}

void topologicalSortUtil(int v, boolean visited[], Stack<Integer> stack, Graph graph) {
visited[v] = true;
Integer i;
Iterator<Integer> it = graph.adjList.get(v).iterator();
while (it.hasNext()) {
i = it.next();
if (!visited[i])
topologicalSortUtil(i, visited, stack, graph);
}
stack.push(new Integer(v));
}

public boolean isDAG(Graph graph, int N) {
boolean[] discovered = new boolean[N];

int[] departure = new int[N];

int time = 0;

for (int i = 0; i < N; i++)
if (discovered[i] == false)
time = DFS(graph, i, discovered, departure, time);

for (int u = 0; u < N; u++) {
for (int v : graph.adjList.get(u)) {
if (departure[u] <= departure[v])
return false;
}
}

return true;
}

private int DFS(Graph graph, int v, boolean[] discovered, int[] departure, int time) {
discovered[v] = true;

for (int u : graph.adjList.get(v)) {
if (!discovered[u])
time = DFS(graph, u, discovered, departure, time);
}

departure[v] = time++;

return time;
}
}

class Edge {
int source, dest;

public Edge(int source, int dest) {
this.source = source;
this.dest = dest;
}

}

public class Graph {
List<List<Integer>> adjList = null;

Graph(List<Edge> edges, int N) {
adjList = new ArrayList<>(N);

for (int i = 0; i < N; i++) {
adjList.add(i, new ArrayList<>());
}

for (Edge edge : edges) {
adjList.get(edge.source).add(edge.dest);
}
}

}

Submission Detail

  • 44 / 44 test cases passed.
  • Runtime: 9 ms, faster than 37.80% of Java online submissions for Course Schedule II.
  • Memory Usage: 39.7 MB, less than 98.78% of Java online submissions for Course Schedule II.

ref

LeetCode - Algorithms - 207. Course Schedule

my exercises is to find solutions which can help me to understand these puzzle algorithms.

Problem

207. Course Schedule

scheduling problem with precedence constraints.

key

  • DAG: a digraph with no directed cycles.
  • A digraph has a topological order if and only if it is a DAG.
  • Is a given digraph a DAG ?
  • Depth-first search

Java

DFS

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class Solution {
public boolean canFinish(int numCourses, int[][] prerequisites) {
List<Edge> edges = new ArrayList<Edge>();
for(int i=0; i<prerequisites.length; i++) {
edges.add(new Edge(prerequisites[i][0],prerequisites[i][1]));
}
Graph graph = new Graph(edges, numCourses);
return isDAG(graph, numCourses);
}

private boolean isDAG(Graph graph, int N) {
boolean[] discovered = new boolean[N];

int[] departure = new int[N];

int time = 0;

for (int i = 0; i < N; i++)
if (discovered[i] == false)
time = DFS(graph, i, discovered, departure, time);

for (int u = 0; u < N; u++) {
for (int v : graph.adjList.get(u)) {
if (departure[u] <= departure[v])
return false;
}
}
return true;
}

private int DFS(Graph graph, int v, boolean[] discovered, int[] departure, int time) {
discovered[v] = true;

for (int u : graph.adjList.get(v)) {
if (!discovered[u])
time = DFS(graph, u, discovered, departure, time);
}

departure[v] = time++;

return time;
}
}

class Edge {
int source, dest;

public Edge(int source, int dest) {
this.source = source;
this.dest = dest;
}
}

class Graph {
List<List<Integer>> adjList = null;

Graph(List<Edge> edges, int N) {
adjList = new ArrayList<>(N);

for (int i = 0; i < N; i++) {
adjList.add(i, new ArrayList<>());
}

for (Edge edge : edges) {
adjList.get(edge.source).add(edge.dest);
}
}
}

Submission Detail

  • 42 / 42 test cases passed.
  • Runtime: 5 ms, faster than 69.31% of Java online submissions for Course Schedule.
  • Memory Usage: 44.6 MB, less than 94.62% of Java online submissions for Course Schedule.

ref

LeetCode - Algorithms - 77. Combinations

just run code of others.

Problem

77. Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 … n.

Java

Iterative Algorithm

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<List<Integer>> combine(int n, int k) {
List<List<Integer>> combinations = new ArrayList<List<Integer>>();

int[] combination = new int[k];
for (int i = 0; i < k; i++) {
combination[i] = i;
}

while (combination[k - 1] < n) {
List<Integer> comblist = new ArrayList<Integer>();
for(int i=0; i<combination.length; i++) {
comblist.add(combination[i]+1);
}
combinations.add(comblist);
int t = k - 1;
while (t != 0 && combination[t] == n - k + t) {
t--;
}
combination[t]++;
for (int i = t + 1; i < k; i++) {
combination[i] = combination[i - 1] + 1;
}
}

return combinations;
}
}

Submission Detail

  • 27 / 27 test cases passed.
  • Runtime: 3 ms, faster than 88.15% of Java online submissions for Combinations.
  • Memory Usage: 39.7 MB, less than 80.43% of Java online submissions for Combinations.

ref

LeetCode - Algorithms - 46. Permutations

just verify code of other peer.

Problem

46. Permutations

Given a collection of distinct integers, return all possible permutations.

Java

BASIC ALGORITHM 1: REMOVE

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
import java.util.ArrayList;
import java.util.List;

class Solution {
public List<List<Integer>> permute(int[] nums) {
List<List<Integer>> list = new ArrayList<List<Integer>>();
permutation_remove(nums,nums.length,list);
return list;
}

private void permutation_remove(int[] a, int n, List<List<Integer>> list) {
if (n == 1) {
List<Integer> x = new ArrayList<Integer>();
for(int i=0;i<a.length;i++)
x.add(new Integer(a[i]));
list.add(x);
return;
}
for (int i = 0; i < n; i++) {
swap(a, i, n - 1);
permutation_remove(a, n - 1, list);
swap(a, i, n - 1);
}
}

private void swap(int[] a, int i, int j) {
int t = a[i];
a[i] = a[j];
a[j] = t;
}
}

Submission Detail

  • 25 / 25 test cases passed.
  • Runtime: 1 ms, faster than 97.52% of Java online submissions for Permutations.
  • Memory Usage: 38 MB, less than 82.98% of Java online submissions for Permutations.

HEAP’S ALGORITHM

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
import java.util.ArrayList;
import java.util.List;

class Solution {
public List<List<Integer>> permute(int[] nums) {
List<List<Integer>> list = new ArrayList<List<Integer>>();
permutation_heaps(nums,nums.length,list);
return list;
}

private void permutation_heaps(int[] a, int n, List<List<Integer>> list) {
if (n == 1) {
List<Integer> x = new ArrayList<Integer>();
for(int i=0;i<a.length;i++)
x.add(new Integer(a[i]));
list.add(x);
return;
}
for (int i = 0; i < (n - 1); i++) {
permutation_heaps(a, n - 1, list);
if (n % 2 == 0)
swap(a, n - 1, i);
else
swap(a, n - 1, 0);
}
permutation_heaps(a, n - 1, list);
}

private void swap(int[] a, int i, int j) {
int t = a[i];
a[i] = a[j];
a[j] = t;
}
}

Submission Detail

  • 25 / 25 test cases passed.
  • Runtime: 1 ms, faster than 97.52% of Java online submissions for Permutations.
  • Memory Usage: 36.3 MB, less than 98.58% of Java online submissions for Permutations.

ref

LeetCode - Algorithms - 49. Group Anagrams

Problem

49. Group Anagrams

Given an array of strings, group anagrams together.

JavaScript

solution by Joan Indiana Lyness

Algorithms 101: Group Anagrams in JavaScript

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
* @param {string[]} strs
* @return {string[][]}
*/
var groupAnagrams = function(strs) {
var m = {};
for(var i=0;i<strs.length;i++) {
var s = strs[i];
var c = s.split("").sort();
m[c]?m[c].push(s):m[c]=[s];
}
var r = [];
var keys = Object.keys(m);
for(var k=0; k<keys.length; k++) {
r.push( m[keys[k]] );
}
return r;
};

Submission Detail

  • 101 / 101 test cases passed.
  • Runtime: 144 ms, faster than 32.01% of JavaScript online submissions for Group Anagrams.
  • Memory Usage: 45.6 MB, less than 34.78% of JavaScript online submissions for Group Anagrams.

Java

translation from solution of Joan Indiana Lyness

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
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Arrays;

class Solution {
public List<List<String>> groupAnagrams(String[] strs) {
List<List<String>> list = new ArrayList<List<String>>();
Map<String, List<String>> map = new HashMap<String, List<String>>();
String s;
char[] c;
String key;
for (int i = 0; i < strs.length; i++) {
s = strs[i];
c = s.toCharArray();
Arrays.sort(c);
key = new String(c);
if (map.containsKey(key)) {
map.get(key).add(s);
} else {
List<String> glist = new ArrayList<String>();
glist.add(s);
map.put(key, glist);
}
}

list.addAll(map.values());
return list;
}
}

Submission Detail

  • 101 / 101 test cases passed.
  • Runtime: 9 ms, faster than 83.05% of Java online submissions for Group Anagrams.
  • Memory Usage: 40.8 MB, less than 96.49% of Java online submissions for Group Anagrams.

ref

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.