Coding: Bring the Noise

%26lt;0011 Em

Archive for the ‘Puzzles’ Category

More thoughts on the Collatz Conjecture

leave a comment »

I made a quick housekeeping sweep of the blog recently, and wanted to revisit the Collatz Conjecture.  I’m sure it’s been suggested before, but I believe there’s another method of proving the conjecture:

Collatz(k) for all k \in [2^{n}, 2^{n+1}] where n \in \mathbb{Z}^+ > 2

That is to say, we only need prove that for an n > 2, all integers between consecutive powers of 2 resolve according to the collatz conjecture.  I’m not sure where to go from there, but for instance we can show that in general:

2^n + 1 \Rightarrow 3^{r} + 1 where r is the number of (divisible by 3) iterations such that n = 2r

Read the rest of this entry »

Advertisements

Written by delwinna

May 13, 2013 at 2:15 am

Posted in Puzzles

Takkuso’s Cycles

leave a comment »

I saw an interesting post on /r/math today, and decided to write a small script to play around with it.

  1. Pick a positive integer, i
  2. Find the magnitude, m, of the difference between i and i’s reverse, j
  3. Repeat step 2 using m; you will eventually hit either 0 or a special number.

The special number is 21, followed by min(0, log10(i)-4) 9s, then 78.

A quick table:

# of digits Special number
4 2178
5 21978
6 219978
7 2199978

Below is the Python script in full, followed by a quick example usage.  I’m hoping to do some graphs when I get home.

Read the rest of this entry »

Written by delwinna

April 20, 2012 at 6:30 pm

Posted in Puzzles

Digit counting in Python

leave a comment »

Question: what’s the fastest way to count the number of digits (base 10) in an integer (integral type, could be long) in python?

This came up when I was working on a ProjectEuler problem.  There are three options I came up with, and we can rule the first out immediately:

  1. Divide (as an integer) the number by ten and keep a counter of how many times we divided it, until the number is 0.
  2. Use log(n, 10) and properly account for floating point black magic
  3. Convert to a string, get the length

Read the rest of this entry »

Written by delwinna

January 27, 2012 at 2:40 am

Posted in Puzzles, Python

Experimenting with the Collatz Conjecture and C#’s GC

leave a comment »

For those new to the Collatz Conjecture

EDIT: Commented the latex tabular code. Get it here.

More after the break. Read the rest of this entry »

Written by delwinna

September 1, 2011 at 7:23 am

Posted in Puzzles