diff --git a/ipynb/Fred Buns.ipynb b/ipynb/Fred Buns.ipynb index 47ed555..7bf374d 100644 --- a/ipynb/Fred Buns.ipynb +++ b/ipynb/Fred Buns.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
Peter Norvig, 15 June 2015
" + "
Peter Norvig, 15 June 2015
" ] }, { @@ -50,9 +50,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "from __future__ import division, print_function # To work in Python 2.x or 3.x\n", @@ -75,9 +73,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "fredbuns = ['FB', 'RU', 'EN', 'DS'] # A lock with two letters on each of four tumblers" @@ -93,9 +89,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -137,9 +131,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "def combinations(lock):\n", @@ -150,9 +142,7 @@ { "cell_type": "code", "execution_count": 5, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -197,9 +187,7 @@ { "cell_type": "code", "execution_count": 6, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "! [ -e words4.txt ] || curl -O http://norvig.com/ngrams/words4.txt" @@ -215,9 +203,7 @@ { "cell_type": "code", "execution_count": 7, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -250,9 +236,7 @@ { "cell_type": "code", "execution_count": 8, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "WORDS = set(open('words4.txt').read().split())" @@ -261,9 +245,7 @@ { "cell_type": "code", "execution_count": 9, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -290,9 +272,7 @@ { "cell_type": "code", "execution_count": 10, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "def words_from(lock): \n", @@ -303,9 +283,7 @@ { "cell_type": "code", "execution_count": 11, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -332,9 +310,7 @@ { "cell_type": "code", "execution_count": 12, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "def show(lock):\n", @@ -349,9 +325,7 @@ { "cell_type": "code", "execution_count": 13, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -391,9 +365,7 @@ { "cell_type": "code", "execution_count": 14, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "wordlock = ['SPHMTWDLFB', 'LEYHNRUOAI', 'ENMLRTAOSK', 'DSNMPYLKTE']" @@ -402,9 +374,7 @@ { "cell_type": "code", "execution_count": 15, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -451,9 +421,7 @@ { "cell_type": "code", "execution_count": 16, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "def random_lock(t=4, c=10, seed='seed'):\n", @@ -468,9 +436,7 @@ { "cell_type": "code", "execution_count": 17, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -496,9 +462,7 @@ { "cell_type": "code", "execution_count": 18, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "def word_count(lock): return len(words_from(lock))" @@ -507,9 +471,7 @@ { "cell_type": "code", "execution_count": 19, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -551,9 +513,7 @@ { "cell_type": "code", "execution_count": 20, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -591,9 +551,7 @@ { "cell_type": "code", "execution_count": 21, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -624,9 +582,7 @@ { "cell_type": "code", "execution_count": 22, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "def greedy_lock(t=4, c=10, words=WORDS):\n", @@ -645,9 +601,7 @@ { "cell_type": "code", "execution_count": 23, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -695,9 +649,7 @@ { "cell_type": "code", "execution_count": 24, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "def improved_lock(lock, steps=3000):\n", @@ -730,9 +682,7 @@ { "cell_type": "code", "execution_count": 25, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -758,16 +708,14 @@ { "cell_type": "code", "execution_count": 26, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 6min 50s, sys: 1.44 s, total: 6min 51s\n", - "Wall time: 6min 53s\n" + "CPU times: user 4min 54s, sys: 1.68 s, total: 4min 56s\n", + "Wall time: 4min 59s\n" ] } ], @@ -785,9 +733,7 @@ { "cell_type": "code", "execution_count": 27, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -815,9 +761,7 @@ { "cell_type": "code", "execution_count": 28, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "def alock(lock):\n", @@ -834,10 +778,8 @@ }, { "cell_type": "code", - "execution_count": 47, - "metadata": { - "collapsed": false - }, + "execution_count": 29, + "metadata": {}, "outputs": [ { "data": { @@ -853,7 +795,7 @@ " ('BCDLMPRSTW', 'AEHILORUWY', 'ACEILNORST', 'ADEHKLNSTY'): 1237}" ] }, - "execution_count": 47, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -876,10 +818,8 @@ }, { "cell_type": "code", - "execution_count": 48, - "metadata": { - "collapsed": false - }, + "execution_count": 30, + "metadata": {}, "outputs": [ { "data": { @@ -888,7 +828,7 @@ " ('BCDFLMPSTW', 'AEHILORUWY', 'ACEILNORST', 'ADEHKLNSTY')}" ] }, - "execution_count": 48, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -926,10 +866,8 @@ }, { "cell_type": "code", - "execution_count": 49, - "metadata": { - "collapsed": false - }, + "execution_count": 31, + "metadata": {}, "outputs": [], "source": [ "def transpose(strings): return [Word(letters) for letters in zip(*strings)]" @@ -944,10 +882,8 @@ }, { "cell_type": "code", - "execution_count": 50, - "metadata": { - "collapsed": false - }, + "execution_count": 32, + "metadata": {}, "outputs": [ { "data": { @@ -964,7 +900,7 @@ " 'BIKE']" ] }, - "execution_count": 50, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -996,10 +932,8 @@ }, { "cell_type": "code", - "execution_count": 51, - "metadata": { - "collapsed": false - }, + "execution_count": 33, + "metadata": {}, "outputs": [], "source": [ "def improved_wordlist(wordlist):\n", @@ -1041,27 +975,25 @@ }, { "cell_type": "code", - "execution_count": 52, - "metadata": { - "collapsed": false - }, + "execution_count": 34, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['RAID',\n", - " 'ANSH',\n", - " 'OYER',\n", - " 'UPON',\n", - " 'KUDU',\n", - " 'GLUM',\n", - " 'JIMP',\n", - " 'IFFY',\n", - " 'NEVE',\n", - " 'FOAL']" + "['HWAN',\n", + " 'GETA',\n", + " 'LOCI',\n", + " 'FIRS',\n", + " 'TYNE',\n", + " 'SAIF',\n", + " 'ELMY',\n", + " 'AVER',\n", + " 'DUSK',\n", + " 'PROG']" ] }, - "execution_count": 52, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -1079,28 +1011,26 @@ }, { "cell_type": "code", - "execution_count": 53, - "metadata": { - "collapsed": false - }, + "execution_count": 35, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['AMAH',\n", - " 'HARM',\n", - " 'UPDO',\n", - " 'LIVE',\n", - " 'GWEN',\n", - " 'FELT',\n", - " 'MUFF',\n", - " 'ROTI',\n", - " 'SCUP',\n", - " 'EDGY',\n", - " 'BROS']" + "['LIDO',\n", + " 'GLIB',\n", + " 'HERS',\n", + " 'IDOL',\n", + " 'CHEW',\n", + " 'JUKU',\n", + " 'ARYA',\n", + " 'POUT',\n", + " 'RAGE',\n", + " 'ONLY',\n", + " 'SPAR']" ] }, - "execution_count": 53, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -1137,10 +1067,8 @@ }, { "cell_type": "code", - "execution_count": 54, - "metadata": { - "collapsed": false - }, + "execution_count": 36, + "metadata": {}, "outputs": [], "source": [ "def improved(item, changed, scorer, extremum, stop):\n", @@ -1165,10 +1093,8 @@ }, { "cell_type": "code", - "execution_count": 55, - "metadata": { - "collapsed": false - }, + "execution_count": 37, + "metadata": {}, "outputs": [], "source": [ "def improved_lock(lock, steps=3000):\n", @@ -1184,10 +1110,8 @@ }, { "cell_type": "code", - "execution_count": 56, - "metadata": { - "collapsed": false - }, + "execution_count": 38, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -1205,27 +1129,25 @@ }, { "cell_type": "code", - "execution_count": 57, - "metadata": { - "collapsed": false - }, + "execution_count": 39, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['TUBA',\n", - " 'PROF',\n", - " 'AXAL',\n", - " 'SCUD',\n", - " 'YAWN',\n", - " 'FLEY',\n", - " 'EGGS',\n", - " 'BILK',\n", - " 'CHIT',\n", - " 'LEHR']" + "['NICK',\n", + " 'HEED',\n", + " 'DOTH',\n", + " 'GRIP',\n", + " 'KHAF',\n", + " 'ELMY',\n", + " 'FURS',\n", + " 'ICON',\n", + " 'UNBE',\n", + " 'CALO']" ] }, - "execution_count": 57, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -1255,10 +1177,8 @@ }, { "cell_type": "code", - "execution_count": 58, - "metadata": { - "collapsed": false - }, + "execution_count": 40, + "metadata": {}, "outputs": [], "source": [ "def greedy_lock_patented(t=4, c=10, words=WORDS):\n", @@ -1276,10 +1196,8 @@ }, { "cell_type": "code", - "execution_count": 59, - "metadata": { - "collapsed": false - }, + "execution_count": 41, + "metadata": {}, "outputs": [ { "data": { @@ -1287,7 +1205,7 @@ "1177" ] }, - "execution_count": 59, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -1298,10 +1216,8 @@ }, { "cell_type": "code", - "execution_count": 60, - "metadata": { - "collapsed": false - }, + "execution_count": 42, + "metadata": {}, "outputs": [ { "data": { @@ -1309,7 +1225,7 @@ "1161" ] }, - "execution_count": 60, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -1335,10 +1251,8 @@ }, { "cell_type": "code", - "execution_count": 61, - "metadata": { - "collapsed": false - }, + "execution_count": 43, + "metadata": {}, "outputs": [ { "data": { @@ -1346,7 +1260,7 @@ "'pass'" ] }, - "execution_count": 61, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -1380,6 +1294,39 @@ "tests()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Addendum: 2018\n", + "\n", + "New [research](https://www.theverge.com/2018/10/7/17940352/turing-test-one-word-minimal-human-ai-machine-poop) suggests that the one word that humans are most likely to think was generated by another human rather than by a machine is *\"poop\"*. Is it a coincidence that the same week this research came out, I was in a bike shop and saw the following:\n", + "\n", + "![](like.jpg)\n", + "\n", + "This proves that I'm not the only one with a juvenile reaction to the *WordLock*®, but it raises some questions: Was the last visitor to the store a human asserting their individuality? Or a robot yearning to be free? Or [Triumph the insult comic dog](https://en.wikipedia.org/wiki/Triumph_the_Insult_Comic_Dog)? I guess we'll never know." + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "'POOP' in WORDS" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -1396,10 +1343,8 @@ }, { "cell_type": "code", - "execution_count": 62, - "metadata": { - "collapsed": false - }, + "execution_count": 45, + "metadata": {}, "outputs": [ { "data": { @@ -1407,7 +1352,7 @@ "{7, 15, 23, 28, 31, 39, 47, 55, 60, 63, 71, 79, 87, 92, 95}" ] }, - "execution_count": 62, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } @@ -1436,9 +1381,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.0" + "version": "3.5.3" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/ipynb/like.jpg b/ipynb/like.jpg new file mode 100644 index 0000000..8d2c508 Binary files /dev/null and b/ipynb/like.jpg differ