Specifically for [livejournal.com profile] coldtortuga

Jan. 1st, 2006 01:56 pm
pmb: (Default)
[personal profile] pmb
A variation on a previous theme:
BaseNumberNumber in Base 10
2121
3232
4312454
54135108
64126152
765142716200
8762513482042460
9827153694416720
109867312109867312
Still churning - these O(nn) algorithms really soak up the CPU time...
(I later hit Ctrl-C, so all numbers after this point are from [livejournal.com profile] coldtortuga)
11A98762413112334364200
12B935217612421877610
13CBA95847213131779700673520

Date: 2006-01-02 02:20 pm (UTC)
From: [identity profile] chanusa.livejournal.com
You should add this to the OEIS! They love new interesting sequences
http://www.research.att.com/~njas/sequences/

Date: 2006-01-02 07:28 pm (UTC)
From: [identity profile] pmb.livejournal.com
I thought that a sequence had to be published in a research result. How would I go about adding this sequence?

Date: 2006-01-03 02:12 pm (UTC)
From: (Anonymous)
Your sequence doesn't need to be published; it just has to be a sequence of interest.
From the homepage, choose submit a sequence; it takes you to the following page:
http://www.research.att.com/~njas/sequences/Submit.html
After that, it's fairly self-explanatory.
Just make sure your explanation is clear so that others could replicate your work.
Be sure to check the "hard" box at the bottom since it is a hard sequence to calculate (computationally).
Then you'll have your own A number!
Good luck. If you'd like to run your submission past me first, feel free.

Date: 2006-01-05 05:16 pm (UTC)
From: [identity profile] mycrust.livejournal.com
Hmm, can't you do it in O(n!)? Not that that's fast, exactly...

Date: 2006-01-05 06:25 pm (UTC)
From: [identity profile] pmb.livejournal.com
Totally could. (actually, $O(\sum_{i=0}^n {(n choose i) * i!})$ which I think is still O(n!), but I'm not entirely sure... That would make a good intro to algorithms and data structures question.)

Try all permutations of n letters, in reverse lexicographic order, then all permutations of all size n-1 subsets in some appropriate order. The only issue is coding all of that up. The reverse lexicographic order thing isn't too bad, but doing all of the subsets and pulling off the next candidate in the right order is a tricky bit of combinatorial coding that I would prefer to avoid. Using some heuristics, [livejournal.com profile] coldtortuga was able to get the base 10 case down to 10 seconds of searching, but I don't know if his techniques generalize to other bases.

I suppose one could make a heap of generators that would yield the front of the lowest generator on the heap. In the worst case there would be O(n!) generators, but that's only O(n lg n) to pull the top one off the heap, and the answer would probably be found before the heap got to be too large. That would be memory intensive, but not too bad otherwise. Heapification is pretty quick... I bet I could use this technique to find the sequence up to base 14, maybe!

But it sounds like a whole lot of work for just 4 more terms. I prefer to throw CPU at the problem and then walk away if that doesn't suffice. Optimizing non-polynomial algorithms just isn't very fun. Finding a polynomial algorithm is, and so is proving a problem impossible. But I don't see how this problem is NP complete (it seems over-specified, which makes reductions difficult), it doesn't seem like it has a polynomial solution, and number theory was always my most dicey section in discrete math.

Date: 2006-01-05 06:53 pm (UTC)
From: [identity profile] mycrust.livejournal.com
Yeah, this problem has the flavor of something that someone clever could find a way to speed up dramatically by reducing the search space using some generalized facts about divisibility. I am not capable of doing that though. And the answer is kind of cooler than the method anyway.

Date: 2006-01-10 09:46 pm (UTC)
From: [identity profile] coldtortuga.livejournal.com
My "heuristic" approach pretty much follows the algorithm described by [livejournal.com profile] pmb, which is (as ya'll surmise) O(n!).

In base n, start with the set of usable digits D={1, ..., n-1}. For each non-empty subset d of D (in Gray-code order, 'cause I already had a Gray-code subset generator), I find and test all the permutations of d (in the order given by Heaps' algorithm, 'cause I already had Heaps coded up). Gray-code + Heaps' algo does not the most efficient search-order make, but it's not too shabby.

The number of candidates to test in base n is given by A007526 which grows like e*n!

Date: 2006-01-09 07:49 pm (UTC)
From: [identity profile] coldtortuga.livejournal.com
Cool! That's a neat generalization :-)

(I'm just now catching up on lj after 2 weeks at my parents' home in Alaska. They only have internet connectivity via the phone line, e.g., "[ring ring ring] Hey Jen, are you near your mom's computer? Could you look up the World Cup groups and read them off to me, pretty pretty please??")

My code spat out the base-eleven answer in a few minutes (A9876241311 = 233436420010) but it's been cranking for a couple hours now on base-twelve. The numbers are big enough to require Python "long" integers, which are waaaaay slower than native-hardware integers; I probably need a thorough re-writing of my generators to avoid so many multiplications and function-calls.

Date: 2006-01-09 09:21 pm (UTC)
From: [identity profile] coldtortuga.livejournal.com
Somewhat disturbingly, my code reports B935217612 = 42187761010 for base-twelve. Hmmmm... [taps teeth]

Date: 2006-01-09 10:44 pm (UTC)
From: [identity profile] pmb.livejournal.com
Makes sense - you can't have a 0 as the final digit, which means that you can't have a multiple of 4 *and* a multiple of 3 in there, so either 4 and 8 are out or 3,6, and 9 are. Which means that you can have at most 9 digits. Why you can't have an A in there, I'm less sure, particularly since it is definitely divisible by A, as it is divisible by both 2 and 5.

Date: 2006-01-09 10:48 pm (UTC)
From: [identity profile] pmb.livejournal.com
(note that the intuition I gave for 12 means that 13 will most likely be some friggin huge number, due to its primeness)

Date: 2006-01-10 02:54 pm (UTC)
From: [identity profile] coldtortuga.livejournal.com
For base thirteen: CBA9584721313 = 177970067352010. Good intuitin' :)

Date: 2006-02-13 03:51 am (UTC)
From: [identity profile] conform.livejournal.com
so josh and paul started on this today in haskell, hoping to take advantage of lazy evaluation in generating the descending seqence of possible answers. it's got a ways to go, but n=13 runs in 23 minutes on josh's 3GHz P4. n=12 is under a second! we're going to apply the beer optimization now and see where it gets us.

Profile

pmb: (Default)
pmb

October 2009

S M T W T F S
    1 23
45678910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 17th, 2026 09:08 am
Powered by Dreamwidth Studios