Created
May 26, 2019 00:06
-
-
Save HamsterofDeath/bb1af86981d72cf10f7b13b6a75e1d9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.lang.Character.digit | |
| import kotlin.math.roundToInt | |
| object N19 { | |
| @JvmStatic | |
| fun main(args: Array<String>) { | |
| fun rand() = (Math.random() * 1000000).roundToInt() | |
| val seq = generateSequence { rand() } | |
| val samples = seq.take(10000) | |
| println(samples.count { it % 19 == 0 }) | |
| } | |
| } | |
| object WordCounts { | |
| val sample = | |
| " To Kill a Mockingbird, Harper Lee – 100,388 words\n" + | |
| " Gullivers Travels, Jonathan Swift – 107,349 words\n" + | |
| " Wuthering Heights, Emily Bronte – 107,945 words\n" + | |
| " The Adventures of Huckleberry Finn, Mark Twain – 109,571 words\n" + | |
| " As I Lay Dying, William Faulkner – 56,695 words\n" + | |
| " Lord of the Flies, William Golding – 59,900 words\n" + | |
| " Mrs Dalloway, Virginia Wolf – 63,422 words\n" + | |
| " Black Beauty, Anna Sewell – 59,635 words\n" + | |
| " The Colour Purple, Alice Walker – 66,556 words\n" + | |
| " Treasure Island, Robert Louis Stevenson – 66,950 words\n" + | |
| " The Sun Also Rises, Ernest Hemingway – 67,707 words\n" + | |
| " The Picture of Dorian Gray, Oscar Wilde – 78,462 words\n" + | |
| " Ulysses, James Joyce – 265,222 words\n" + | |
| " Bleak House, Charles Dickens – 360,947 words\n" + | |
| " Great Expectations, Charles Dickens – 183,349 words\n" + | |
| " Les Miserables, Victor Hugo – 530,982 words\n" + | |
| " War and Peace, Leo Tolstoy – 561,304 words\n" + | |
| " Anna Karenina, Leo Tolstoy – 349,736 words\n" + | |
| " Gone with the Wind, Margaret Mitchell – 418,053 words\n" + | |
| " Moby Dick, Herman Melville – 206,052 words\n" + | |
| " For Whom the Bell Tolls, Ernest Hemingway – 174,106 words\n" + | |
| " Memoirs of a Geisha, Arthur Golden – 186,418 words\n" + | |
| " Jane Eyre, Charlotte Brontë – 183,858 words\n" + | |
| " Catch-22, Joseph Heller – 174,269 words\n" + | |
| " Sense and Sensibility, Jane Austen – 126,194 words\n" + | |
| " Atonement, Ian McEwan – 123,378 words\n" + | |
| " Lonesome Dove, Larry McMurtry – 365,712 words\n" + | |
| " Atlas Shrugged, Ayn Rand – 561,996 words\n" + | |
| " Crime and Punishment, Fyodor Dostoyevsky – 211,591 words\n" + | |
| " The Grapes of Wrath, John Steinbeck – 169,481 words\n" + | |
| " One Hundred Years of Solitude, Gabriel Garcia Marquez – 144,523 words\n" + | |
| " Jonathan Strange & Mr Norrell, Susanna Clarke – 308,931 words\n" + | |
| " American Gods, Neil Gaiman – 183,222 words\n" + | |
| " The Colour of Magic, Terry Pratchett – 65,113 words\n" + | |
| " Eragon, Christopher Paolini – 157,000 words\n" + | |
| " A Wizard of Earthsea – 56,533 words\n" + | |
| " The Tombs of Atuan – 45,939 words\n" + | |
| " The Farthest Shore – 60,591 words\n" + | |
| " Tehanu – 99,200 words\n" + | |
| " Tales from Earthsea – 128,960 words\n" + | |
| " The Other Wind – 89,280 words\n" + | |
| " A Game of Thrones – 298,000 words\n" + | |
| " A Clash of Kings – 326,000 words\n" + | |
| " A Storm of Swords – 424,000 words\n" + | |
| " A Feast for Crows – 300,000 words\n" + | |
| " A Dance with Dragons – 422,000 words\n" + | |
| " The entire A Song of Ice and Fire series (so far) – 1,770,000 words\n" + | |
| " The Hobbit – 95,356 words\n" + | |
| " The Fellowship of the Ring – 187,790 words\n" + | |
| " The Two Towers – 156,198 words\n" + | |
| " The Return of the King – 137,115 words\n" + | |
| " The entire Lord of the Rings series (including The Hobbit) – 576,459 words\n" + | |
| " Harry Potter and the Philosopher’s Stone – 76,944 words\n" + | |
| " Harry Potter and the Chamber of Secrets – 85,141 words\n" + | |
| " Harry Potter and the Prisoner of Azkaban – 107,253 words\n" + | |
| " Harry Potter and the Goblet of Fire – 190,637 words\n" + | |
| " Harry Potter and the Order f the Phoenix – 257,045 words\n" + | |
| " Harry Potter and the Half-Blood Prince – 168,923 words\n" + | |
| " Harry Potter and the Deathly Hallows – 198,227 words\n" + | |
| " The entire Harry Potter series – 1,084,170 words\n" + | |
| " The Golden Compass – 112,815 words\n" + | |
| " The Subtle Knife – 109,120 words\n" + | |
| " The Amber Spyglass – 168,640 words\n" + | |
| " The Lion, The Witch, and the Wardrobe – 38,421 words\n" + | |
| " Prince Caspian – 46,290 words\n" + | |
| " The Voyage of the Dawn Treader – 53,960 words\n" + | |
| " The Silver Chair – 51,022 words\n" + | |
| " The Horse and His Boy – 48,029 words\n" + | |
| " The Magician’s Nephew – 64,480 words\n" + | |
| " The Last Battle – 43,333 words\n" + | |
| " The Time Traveller’s Wife, Audrey Niffenegger – 155,717 words\n" + | |
| " Fahrenheit 451, Ray Bradbury – 46,118 words\n" + | |
| " The Martian Chronicles, Ray Bradbury – 64,768 words\n" + | |
| " Brave New World, Aldous Huxley – 63,766 words\n" + | |
| " War of the Worlds, G. Well – 59,796 words\n" + | |
| " The Time Machine, G. Well – 32,149 words\n" + | |
| " Nineteen Eight-Four, George Orwell – 88,942 words\n" + | |
| " Dune, Frank Herbert – 187,240 words\n" + | |
| " The Left Hand of Darkness, Ursula K. Le Guin – 94,240 words\n" + | |
| " Do Androids Dream of Electric Sheep, Phillip K. Dick – 79,360 words\n" + | |
| " Frankenstein, Mary Shelley – 74,800 words\n" | |
| @JvmStatic | |
| fun main(args: Array<String>) { | |
| var divine = 0 | |
| var humanMade = 0 | |
| sample.lines().filter { str -> str.trim().isNotEmpty() } | |
| .forEach { line -> | |
| val dropUntil = line.lastIndexOf('–') | |
| val words = line.drop(dropUntil).filter(Character::isDigit).toInt() | |
| val match = words % 19 == 0 | |
| if (match) { | |
| divine += 1 | |
| } else { | |
| humanMade += 1 | |
| } | |
| println("$line -> $words -> mod19 -> $match") | |
| } | |
| println("$divine / $humanMade") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment