Iterating over permutations, part 3 – Steinhaus-Johnson-Trotter algorithm

We talked about Nariyana Pandita’s method for iterating over permutations in 1300s India, and also B. R. Heale’s completely different algorithm from 1963 Britain.

Yet a third, also completely different, algorithm was discovered by American mathematician Hale Trotter in 1962, and, independently, American mathematician Selmer Johnson in 1963. This is called the Steinhaus–Johnson–Trotter algorithm. I have a PowerShell implementation of this too.

The key concept is to assign each element in the permutation a direction – either left or right. Use < to indicate that the element is looking left, and > to indicate that the element is looking right.

Example: <A <B <C <D

Then the algorithm is follows:

  1. Start with the permutation in ascending order. All elements start looking left.
  2. Define a mobile element as one which is larger than the element it is looking at.
  3. Find the largest mobile element x. (If no elements are mobile, then you are done iterating.)
  4. Swap x with the element it is looking it. This is the next permutation.
  5. Reverse the direction for all elements greater than x.
  6. Repeat steps 2 through 5 until step 3 fails.

Working through the example:

  • <A <B <C <D – move D to the left
  • <A <B <D <C – move D to the left
  • <A <D <B <C – move D to the left
  • <D <A <B <C – move C to the left and reverse direction of D
  • D> <A <C <B – move D to the right
  • <A D> <C <B – move D to the right
  • <A <C D> <B – move D to the right
  • <A <C <B D> – move C to the left and reverse direction of D
  • <C <A <B <D – move D to the left
  • <C <A <D <B – move D to the left
  • <C <D <A <B – move D to the left
  • <D <C <A <B – move B to the left and reverse direction of C and D
  • D> C> <B <A – move D to the right
  • C> D> <B <A – move D to the right
  • C> <B D> <A – move D to the right
  • C> <B <A D> – move C to the right and reverse direction of D
  • <B C> <A <D – move D to the left
  • <B C> <D <A – move D to the left
  • <B <D C> <A – move D to the left
  • <D <B C> <A – move C to the right and reverse direction of C
  • D> <B <A C> – move D to the right
  • <B D> <A C> – move D to the right
  • <B <A D> C> – move D to the right
  • <B <A C> D> – no mobile elements, we’re done

Note that the largest element (in this case, D) goes back and forth, bouncing off of the ends of the permutation.

So (n – 1)/n of the time, the next permutation can be found very quickly (in constant time) by just keeping track of the largest element.

The other 1/n of the time, the largest element is stuck, and a scan is necessary to find the largest mobile element (or lack thereof,) and then to reverse the direction of larger elements. This takes time proportional to n and unsticks the largest element again.

So on average it takes constant time to find the next permutation: O(1) + (O(n)/n) = O(1).

Iterating over permutations, part 2 – Heap’s algorithm

Last time we talked about how Nariyana Pandita iterated over permutations in India in the 1300s. Also see Iterating over permutations, part 3 – Steinhaus-Johnson-Trotter algorithm.

600 years later, in 1963, B. R. Heap showed a completely different way to do it. Heap’s algorithm (original paper, PDF) takes a divide-and-conquer approach. I have a PowerShell implementation of this too.

Example: A B C D E F G

  1. First set up an outer loop. This loop controls the last place in the permutation and cycles all of the elements through it in turn:
    • ? ? ? ? ? ? G
    • ? ? ? ? ? ? D
    • ? ? ? ? ? ? C
    • ? ? ? ? ? ? B
    • ? ? ? ? ? ? E
    • ? ? ? ? ? ? F
    • ? ? ? ? ? ? A
  2. Then set up a second loop inside the first one. This loop controls the next-to-last place in the permutation. Note that this loop iterates one fewer time than the outer loop.
    • ? ? ? ? ? F G
    • ? ? ? ? ? E G
    • ? ? ? ? ? B G
    • ? ? ? ? ? C G
    • ? ? ? ? ? D G
    • ? ? ? ? ? A G
  3. Then set up a third loop inside the second one
  4. And fourth loop inside that

… and so on until every place in the permutation has a loop. Have the innermost loop print the permutation or do what ever operation on it is desired.

All the loops work in the same way. Consider the loop that controls the kth place in the permutation. Call the preceding (k – 1) places the prefix.

Some examples:

  • k = 6: A B C D E F G
  • k = 5: A B C D E F G

If the length of the prefix (k – 1) is odd, then the loop swaps elements as follows:

  1. At the end of the first iteration, swap the first element in the prefix into the controlled place
  2. At the end of the second iteration, swap the second element in the prefix into the controlled place
  3. At the end of the (k – 1)th iteration, swap the (k – 1)th element in the prefix into the controlled place

Note that every element in the prefix takes its turn in the controlled place.

If the length of the prefix (k – 1) is even, then the shuffling of the prefix by the inner loops is more fortuitous, and the loop’s swapping logic is simpler:

  • At the end of every iteration, swap the first element in the prefix into the controlled place

This is easier to see in action. Here are three loops k = 2, k = 3, and k = 4 working together:

  • k = 4, first iteration begins
    A B C D E F G
    • k = 3, first iteration begins
      A B C D E F G
      • k = 2, first iteration begins
        A B C D E F G
      • k = 2, swap the first and second elements, second iteration begins
        B A C D E F G
    • k = 3, swap the first and third elements, second iteration begins
      C A B D E F G
      • k = 2, first iteration begins
        C A B D E F G
      • k = 2, swap the first and second elements, second iteration begins
        A C B D E F G
    • k = 3, swap the first and third elements (again), third iteration begins
      B C A D E F G
      • k = 2, first iteration begins
        B C A D E F G
      • k = 2, swap the first and second elements, second iteration begins
        C B A D E F G
  • k = 4 – swap the first and fourth elements, second iteration begins
    D B A C E F G
    • k = 3, first iteration begins
      D B A C E F G
      • k = 2, first iteration begins
        D B A C E F G
      • k = 2, swap the first and second elements, second iteration begins
        B D A C E F G
    • k = 3, swap the first and third elements, second iteration begins
      A D B C E F G
      • k = 2, first iteration begins
        A D B C E F G
      • k = 2, swap the first and second elements, second iteration begins
        D A B C E F G
    • k = 3, swap the first and third elements (again), third iteration begins
      B A D C E F G
      • k = 2, first iteration begins
        B A D C E F G
      • k = 2, swap the first and second elements, second iteration begins
        A B D C E F G
  • k = 4 – swap the second and fourth elements, third iteration begins
    A C D B E F G
    • k = 3, first iteration begins
      A C D B E F G
      • k = 2, first iteration begins
        A C D B E F G
      • k = 2, swap the first and second elements, second iteration begins
        C A D B E F G
    • k = 3, swap the first and third elements, second iteration begins
      D A C B E F G
      • k = 2, first iteration begins
        D A C B E F G
      • k = 2, swap the first and second elements, second iteration begins
        A D C B E F G
    • k = 3, swap the first and third elements (again), third iteration begins
      C D A B E F G
      • k = 2, first iteration begins
        C D A B E F G
      • k = 2, swap the first and second elements, second iteration begins
        D C A B E F G
  • k = 4 – swap the third and fourth element, fourth iteration begins
    D C B A E F G
    • k = 3, first iteration begins
      D C B A E F G
      • k = 2, first iteration begins
        D C B A E F G
      • k = 2, swap the first and second elements, second iteration begins
        C D B A E F G
    • k = 3, swap the first and third elements, second iteration begins
      B D C A E F G
      • k = 2, first iteration begins
        B D C A E F G
      • k = 2, swap the first and second elements, second iteration begins
        D B C A E F G
    • k = 3, swap the first and third elements (again), third iteration begins
      C B D A E F G
      • k = 2, first iteration begins
        C B D A E F G
      • k = 2, swap the first and second elements, second iteration begins
        B C D A E F G

Note that the k = 4 loop, which has an odd-length prefix, swaps first and fourth, second and fourth, third and fourth; but the k = 3 loop, which has an even-length prefix, swaps first and third, first and third. The k = 3 loop has less work to do, because the k = 2 loop moved a new element to the first place for it.

Iterating over permutations, part 1 – Nariyana Pandita method

It is often interesting to iterate over all permutations of an array. Consider the three letters N, O, W. There are six permutations, and three of them are English words:

  • NOW
  • NWO
  • ONW
  • OWN
  • WNO
  • WON

I found three different algorithms to iterate over permutations and implemented them all in PowerShell. Also see Iterating over permutations, part 2 – Heap’s algorithm and Iterating over permutations, part 3 – Steinhaus-Johnson-Trotter algorithm.

In India in the 1300s, mathematician Nariyana Pandita described a method to find the next permutation in alphabetical order, starting from a given permutation:

  1. Find the rightmost pair of elements that are in ascending order. (If the entire permutation is in descending order, there is no next permutation, and we’re done.) Call this the pivot. Notice that all of the elements from the second element in the pivot to the end of the permutation are in descending order. Call this the tail.
    Example: C B D G F E A
  2. Find the rightmost element in the tail that is larger than the first element of the pivot.
    Example: C B D G F E A
  3. Swap this element with the first element of the pivot. Note that the new tail is still in descending order.
    Example: C B E G F D A
  4. Put the tail in ascending order by reversing it.
    Example: C B E A D F G

The time this algorithm takes is proportional to the length of the tail. The tail could be as short as a single element, e. g. A B C D E F G => A B C D E G F. Or it could be as long as the whole permutation, minus one, e.g. A G F E D C B => B A C D E F G.

It turns out though that short tails are very, very common, and long tails are very, very, rare. In half of all permutations, the tail length is 1; in half of the remainder, the tail length is 2; in half of the remainder, the tail length is 3, etc. The exponential decay in the count of permutations outweighs the linear growth in the tail length so completely that, on average, you can find the next permutation in constant time (which is less time than it takes to print the result.)

Grabbing a dump file of another process via MiniDumpWriteDump

I was debugging a particular audio problem and I needed a process dump with full memory.

I used an internal gather-dumps tool and asked it to give me a bunch of dumps of the problem with full memory… and it gave me some dumps without full memory.

This told me that either the gather-dumps tool was broken, or MiniDumpWriteDump was broken, or perhaps both were working fine and my debugger was lying to me about the full-memory-ness of the dumps I was looking at.

To help narrow the problem down, I created a tool that is a very simple wrapper around MiniDumpWriteDump. This grabbed full memory dumps just fine, so I turned my attention toward the internal gather-dumps tool.


minidumpwritedump.exe [--help | -? | /?]
minidumpwritedump.exe --processId <processId> --dumpType <dumpType> --fileName <fileName>


EDIT 2020-06-30: added a PowerShell script to translate a MINIDUMP_TYPE number into a human-readable set of values


.\minidump_type.ps1 -minidump_type 482707
MiniDumpWithDataSegs, MiniDumpWithFullMemory, MiniDumpScanMemory, MiniDumpFilterModulePaths, MiniDumpWithProcessThreadData, MiniDumpWithoutOptionalData, MiniDumpWithFullMemoryInfo, MiniDumpWithThreadInfo, MiniDumpWithoutAuxiliaryState, MiniDumpWithPrivateWriteCopyMemory, MiniDumpIgnoreInaccessibleMemory, MiniDumpWithTokenInformation

President Trump tweets about the stock market

President Trump’s frequent tweets about the stock market inspired my post Some Dow Jones Industrial Average statistics, by United States President.

But he has tweeted so much since then that the list of tweets in that post has begun to overwhelm the main point of the post, which was the Dow Jones data.

So I have decided to split the tweets out into their own post. Here it is. If I missed any, please let me know in a comment below.

I grabbed the raw tweet data from and added some PowerShell scripts to to filter the list down to the relevant tweets and format them as HTML for easy posting.

  1. 2017-02-16: Stock market hits new high with longest winning streak in decades. Great level of confidence and optimism – even before tax plan rollout!
  2. 2017-02-23: ‘S&P 500 Edges Higher After Trump Renews Jobs Pledge’
  3. 2017-02-25: Great optimism for future of U.S. business, AND JOBS, with the DOW having an 11th straight record close. Big tax & regulation cuts coming!
  4. 2017-03-02: Since November 8th, Election Day, the Stock Market has posted $3.2 trillion in GAINS and consumer confidence is at a 15 year high. Jobs!
  5. 2017-03-14: JOBS, JOBS, JOBS! (Four Fox Business graphics, including “U. S. MARKETS FROM ELECTION DAY”)
  6. 2017-04-01: Thank you @JCLayfield — will get even better as my Administration continues to put #AmericaFirst🇺🇸 (video clip of Fox News: “CONSUMER CONFIDENCE AT 16-YR HIGH AS DOW SEES LONGEST QUARTERLY WINNING STREAK IN 10 YRS”)
  7. 2017-06-02: RT @foxandfriends: Wall Street hits record highs after Trump pulls out of Climate pact
  8. 2017-06-02: RT @EricTrump: #MakeAmericaGreatAgain!!! 🇺🇸🇺🇸 (video clip of Reuters Business: “Dow, S&P 500 and Nasdaq set record closing highs”)
  9. 2017-06-11: The #FakeNews MSM doesn’t report the great economic news since Election Day. #DOW up 16%. #NASDAQ up 19.5%. Drilling & energy sector…
  10. 2017-07-02: Stock Market at all time high, unemployment at lowest level in years (wages will start going up) and our base has never been stronger!
  11. 2017-07-03: Dow hit a new intraday all-time high! I wonder whether or not the Fake News Media will so report?
  12. 2017-07-03: RT @JacobAWohl: @realDonaldTrump When Obama was President, the #MSM LOVED talking about stock market rallies! Now they barely mention new a… (Retweet of account now suspended)
  13. 2017-07-12: Stock market hits another high with spirit and enthusiasm so positive. Jobs outlook looking very good! #MAGA🇺🇸
  14. 2017-07-15: Stock Market at new all-time high! Working on new trade deals that will be great for U.S. and its workers!
  15. 2017-07-15: Stock Market hit another all-time high yesterday – despite the Russian hoax story! Also, jobs numbers are starting to look very good!
  16. 2017-07-15: Just got to the #USWomensOpen in Bedminster, New Jersey. People are really happy with record high stock market – up over 17% since election!
  17. 2017-07-18: RT @FoxNews: U.S. Markets since election.
  18. 2017-07-23: Thank you to @LOUDOBBS for giving the first six months of the Trump Administration an A+. S.C.,reg cutting,Stock M, jobs,border etc. = TRUE!
  19. 2017-07-29: U.S. Stock Market up almost 20% since Election!
  20. 2017-07-31: Highest Stock Market EVER, best economic numbers in years, unemployment lowest in 17 years, wages raising, border secure, S.C.: No WH chaos!
  21. 2017-08-01: Stock Market could hit all-time high (again) 22,000 today. Was 18,000 only 6 months ago on Election Day. Mainstream media seldom mentions!
  22. 2017-08-03: Business is looking better than ever with business enthusiasm at record levels. Stock Market at an all-time high. That doesn’t just happen!
  23. 2017-08-06: MAKE AMERICA GREAT AGAIN! (Four Fox Business graphics, including “DOW HITS ALL-TIME HIGH”)
  24. 2017-08-07: …and West Virginia. The fact is the Fake News Russian collusion story, record Stock Market, border security, military strength, jobs…..
  25. 2017-08-16: RT @JacobAWohl: @realDonaldTrump President Trump alone has succeeded in bringing the Stock Market, Small Business Index and Consumer Comfor… (Retweet of account now suspended)
  26. 2017-09-01: Stock Market up 5 months in a row!
  27. 2017-09-16: A great deal of good things happening for our country. Jobs and Stock Market at all time highs, and I believe will be getting even better!
  28. 2017-09-29: RECORD HIGH FOR S & P 500!
  29. 2017-09-29: RT @Scavino45: Under POTUS’ @realDonaldTrump
    ☑️S&P 500 38th📈Record High
    ☑️NASDAQ 44th📈Record High
  30. 2017-10-05: Stock Market hits an ALL-TIME high! Unemployment lowest in 16 years! Business and manufacturing enthusiasm at highest level in decades!
  31. 2017-10-05: RT @FoxBusiness: #StockAlert: U.S. markets since the election (Fox Business graphic “MARKETS SINCE THE ELECTION”)
  32. 2017-10-09: RT @IvankaTrump: .@realDonaldTrump stock market rally is close to becoming the greatest in 85 years
  33. 2017-10-11: Stock Market has increased by 5.2 Trillion dollars since the election on November 8th, a 25% increase. Lowest unemployment in 16 years and..
  34. 2017-10-11: It would be really nice if the Fake News Media would report the virtually unprecedented Stock Market growth since the election.Need tax cuts
  35. 2017-10-16: Since Election Day on November 8, the Stock Market is up more than 25%, unemployment is at a 17 year low & companies are coming back to U.S.
  36. 2017-10-16: The U.S. has gained more than 5.2 trillion dollars in Stock Market Value since Election Day! Also, record business enthusiasm.
  37. 2017-10-17: RT @Scavino45: U.S. MARKETS FROM ELECTION DAY {Since 11/8/2016} 📈 (video clip of Fox Business: “DOW CLOSES AT RECORD HIGH”)
  38. 2017-10-17: “Dow Passes 23,000 for the First Time, Fueled by Strong Earnings”
  39. 2017-10-17: WOW! (includes an animation titled “DOW PASSES 23,000 FOR THE FIRST TIME”)
  40. 2017-10-18: “20,000📈21,000📈22,000📈 23,000📈this year…FOUR one thousand milestones this year…”
    #Dow23K #MAGA
    (video clip of Fox Business: “DOW CLOSES ABOVE 23,000 54 DAYS SINCE DOW CLOSED ABOVE 22,000”)
  41. 2017-10-21: Stock Market hits another all time high on Friday. 5.3 trillion dollars up since Election. Fake News doesn’t spent much time on this!
  42. 2017-10-21: …2nd Amendment, Strong Military, ISIS, historic VA improvement, Supreme Court Justice, Record Stock Market, lowest unemployment in 17 yrs!
  43. 2017-10-24: Stock Market just hit another record high! Jobs looking very good.
  44. 2017-10-25: MAKE AMERICA GREAT AGAIN! (video clip of Fox News: “STOCK MARKET SURGE”)
  45. 2017-11-04: Unemployment is down to 4.1%, lowest in 17 years. 1.5 million new jobs created since I took office. Highest stock Market ever, up $5.4 trill
  46. 2017-11-07: Stock market hit yet another all-time record high yesterday. There is great confidence in the moves that my Administration….
  47. 2017-11-17: Great numbers on Stocks and the Economy. If we get Tax Cuts and Reform, we’ll really see some great results!
  48. 2017-11-22: Will be having meetings and working the phones from the Winter White House in Florida (Mar-a-Lago). Stock Market hit new Record High yesterday – $5.5 trillion gain since E. Many companies coming back to the U.S. Military building up and getting very strong.
  49. 2017-11-23: HAPPY THANKSGIVING, your Country is starting to do really well. Jobs coming back, highest Stock Market EVER, Military getting really strong, we will build the WALL, V.A. taking care of our Vets, great Supreme Court Justice, RECORD CUT IN REGS, lowest unemployment in 17 years….!
  50. 2017-11-27: New home sales reach a 10 year high. Stock Market has more record gains. Hopefully Republican Senators will give us the much needed Tax Cuts to keep it all going! Democrats want big Tax Increases.
  51. 2017-11-28: Dow, S&P 500 and Nasdaq all finished the day at new RECORD HIGHS!
  52. 2017-11-29: RT @EricTrump: #MakeAmericaGreatAgain (video clip of Fox Business: “DOW CLOSES AT RECORD HIGH”)
  53. 2017-11-29: Looks like another great day for the Stock Market. Consumer Confidence is at Record High. I guess somebody likes me (my policies)!
  54. 2017-11-29: Economy growing! Excluding hurricane effects, CEA estimates that real GDP growth would have been 3.9% in Q3.

    Stock market at a new high, unemployment at a low. We are winning and TAX CUTS will shift our economy into high gear!
  55. 2017-11-30: Stock Market hits new Record High. Confidence and enthusiasm abound. More great numbers coming out!
  56. 2017-11-30: The Dow just broke 24,000 for the first time (another all-time Record). If the Dems had won the Presidential Election, the Market would be down 50% from these levels and Consumer Confidence, which is also at an all-time high, would be “low and glum!”
  57. 2017-11-30: Our FIFTH 1K milestone of 2017!
    #DOW24K #MAGA
  58. 2017-12-03: People who lost money when the Stock Market went down 350 points based on the False and Dishonest reporting of Brian Ross of @ABC News (he has been suspended), should consider hiring a lawyer and suing ABC for the damages this bad reporting has caused – many millions of dollars!
  59. 2017-12-04: Putting Pelosi/Schumer Liberal Puppet Jones into office in Alabama would hurt our great Republican Agenda of low on taxes, tough on crime, strong on military and borders…& so much more. Look at your 401-k’s since Election. Highest Stock Market EVER! Jobs are roaring back!
  60. 2017-12-04: With the great vote on Cutting Taxes, this could be a big day for the Stock Market – and YOU!
  61. 2017-12-10: Things are going really well for our economy, a subject the Fake News spends as little time as possible discussing! Stock Market hit another RECORD HIGH, unemployment is now at a 17 year low and companies are coming back into the USA. Really good news, and much more to come!
  62. 2017-12-12: Consumer Confidence is at an All-Time High, along with a Record High Stock Market. Unemployment is at a 17 year low. MAKE AMERICA GREAT AGAIN! Working to pass MASSIVE TAX CUTS (looking good).
  63. 2017-12-14: Republican Tax Cuts are looking very good. All are working hard. In the meantime, the Stock Market hit another record high!
  64. 2017-12-15: DOW, S&P 500 and NASDAQ close at record highs! #MAGA
  65. 2017-12-18: 70 Record Closes for the Dow so far this year! We have NEVER had 70 Dow Records in a one year period. Wow!
  67. 2017-12-19: Stocks and the economy have a long way to go after the Tax Cut Bill is totally understood and appreciated in scope and size. Immediate expensing will have a big impact. Biggest Tax Cuts and Reform EVER passed. Enjoy, and create many beautiful JOBS!
  68. 2017-12-22: With all my Administration has done on Legislative Approvals (broke Harry Truman’s Record), Regulation Cutting, Judicial Appointments, Building Military, VA, TAX CUTS & REFORM, Record Economy/Stock Market and so much more, I am sure great credit will be given by mainstream news?
  69. 2017-12-23: The Stock Market is setting record after record and unemployment is at a 17 year low. So many things accomplished by the Trump Administration, perhaps more than any other President in first year. Sadly, will never be reported correctly by the Fake News Media!
  70. 2017-12-26: All signs are that business is looking really good for next year, only to be helped further by our Tax Cut Bill. Will be a great year for Companies and JOBS! Stock Market is poised for another year of SUCCESS!
  71. 2017-12-30: “Trump Rally: Stocks put 2017 in the record books”
  72. 2018-01-03: Stock Market had another good day but, now that the Tax Cut Bill has passed, we have tremendous upward potential. Dow just short of 25,000, a number that few thought would be possible this soon into my administration. Also, unemployment went down to 4.1%. Only getting better!
  73. 2018-01-04: Dow just crashes through 25,000. Congrats! Big cuts in unnecessary regulations continuing.
  75. 2018-01-04: The Fake News Media barely mentions the fact that the Stock Market just hit another New Record and that business in the U.S. is booming…but the people know! Can you imagine if “O” was president and had these numbers – would be biggest story on earth! Dow now over 25,000.
  76. 2018-01-05: Dow goes from 18,589 on November 9, 2016, to 25,075 today, for a new all-time Record. Jumped 1000 points in last 5 weeks, Record fastest 1000 point move in history. This is all about the Make America Great Again agenda! Jobs, Jobs, Jobs. Six trillion dollars in value created!
  77. 2018-01-06: Brian Ross, the reporter who made a fraudulent live newscast about me that drove the Stock Market down 350 points (billions of dollars), was suspended for a month but is now back at ABC NEWS in a lower capacity. He is no longer allowed to report on Trump. Should have been fired!
  78. 2018-01-07: The Stock Market has been creating tremendous benefits for our country in the form of not only Record Setting Stock Prices, but present and future Jobs, Jobs, Jobs. Seven TRILLION dollars of value created since our big election win!
  79. 2018-01-13: Yesterday was a big day for the stock market. Jobs are coming back to America. Chrysler is coming back to the USA, from Mexico and many others will follow. Tax cut money to employees is pouring into our economy with many more companies announcing. American business is hot again!
  80. 2018-01-13: RT @LouDobbs: The stock market has gained an incredible 7.8 Trillion dollars in market value since @POTUS was elected! Looks like 4% econom…
  81. 2018-01-14: “President Trump is not getting the credit he deserves for the economy. Tax Cut bonuses to more than 2,000,000 workers. Most explosive Stock Market rally that we’ve seen in modern times. 18,000 to 26,000 from Election, and grounded in profitability and growth. All Trump, not 0…
  82. 2018-01-15: RT @EricTrump: #MakeAmericaGreatAgain 🇺🇸🇺🇸🇺🇸 (Image: “The value of all stocks has gone up $7,800,000,000,000 from the election to now”)
  83. 2018-01-20: Unprecedented success for our Country, in so many ways, since the Election. Record Stock Market, Strong on Military, Crime, Borders, & ISIS, Judicial Strength & Numbers, Lowest Unemployment for Women & ALL, Massive Tax Cuts, end of Individual Mandate – and so much more. Big 2018!
  84. 2018-02-07: In the “old days,” when good news was reported, the Stock Market would go up. Today, when good news is reported, the Stock Market goes down. Big mistake, and we have so much good (great) news about the economy!
  85. 2018-03-26: Great news! #MAGA (Retweet of CNBC Now: “BREAKING: Dow posts third best one-day point gain ever;)
  86. 2018-06-05: The U.S. has an increased economic value of more than 7 Trillion Dollars since the Election. May be the best economy in the history of our country. Record Jobs numbers. Nice!
  87. 2018-06-11: Stock Market up almost 40% since the Election, with 7 Trillion Dollars of U.S. value built throughout the economy. Lowest unemployment rate in many decades, with Black & Hispanic unemployment lowest in History, and Female unemployment lowest in 21 years. Highest confidence ever!
  88. 2018-07-14: The Stock Market hit 25,000 yesterday. Jobs are at an all time record – and that is before we fix some of the worst trade deals and conditions ever seen by any government. It is all happening!
  89. 2018-08-17: Wow! Big pushback on Governor Andrew Cuomo of New York for his really dumb statement about America’s lack of greatness. I have already MADE America Great Again, just look at the markets, jobs, military- setting records, and we will do even better. Andrew “choked” badly, mistake!
  90. 2018-08-22: Longest bull run in the history of the stock market, congratulations America!
  91. 2018-08-25: Stock Market hit all time high on Friday. Congratulations U.S.A.!
  92. 2018-08-26: Fantastic numbers on consumer spending released on Friday. Stock Market hits all time high!
  93. 2018-08-28: NASDAQ has just gone above 8000 for the first time in history!
  94. 2018-08-30: The news from the Financial Markets is even better than anticipated. For all of you that have made a fortune in the markets, or seen your 401k’s rise beyond your wildest expectations, more good news is coming!
  95. 2018-09-09: “Trump has set Economic Growth on fire. During his time in office, the economy has achieved feats most experts thought impossible. GDP is growing at a 3 percent-plus rate. The unemployment rate is near a 50 year low.” CNBC…Also, the Stock Market is up almost 50% since Election!
  96. 2018-09-20: S&P 500 HITS ALL-TIME HIGH Congratulations USA!
  97. 2018-09-21: RT @FoxBusiness: .@POTUS: “The stock market is up 55%… Your 401(k)s are up 50, 60, 70% in some cases.”
  98. 2018-10-03: The Stock Market just reached an All-Time High during my Administration for the 102nd Time, a presidential record, by far, for less than two years. So much potential as Trade and Military Deals are completed.
  99. 2018-10-03: Blowout numbers on New Jobs and, separately, Services. Market up!
  100. 2018-10-04: “U.S. Stocks Widen Global Lead” (Image: “U.S. Stocks Widen Global Lead”)
  101. 2018-10-16: Incredible number just out, 7,036,000 job openings. Astonishing – it’s all working! Stock Market up big on tremendous potential of USA. Also, Strong Profits. We are Number One in World, by far!
  102. 2018-10-16: Stock Market up 548 points today. Also, GREAT jobs numbers!
  103. 2018-10-17: “Network News gave Zero coverage to the Big Day the Stock Market had yesterday.” @foxandfriends
  104. 2018-10-21: Best Jobs Numbers in the history of our great Country! Many other things likewise. So why wouldn’t we win the Midterms? Dems can never do even nearly as well! Think of what will happen to your now beautiful 401-k’s!
  105. 2018-10-30: The Stock Market is up massively since the Election, but is now taking a little pause – people want to see what happens with the Midterms. If you want your Stocks to go down, I strongly suggest voting Democrat. They like the Venezuela financial model, High Taxes & Open Borders!
  106. 2018-10-30: “If the Fed backs off and starts talking a little more Dovish, I think we’re going to be right back to our 2,800 to 2,900 target range that we’ve had for the S&P 500.” Scott Wren, Wells Fargo.
  107. 2018-10-31: Stock Market up more than 400 points yesterday. Today looks to be another good one. Companies earnings are great!
  108. 2018-11-12: The prospect of Presidential Harassment by the Dems is causing the Stock Market big headaches!
  109. 2019-01-04: As I have stated many times, if the Democrats take over the House or Senate, there will be disruption to the Financial Markets. We won the Senate, they won the House. Things will settle down. They only want to impeach me because they know they can’t win in 2020, too much success!
  110. 2019-01-05: “Jobs up big, plus 312,000. Record number working. Manufacturing best in 20 years (Previous administration said this could not happen). Hispanic unemployment lowest ever. Dow plus 747 (for day).” @DRUDGE_REPORT
  111. 2019-01-08: Economic numbers looking REALLY good. Can you imagine if I had long term ZERO interest rates to play with like the past administration, rather than the rapidly raised normalized rates we have today. That would have been SO EASY! Still, markets up BIG since 2016 Election!
  112. 2019-01-19: The Economy is one of the best in our history, with unemployment at a 50 year low, and the Stock Market ready to again break a record (set by us many times) – & all you heard yesterday, based on a phony story, was Impeachment. You want to see a Stock Market Crash, Impeach Trump!
  113. 2019-01-24: Great earnings coming out of Stock Market. Too bad Media doesn’t devote much time to this!
  114. 2019-01-30: Dow just broke 25,000. Tremendous news!
  115. 2019-02-01: Best January for the DOW in over 30 years. We have, by far, the strongest economy in the world!
  116. 2019-02-19: Had the opposition party (no, not the Media) won the election, the Stock Market would be down at least 10,000 points by now. We are heading up, up, up!
  117. 2019-02-25: Since my election as President the Dow Jones is up 43% and the NASDAQ Composite almost 50%. Great news for your 401(k)s as they continue to grow. We are bringing back America faster than anyone thought possible!
  118. 2019-03-02: RT @realDonaldTrump: Since my election as President the Dow Jones is up 43% and the NASDAQ Composite almost 50%. Great news for your 401(k)…
  119. 2019-03-29: Had the Fed not mistakenly raised interest rates, especially since there is very little inflation, and had they not done the ridiculously timed quantitative tightening, the 3.0% GDP, & Stock Market, would have both been much higher & World Markets would be in a better place!
  120. 2019-04-14: If the Fed had done its job properly, which it has not, the Stock Market would have been up 5000 to 10,000 additional points, and GDP would have been well over 4% instead of 3%…with almost no inflation. Quantitative tightening was a killer, should have done the exact opposite!
  121. 2019-04-23: You mean the Stock Market hit an all-time record high today and they’re actually talking impeachment!? Will I ever be given credit for anything by the Fake News Media or Radical Liberal Dems? NO COLLUSION!
  122. 2019-05-10: The average 401(k) balance has SOARED since the bottom of the market – 466%. Wow!
  123. 2019-06-07: Dow Jones has best week of the year!
  124. 2019-06-11: Good day in the Stock Market. People have no idea the tremendous potential our Country has for GROWTH – and many other things!
  125. 2019-06-15: The Trump Economy is setting records, and has a long way up to go….However, if anyone but me takes over in 2020 (I know the competition very well), there will be a Market Crash the likes of which has not been seen before! KEEP AMERICA GREAT
  126. 2019-06-19: Since Election Day 2016, Stocks up almost 50%, Stocks gained 9.2 Trillion Dollars in value, and more than 5,000,000 new jobs added to the Economy. @LouDobbs If our opponent had won, there would have been a market crash, plain and simple! @TuckerCarlson @seanhannity @IngrahamAngle
  127. 2019-06-20: S&P opens at Record High!
  128. 2019-06-20: S&P closes at Record High!
  129. 2019-06-22: Stock Market is on track to have the best June in over 50 years! Thank you Mr. President! @WSJ
  130. 2019-06-22: I am at Camp David working on many things, including Iran! We have a great Economy, Tariffs have been very helpful both with respect to the huge Dollars coming IN, & on helping to make good Trade Deals. The Dow heading to BEST June in 80 years! Stock Market BEST June in 50 years!
  131. 2019-06-24: ….Think of what it could have been if the Fed had gotten it right. Thousands of points higher on the Dow, and GDP in the 4’s or even 5’s. Now they stick, like a stubborn child, when we need rates cuts, & easing, to make up for what other countries are doing against us. Blew it!
  132. 2019-06-25: Stock Market is heading for one of the best months (June) in the history of our Country. Thank you Mr. President!
  133. 2019-06-26: RT @realDonaldTrump: Stock Market is heading for one of the best months (June) in the history of our Country. Thank you Mr. President!
  134. 2019-06-28: The Stock Market went up massively from the day after I won the Election, all the way up to the day that I took office, because of the enthusiasm for the fact that I was going to be President. That big Stock Market increase must be credited to me. If Hillary won – a Big Crash!
  135. 2019-06-30: “Stocks Cap Best First Half Since 1997” @WSJ Our Country is doing great!
  136. 2019-07-03: S&P 500 hits new record high. Up 19% for the year. Congratulations!
  137. 2019-07-03: Today’s Stock Market is the highest in the history of our great Country! This is the 104th time since the Election of 2016 that we have reached a NEW HIGH. Congratulations USA!
  138. 2019-07-05: ….As well as we are doing from the day after the great Election, when the Market shot right up, it could have been even better – massive additional wealth would have been created, & used very well. Our most difficult problem is not our competitors, it is the Federal Reserve!
  139. 2019-07-07: RT @WhiteHouse: The 3 major U.S. stock indexes all closed with record highs Wednesday!
  140. 2019-07-11: Dow just hit 27,000 for first time EVER!
  141. 2019-07-12: The DOW, S&P 500, and NASDAQ all close the week at a new record high!
  142. 2019-07-15: ….Detention facilities are not Concentration Camps! America has never been stronger than it is now – rebuilt Military, highest Stock Market EVER, lowest unemployment and more people working than ever before. Keep America Great!
  143. 2019-07-17: Big Rally tonight in Greenville, North Carolina. Lots of great things to tell you about, including the fact that our Economy is the best it has ever been. Best Employment & Stock Market Numbers EVER. I’ll talk also about people who love, and hate, our Country (mostly love)! 7:PM
  144. 2019-07-23: Newest Poll: Only 11% in favor of starting ridiculous impeachment hearings. Well, let’s see: We have the Best Economy in History, the Best Employment Numbers in History, Most People Working in History, Highest Stock Market in History, Biggest Tax and Regulation Cuts in History,..
  145. 2019-07-25: President Trump’s Approval Rating on Economy is at 52%, a 4 point jump. Fox Poll @foxandfriends Shouldn’t this be at 100%? Best stock market, economy and unemployment numbers ever! Most people working within U.S. ever! Low interest rates, very low inflation! Country doing great!
  146. 2019-07-31: What the Market wanted to hear from Jay Powell and the Federal Reserve was that this was the beginning of a lengthy and aggressive rate-cutting cycle which would keep pace with China, The European Union and other countries around the world….
  147. 2019-08-01: The people on the stage tonight, and last, were not those that will either Make America Great Again or Keep America Great! Our Country now is breaking records in almost every category, from Stock Market to Military to Unemployment. We have prosperity & success like never before..
  148. 2019-08-06: Thank you @JimCramer @CNBC! (Clip of CNBC: “U.S. FUTURES: S&P 500, DOW JONES, NASDAQ”)
  149. 2019-08-23: The Dow is down 573 points perhaps on the news that Representative Seth Moulton, whoever that may be, has dropped out of the 2020 Presidential Race!
  150. 2019-08-25: My Stock Market gains must be judged from the day after the Election, November 9, 2016, where the Market went up big after the win, and because of the win. Had my opponent won, CRASH!
  151. 2019-08-30: If the Fed would cut, we would have one of the biggest Stock Market increases in a long time. Badly run and weak companies are smartly blaming these small Tariffs instead of themselves for bad management…and who can really blame them for doing that? Excuses!
  152. 2019-09-01: RT @realDonaldTrump: If the Fed would cut, we would have one of the biggest Stock Market increases in a long time. Badly run and weak compa…
  153. 2019-09-02: Since my election, many trillions of dollars of worth has been created for our Country, and the Stock Market is up over 50%. If you followed the advice of the Failing New York Times columnist, Paul Krugman, you’d be doing VERY poorly – you’d be angry and hurt. He never got it!
  154. 2019-09-05: RT @MadMoneyOnCNBC: .@JimCramer: Thursday’s positive economic data may get some commentators to ease up on the desire to endlessly call for… (Link to CNBC article Positive economic data triggered a ‘sea change’ in the stocks that are working on Wall Street)
  155. 2019-09-26: If they actually did this the markets would crash. Do you think it was luck that got us to the best Stock Market and Economy in our history. It wasn’t!
  156. 2019-10-01: You cannot judge my Stock Market performance since the Inauguration, which was very good, but only from the day after the big Election Win, which was spectacular due to the euphoria of getting Obama/Biden OUT, & getting Trump/Pence IN. WentI up BIG between Nov. 9 & Inauguration!
  157. 2019-10-02: All of this impeachment nonsense, which is going nowhere, is driving the Stock Market, and your 401K’s, down. But that is exactly what the Democrats want to do. They are willing to hurt the Country, with only the 2020 Election in mind!
  158. 2019-10-16: Our record Economy would CRASH, just like in 1929, if any of those clowns became President!
  159. 2019-10-28: The S&P just hit an ALL TIME HIGH. This is a big win for jobs, 401-K’s, and, frankly, EVERYONE! Our Country is doing great. Even killed long sought ISIS murderer, Al-Baghdadi. We are stronger than ever before, with GREAT upward potential. Enjoy!
  160. 2019-10-31: The Impeachment Hoax is hurting our Stock Market. The Do Nothing Democrats don’t care!
  161. 2019-11-01: Stock Market up BIG! Record highs for S&P 500 and NASDAQ. Enjoy!
  162. 2019-11-04: Stock Market hits RECORD HIGH. Spend your money well!
  163. 2019-11-04: All-Time High for Stock Market and all the Fake News wants to talk about is the Impeachment Hoax!
  164. 2019-11-04: RT @TrumpWarRoom: “So today, we just hit the highest number in the history of the stock market. … That’s for everybody. Your 401(k)’s, ho…
  165. 2019-11-05: RT @Varneyco: STU: “Throw in strong #profits, #tradedeals, and more #economicgrowth still to come, and you can see why we have record highs…
  166. 2019-11-05: RT @realDonaldTrump: All-Time High for Stock Market and all the Fake News wants to talk about is the Impeachment Hoax!
  167. 2019-11-06: Stock Markets (all three) hit another ALL TIME & HISTORIC HIGH yesterday! You are sooo lucky to have me as your President (just kidding!). Spend your money well!
  168. 2019-11-06: RT @realDonaldTrump: Stock Markets (all three) hit another ALL TIME & HISTORIC HIGH yesterday! You are sooo lucky to have me as your Presid…
  169. 2019-11-07: Stock Market up big today. A New Record. Enjoy!
  170. 2019-11-14: Hit New Stock Market record again yesterday, the 20th time this year, with GREAT potential for the future. USA is where the action is. Companies and jobs are coming back like never before!
  171. 2019-11-15: Another Record Stock Market, 21 times this year, despite an ongoing, & totally unfounded, Witch Hunt, & a Democrat Party that would love to see a nice, big, juicy recession. In actuality, the potential for the United States is unlimited. We will power through the Do Nothing Dems!
  172. 2019-11-15: Stock Market up big. New and Historic Record. Job, jobs, jobs!
  173. 2019-11-16: Dow hits 28,000 – FIRST TIME EVER, HIGHEST EVER! Gee, Pelosi & Schitt have a good idea, “lets Impeach the President.” If something like that ever happened, it would lead to the biggest FALL in Market History. It’s called a Depression, not a Recession! So much for 401-K’s & Jobs!
  174. 2019-11-17: Thanks Eric! (Reply to Eric Trump: “The DOW closed at over 28,000 for the first time in HISTORY. All three US stock indexes closed today at record highs!!! Good job dad! @realDonaldTrump #MAGA 🇺🇸🇺🇸🇺🇸”)
  175. 2019-11-18: GREAT NEWS! #MAGA #KAG (Clip of CNBC: “DOW, NASDAQ RECORD CLOSE”)
  176. 2019-11-19: NASDAQ UP 27% THIS YEAR ALONE!
  177. 2019-11-25: Another new Stock Market Record. Enjoy!
  178. 2019-11-25: “DOW, NASDAQ, S&P 500 CLOSE AT RECORD HIGHS”
  179. 2019-11-25: RT @realDonaldTrump: “DOW, NASDAQ, S&P 500 CLOSE AT RECORD HIGHS”
  180. 2019-11-27: New Stock Market Record today, AGAIN. Congratulations USA!
  181. 2019-11-30: RT @WattersWorld: . @realDonaldTrump won’t get the nomination, Trump won’t win, Stock Market will tank, Russia Collusion…These are the st…
  182. 2019-12-02: U.S. Markets are up as much as 21% since the announcement of Tariffs on 3/1/2018 – and the U.S. is taking in massive amounts of money (and giving some to our farmers, who have been targeted by China)!
  183. 2019-12-05: Nancy Pelosi just had a nervous fit. She hates that we will soon have 182 great new judges and sooo much more. Stock Market and employment records. She says she “prays for the President.” I don’t believe her, not even close. Help the homeless in your district Nancy. USMCA?
  184. 2019-12-06: Stock Markets Up Record Numbers. For this year alone, Dow up 18.65%, S&P up 24.36%, Nasdaq Composite up 29.17%. “It’s the economy, stupid.”
  185. 2019-12-06: Without the horror show that is the Radical Left, Do Nothing Democrats, the Stock Markets and Economy would be even better, if that is possible, and the Border would be closed to the evil of Drugs, Gangs and all other problems! #2020
  187. 2019-12-08: RT @WarRoom2020: OH MY JOBS! – U.S. Economy Adds 266,000 Jobs in November #WarRoomImpeachment ( article: “OH MY JOBS! – U.S. Economy Adds 266,000 Jobs in November. U.S. jobs numbers soared again in November, providing markets another boost…”)
  188. 2019-12-09: The best Economy ever! (Reply to CNBC tweet with a list of economic assets that added value, including among others the S&P 500)
  189. 2019-12-13: Record Stock Market & Jobs!
  190. 2019-12-16: New Stock Market high! I will never get bored of telling you that – and we will never get tired of winning!
  191. 2019-12-16: ( article: “Dow gains 10,000th point since Trump’s election”)
  192. 2019-12-17: The Stock Market hit another Record High yesterday, number 133 in less than three years as your all time favorite President, and the Radical Left, Do Nothing Democrats, want to impeach me. Don’t worry, I have done nothing wrong. Actually, they have!
  193. 2019-12-20: Economy is GREAT, Big Stock Market uptick today. Best ranking in 20 years admits CNN!
  194. 2019-12-20: Broke all time Stock Market Record again today. 135 times since my 2016 Election Win. Thank you!
  195. 2019-12-23: NASDAQ UP 72.2% SINCE OUR GREAT 2016 ELECTION VICTORY! DOW UP 55.8%. The best is yet to come!
  196. 2019-12-23: STOCK MARKET CLOSES AT ALL-TIME HIGH! What a great time for the Radical Left, Do Nothing Democrats to Impeach your favorite President, especially since he has not done anything wrong!
  197. 2019-12-24: “Stocks kick off Christmas week at All-Time Record Highs.” @foxandfriends
  198. 2019-12-24: (Clip of Fox News: “STOCKS RECORD RISE”)
  199. 2019-12-26: “Trump stock market rally is far outpacing past US presidents”
  200. 2019-12-26: “Nasdaq Hits 9,000 for First Time Ever”
  201. 2019-12-26: RT @AZachParkinson: “The S&P 500 has returned more than 50% since Trump was elected, more than double the 23% average market return of pres…
  202. 2019-12-26: RT @TrumpWarRoom: Americans’ retirement savings are WINNING BIG under President Trump!

    The Nasdaq just hit 9,000 for the first time IN HIS…
  203. 2019-12-27: “Trump Stock Market rally is far outpacing past U.S. presidents” @CNBC With new trade deals, and more, THE BEST IS YET TO COME!
  204. 2019-12-27: “Dow closes at another All-Time High!” @cvpayne @FoxBusiness
  205. 2019-12-27: RT @ROHLL5: I Blame Trump! 🤣
    (Image: “I Blame Trump! Stock Market Up! Jobs Up; Wages are up!”)
  206. 2020-01-01: RT @Scavino45: (Image: “THE STOCK MARKET KEEPS BREAKING RECORDS”)
  207. 2020-01-09: STOCK MARKET AT ALL-TIME HIGH! HOW ARE YOUR 401K’S DOING? 70%, 80%, 90% up? Only 50% up! What are you doing wrong?
  208. 2020-01-10: “11,000 points gained in the Dow in the 3 years since the Election of President Trump. Today it may hit 29,000. That has NEVER happened before in that time frame. That has added 12.8 Trillion Dollars to the VALUE of American Business.” @Varneyco @FoxNews The best is yet to come!
  209. 2020-01-10: RT @realDonaldTrump: “11,000 points gained in the Dow in the 3 years since the Election of President Trump. Today it may hit 29,000. That h…
  210. 2020-01-17: Heading to Florida for big Republican Party event. New Stock Market Record. Jobs in USA at all-time high!
  211. 2020-01-18: RT @realDonaldTrump: “Trade Deals Drive Stocks To Record Highs.” @FoxNews
  212. 2020-01-18: If you listened to the flawed advice of @paulkrugman at the @nytimes, a newspaper that was going broke until I came along, you would have entirely missed the RECORD BREAKING Stock Market (and other) numbers produced since Election Day, 2016. Sorry, those are the FACTS…..
  213. 2020-01-24: RT @SenJohnBarrasso: Since @realDonaldTrump took office, we’ve added 7 million new jobs, consumer confidence & the stock market are at all-…
  214. 2020-02-04: Market up big today on very good economic news. JOBS, JOBS, JOBS!
  215. 2020-02-11: New Stock Market RECORD. Congratulations, spend your money wisely. KEEP AMERICA GREAT!!!!!
  216. 2020-02-11: When Jerome Powell started his testimony today, the Dow was up 125, & heading higher. As he spoke it drifted steadily downward, as usual, and is now at -15. Germany & other countries get paid to borrow money. We are more prime, but Fed Rate is too high, Dollar tough on exports.
  217. 2020-02-12: GREAT NEWS! #KAG2020🇺🇸 (Clip of CNBC: “RECORD CLOSE FOR STOCKS”)
  218. 2020-02-15: RT @GOPChairwoman: .@realDonaldTrump’s policies have kicked America’s economic engine into high gear:

    Last month marked the 23rd consecut…
  219. 2020-02-19: Highest Stock Market In History, By Far!
  220. 2020-02-24: The Coronavirus is very much under control in the USA. We are in contact with everyone and all relevant countries. CDC & World Health have been working hard and very smart. Stock Market starting to look very good to me!
  221. 2020-03-02: (Clip of Hannity: “STOCKS SURGE, BREAK SINGLE-DAY TRADING RECORDS”)
  222. 2020-03-13: RT @SaraCarterDC: Trump Declares National Emergency Over Coronavirus, Solutions Spur Wall Street Rally

    Incredible what can be done w/ rig…
  224. 2020-04-10: This week, in only 4 days, we had the biggest Stock Market increase since 1974. We have a great chance for the really big bounce when the Invisible Enemy is gone!

Last updated 2020-04-20

Collecting audio logs the REALLY old-fashioned way – on Windows 7

I’ve blogged before about how to collect audio logs using Windows Performance Recorder profiles (WPRP files), among other things:

I’ve blogged before about what to do if you have an audio problem on Windows 7:

I’ve blogged before about the Trusted Audio Drivers audio digital rights management feature:

Recently I was involved in a Windows 7 audio support issue that involved SHA-1 deprecation and Trusted Audio Drivers. It was very handy to be able to collect audio logs and Code Integrity logs on Windows 7, but it turns out the Windows 7 version of Windows Performance Recorder has slightly different syntax requirements for WPRP files.

Here are the WPRP files we used:

Safe primes and unsafe primes

Secure communications like HTTPS, SSH, SFTP and others rely on cryptographic handshakes like the Diffie-Hellman key exchange to negotiate a shared key.

There are lots of ways to set up a Diffie-Hellman key exchange. The Logjam security vulnerability starts with a flaw in the negotiation process to ensure a relatively weak one is used – finite-field with a small prime – and ends up with a man-in-the-middle attack.

The paper uses the term “safe prime” and thought I would dig a little into exactly what that meant.

Refresher: a given prime p defines the Galois field GF(p). This contains p elements: 0 through p – 1 inclusive. Addition and multiplication are both modulo p. We can start with any one of these elements – call it g, for “generator” – and form the sequence 1, g, g2, g3, and so on, until we eventually come back to 1. Call the “period” (length) of this sequence x. It is a law of mathematics that x always evenly divides p – 1.

The vulnerable Diffie-Hellman key exchange goes something like this, skipping over some details:

  1. Alice has a secret key a; Bob has a secret key b.
  2. Alice and Bob start a conversation where the attacker Eve can hear them – they publicly agree to a particular prime p and a generator g.
  3. Alice calculates ga mod p and shares it; Bob calculates gb mod p and shares it.
  4. Alice calculates (gb)a mod p and Bob calculates (ga)b mod p. These are necessarily equal, and their shared value is used as a secret symmetric key for the rest of the conversation.

For cryptographic reasons, we want g’s period in GF(p) to be reasonably large. If the period is small, that gives Eve a reasonable chance to guess the shared secret, which is even worse than her man-in-the-middle attack from Logjam.

So how do we ensure the period is small? One way to do it (not necessarily a good way to do it) is to arrange for p – 1 to have very few divisors.

Could p – 1 be prime? Well, yes, there are two consecutive primes – namely, (2, 3) – but choosing p = 3 has some other cryptographic drawbacks which outweigh the benefit 🙂

OK, well, then, if p – 1 can’t be prime, can it be a semiprime?

Yes, it can. In fact, it can be of the form 2q where q is also prime. In this case, the prime pair (q, p = 2q + 1) are called a (Sophie Germain prime, safe prime) pair. This is the technical definition of “safe prime.”

To illustrate this, let’s choose a couple of primes and see what their generator cycles look like. In particular, let’s look at the safe prime 59 (59 – 1 = 2 * 29 so the corresponding Sophie Germain prime is 29) and the “unsafe prime” 61 (61 – 1 = 60 is a smooth number with quite a lot of factors.)

For each prime I made a table where the rows are all the possible generators g and the columns are the exponents i in gi. I highlighted the columns x where x is a factor of p – 1

Here’s the safe prime 59:

Generator cycles in GF(59)

And here’s the unsafe prime 61:

Generator cycles in GF(61)

Notice that there are only four periods for 59, in particular x = 1, 2, 29, and 58. These are the four factors of (59 – 1). When choosing a generator, periods 1 and 2 are of course to be avoided; this is easy to do. Period 58 is as good as possible. Period 29 might be accepted as good enough; but if you wanted to go the extra mile, you could detect and correct as follows.

  • Calculate g(p – 1)/2. This will always be -1 or 1.
  • If it’s -1, g has period p – 1, which is as good as it gets.
  • If it’s 1, g has period (p – 1)/2. Use –g instead, which has period p – 1, unless (q, p) = (2, 5), which we reject for the same reasons as (2, 3).

By contrast, there are no fewer than 12 periods for 61, in particular x = 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60. These are the factors of (61 – 1). It is not so easy to decide where the threshold of acceptability lies (30? 12?), and it is not so easy to correct generators with small periods, or even to detect them (other than 0, 1, and p – 1, which are still trivial to avoid.)

Real cryptographic primes are of course much, much bigger than 61, but this serves as an illustration of why safe primes are called “safe”.

Gravity and centripetal acceleration on a space station

Commenter Robert blanton asked

Okay, so I’m standing on a space station that is a rotating toroid so I experience One gravity under my feet. I’m holding a coffee cup and let it drop. Isn’t its drop going to follow a V*cos function? Unless the space station is really small it’s going to look like it accelerates at one G, but what is the force it experiences on impact?

It seems that that force won’t be the same as if it were truly accelerating. Now add a little push, in the direction of spin, and anti-spin. Won’t the behavior vary?

I’m writing a science fiction book and would like to get it right.

Robert blanton

To answer this question, it is important to emphasize the difference between gravity per se and centripetal acceleration.

GravityCentripetal acceleration
Exists between any two objects with mass
Stronger between objects of large mass
Stronger as objects are closer together
Keeps one object in orbit around another object
Stronger as the radius of orbit increases
Stronger as the time of orbit decreases

For some gory detail on how gravity and centripetal acceleration interplay on the Earth, see Gravity and centripetal acceleration on Earth. TL:DR; gravity is king, centripetal acceleration can mostly be ignored.

On the space station, the situation is exactly reversed. Centripetal acceleration is king, and gravity can mostly be ignored.

Let’s define a “day” as the amount of time it takes for our space station to undergo a single complete rotation. We’ll also define t as the length of the “day”, in seconds.

Let r be the radius of the space station, in meters.

We can manipulate the formula a = v2/r to relate the length of the day and the radius of the space station. Start with a = v2/r and substitute both a = 9.8 m/s2 (which is what humans on Earth are used to) and v = 2πr/t. Then do some manipulation to get:

9.8t2 = 4π2r

The radius is proportional to the square of the orbital time. That is, smaller space stations need to spin faster. The bigger the space station, the longer the day.

For story purposes, if we want a particular size, we can calculate the required length of the day. Solving for t:

t = √(4π2r/9.8) = 2.0√r

For example, a space station of radius 150 meters would need to have a day of 24 seconds; a space station of radius 1,500 meters would need to have a day of 77 seconds.

Or if we want a particular day length, we can calculate the required size. Solving for r:

r = 9.8t2/(4π2) = 0.25t2

So if we want a day to last 60 seconds, we need a space station of radius 900 m; if we want a day to last 120 seconds, we need a space station of radius 3.6 km.

The acceleration varies as you wander throughout the space station. The closer you are to the rotational axis, the weaker the effect. So things near the ceiling will be accelerated slightly less than things on the floor.

The variation will be minimal if the hole in the toroid is large; that is to say, if the ceiling and the floor are both quite far from the rotational axis.

So if the space station is large, the coffee cup will behave almost exactly as it does on the Earth. If you add a little push, the coffee cup will follow a parabolic path to the floor. If the floor is hard, the cup will break.

If the space station is small, and you had a fairly precise scale, you would notice that the cup weighs less on the top shelf than it does on the floor.

Just for fun, suppose that in addition to the inhabited toroidal part of the space station, there was a service area in the center, on the rotational axis. People would be weightless here.

Perhaps the service area is connected to the toroidal part by spokes, so that it can be reached without going outside. You would experience a gradual transition between full Earth gravity and complete weightlessness as you went along the spoke. Perhaps you have a ladder on the spoke which has rungs quite close together near the edge, where there is full gravity; and as you ascend toward the hub, the rungs get farther apart, as you move from climbing, to jumping, to swimming, to floating.

Gravity and centripetal acceleration on Earth

Earth accelerates you in two different directions at once. Earth’s gravity pulls you one way, and its rotation pushes you another. We consider the direction, magnitude, and variation of these forces at various points on the Earth’s surface.


Direction: gravity pulls you toward the center of the Earth.

Magnitude: if you are on or above the Earth’s surface, the pull’s strength follows the “Acceleration due to Earth’s gravity” formula from “Formulas and facts” below.

Variation: the pull’s strength is inversely proportional to the square of your distance from the center of the Earth, so long as you’re on or above the surface. The closer you get to the center, the stronger gravity is; the further away you get from the center, the weaker gravity is.

  • The Earth is shaped like a sphere. Well… not quite like a sphere. It’s flattened a bit, like an M&M. The “M”s are printed at the North and South Poles, and the Equator goes around the edge.
    This means that when you’re at the Poles, you’re closer to the center of the Earth than you are at the Equator. So gravity is stronger at the Poles, and weaker at the Equator.
  • Also, but to a much lesser degree, the Earth’s surface is uneven. There are bumps (mountains) and crannies (valleys.)
    At a given latitude, when you’re at the bottom of a valley, you’re closer to the center of the Earth than you are at the top of a mountain. So gravity is weaker on mountains. (It is tempting to say that gravity is stronger in valleys, but valleys are a little complicated, because the higher land around you pulls you in the opposite direction than the rest of the Earth. It is true to say that gravity is stronger on low-laying plains, though.)
  • The strongest gravity is at the North Pole, which is pretty much at sea level. (The South Pole is on a plateau.)
  • The weakest gravity is at the peak of Mt. Chimborazo in Ecuador.
  • What about Mt. Everest, you say? Well, Mt. Everest is the highest mountain above sea level, but the sea follows the M&M shape, so Mt. Chimborazo is further from the center of the Earth.

Centripetal acceleration

Direction: centripetal acceleration pushes you away from Earth’s axis of rotation.

If you’re at the Equator, this is straight up; if you are at the North Pole or South Pole, the only effect is to make you very slightly dizzy; and if you are somewhere in between, you can get a basic feel for the direction by looking at the nearest satellite dish.

You can get a more precise direction by knowing your latitude and compass heading:

  1. Point an arrow straight up (that is, away from the center of the Earth.)
  2. If your latitude is zero, you’re on the Equator. You’re done.
  3. Bend it down, in the direction of the Equator, by an angle equal to your latitude.
    • If you are in the Northern hemisphere, bend it South.
    • If you are in the Southern hemisphere, bend it North.
  4. The final direction of the arrow is the way centripetal acceleration is pushing you.

Magnitude: the pull’s strength follows the “Acceleration due to Earth’s rotation” formula.

Variation: the pull’s strength is proportional to the square of your distance from Earth’s axis of rotation. The closer you get to the axis, the weaker centripetal acceleration is. The further you get from the axis, the stronger centripetal acceleration is.

In particular, centripetal acceleration is strongest at the Equator. It is weakest at the Poles. (In fact, it is zero at the Poles.)

Putting the two together

Direction: gravity is much stronger than centripetal acceleration, so the sum of the two vectors always points almost completely in the direction of the gravity vector.

Magnitude: the pull’s strength follows the “Combined acceleration due to Earth’s gravity and rotation” formula. The angle between the two vectors is always between 90° and 180°, so the forces counteract each other; the total acceleration is always a little bit less than gravity alone (or, in the case of the Poles, exactly equal to gravity alone.)

Variation: because of the M&M shape, centripetal acceleration (which counteracts gravity) is strongest in the same places where gravity is already weak – the Equator, and mountains. So centripetal acceleration just exaggerates the weakness of already-weak gravity.

Here’s a table. I throw in La Rinconada, in Peru, because it’s the highest permanently inhabited place, and it’s also quite near the equator. The table has the strongest combined acceleration at the top and the lowest at the bottom.

PlaceTo center (m)ag (m/s2)Lat. (°)To axis (m)ar (m/s2)a (m/s2)
North Pole6.357e69.86390.00009.863
Mt. Everest6.382e69.78627.995.636e60.0095399.777
La Rinconada6.383e69.78314.636.176e60.010459.773
Mt. Chimborazo6.384e69.7801.476.382e60.010809.769

In conclustion, a varies across the Earth from 9.769 m/s2 to 9.863 m/s2, which is a variation of about 0.95%. About 0.84% of this comes from variation in gravity, and the other 0.11% comes from variation in centripetal acceleration.

Facts and formulas

  • Newton’s second law of motion
    F is the force applied to an object
    m is the mass of the object
    a is the acceleration experienced by the object
    F = ma
  • Gravitational constant
    G = 6.674e-11 m3/(kg s2)
  • Earth mass
    M = 5.9722e24 kg
  • Earth radius (at sea level)
    • At the North Pole or South Pole = 6.357e6 m
    • Mean = 6.371e6 m
    • At the Equator = 6.378e6 m
  • Acceleration due to Earth’s gravity
    G is the gravitational constant
    M is Earth’s mass
    r is the distance of the object from the center of the Earth
    ag = GM/r2
  • Centripetal acceleration
    v is the speed of an object orbiting a fixed point
    r is the radius of the orbit
    t is the time to complete a single orbit; note that v = 2πr/t
    a is the acceleration experienced by the object
    a = v2 /r = 4π2r/t2
  • Earth rotation
    • Nominal time for one solar rotation: 24 * 60 * 60 = 8.6400e4 s
    • Actual time for one solar rotation: a teensy bit more due to leap seconds
    • Actual time for one sidereal rotation: T = 8.6164e4 s
  • Acceleration due to Earth’s rotation
    r is the distance between the object and the Earth’s axis of rotation (not the center of the Earth)
    T is the time for one sidereal rotation
    ar is the acceleration experienced by the object
    ar = 4π2r/T2
  • Vector addition
    a is a vector
    b is another vector
    θ is the angle between a and b when placed tail-to-tail
    |a + b|2 = |a|2 + |b|2 + 2|a||b|cos θ
  • Combined acceleration due to Earth’s gravity and rotation
    ag is the acceleration due to Earth’s gravity
    ar is the acceleration due to Earth’s rotation
    L is the latitude of the object, in degrees; the angle of the two vectors in radians is π – (πL/180)
    a is the combined acceleration
    |a|2 = |ag|2 + |ar|2 + 2|ag||ar|cos (π – (πL/180))

Final Fantasy X blitzball tech map

I’m leveling up my kick-ass women’s blitzball team and I’m running into trouble with Irga Ronso. She has three key techniques:

  • Pile Wither
  • Wither Tackle 3
  • Super Goalie

Usually my approach is to learn techniques using Techcopy.

But Irga’s Wither Tackle 3 and Super Goalie are both locked until she learns at least one key technique (or maybe two.)

Which means I’m looking at Pile Wither…

… but Pile Wither cannot be Techcopy’d.

So in order for Irga to achieve her full potential, I need to either:

  • Win Pile Wither in a tournament and award it to her
  • Win Tech Find in a tournament and use it to unlock either Wither Tackle 3 or Super Goalie for her, so she can Techcopy it later
  • Release her as a free agent and hope some other team helps her learn a key technique

I am unwilling to release her because I like having her on my team. So I’m looking at the “win Pile Wither” or “win Tech Find” approaches. Luckily, these can be tried in parallel.

The “win Pile Wither” approach is straightforward.

But for the “win Tech Find” approach to work, I need to know where Wither Tackle 3 and Super Goalie are on the list of techniques.

That is, I need a map of the techniques.

I built up my recruiting skill to maximum level and chatted up all the players on my team (and a couple of people not on my team who happened to be nearby) and got a pretty good map, which follows. The techniques marked with question marks are just guesses based on the pattern and fuzzy memories of previous games I’ve played:

1Jecht ShotWither ShotWither Pass 2
2Jecht Shot 2?Wither Shot 2Wither Pass 3
3Sphere ShotWither Shot 3Volley Shot
4Invisible Shot?Venom PassVolley Shot 2?
5Venom ShotVenom Pass 2Volley Shot 3?
6Venom Shot 2Venom Pass 3Venom Tackle
7Venom Shot 3Nap PassVenom Tackle 2
8Nap ShotNap Pass 2Venom Tackle 3?
9Nap Shot 2?Nap Pass 3?Nap Tackle
10Nap Shot 3Wither PassNap Tackle 2
1Nap Tackle 3Anti-Venom 2Brawler
2Wither TackleAnti-NapPile Venom?
3Wither Tackle 2Anti-Nap 2?Pile Wither
4Wither Tackle 3Anti-WitherRegen
5Drain TackleAnti-Wither 2Good Morning!
6Drain Tackle 2Anti-DrainHi-Risk
7Drain Tackle 3Anti-Drain 2?Golden Arm
8Tackle SlipSpin BallGamble
9Tackle Slip 2Grip GlovesSuper Goalie
10Anti-VenomElite DefenseAurochs Spirit?

I will update the map as I confirm my guesses.