You are not logged in.
The early 90's...I remember them well! I couldn't even spell ASM back then! But that wasn't a requirement of ASM, was it? Unless you documented your code with rems to make sense of the blur!!
Well, I don't have your intimate knowledge of your machine.
...or three!!
That's using JM's, I guess. Have you tried it on George's yet?
Hmmm...that's odd! OneDrive has always worked for me before.
Try these links. They're on Filedropper, which I've never used before. It works when I tested it, but you have to complete a captcha for each file...which I didn't know before I uploaded them.
What file host do you use for file sharing on forums?
Edit: The above links no longer seem to work, so I went back to post #33 and changed the links to ones that work...at least for now (for me)!
It's the same idea as my post #19, where I included it in the first line of your code that I changed.
This time I made it a bit bigger...and I'm not sure if I should try it on your code!
With n = RandomInteger[10^100000] in the first line of code.
Do you want to see it, and the solution?
Maybe you're a rough diamond?
J.M. is a very talented guy and a good EM too.
His code backs that up!.
I tried his and George's codes on a random 100,000-digit number that has a solution. JM's took approx 14.3 seconds to solve it, and George's approx 767 seconds. So their speed comparison has changed dramatically with this much larger number!
Hi Bobby;
If he's checking his pulse to see if it's still ticking, something else isn't ticking as it should!
So, mine took 3 hours+ and his took .02 seconds....
George's time was 5 times that of JM's.
I ran yours again overnight on the same number, and solving time was just over 6 hours. Just to put the 'just' part into perspective when compared to JM's time, just that part alone (ie, without the 6 hours part) is just over 5732.31012092 times the speed of JM's. So now you know how many seconds yours took - within a smidgen.
I give JM's comment - "A ploddingly procedural implementation" - a like.
What is 'the diamond effect'?
Hi Bobby;
'Obsolete'?? I take it the meaning is in the teenage-speak word-inversion sense.
As wicked = good/great, and sick = cool/awesome, so obsolete = now/happening/up-to-the-minute. eg, someone referred to as being 'obsolete' is really a now (as in right now)/up-to-date person, with his finger right on the pulse. And no, he's not checking his pulse to see if it's still ticking!
Just to confirm that it's not the number size that's the problem with your code, I gave it this 1000-digit number to solve:
I don't know how long it took because I forgot to include the timer in the code, but it started looking for the answer late this afternoon, was still busy at it 3 hours or so later when I had to go out, but when I got home 2-and-a-half hours later it was waiting for me with the answer:
JM found the same solution as yours in 0.004 seconds, and George found it in 0.020 seconds.
George's check says "True" in each case, but I haven't checked it myself. I'm happy to accept George's code's say-so!
That's what it also does with the two numbers I mentioned in post #15 (12398 and 123476). Those two don't have a solution, but the 50-digit one does.
I don't know what the number was, as I used RandomInteger[10^50] to generate it and didn't save it.
This is my changed version of your code that I used. It includes George's check.
m=RandomInteger[10^50]
n=IntegerLength[m];
var=Table[Subscript[a,k],{k,n,1,-1}];
f=Sum[1/9 (-1+10^k) Subscript[a,k],{k,1,n}]==m;
s=FindInstance[Append[{f,10>Subscript[a,1]>0},Table[10>Subscript[a,k]>=0,{k,2,n}]]//Flatten,var,Integers];
FromDigits[Flatten[var/.s]]
Total@NestWhileList[Floor[#/10]&,%,#>0&]==m
I think you'll find most numbers will work: eg, 69586679352243945460884074620809492862023430738549. That works in JM's & George's too, and comes up as "True" in George's check.
38994141682523903136734583674252327906171348631335 has a solution, but your code complains. Try it!
Hi Bobby;
He must have edited it later on and left out a bracket.
He had one bracket too many.
In the end I had to accept J.M.'s code because it was the fastest.
Theirs were both instantaneous on a 50-digit number.
Mine gags on a large example, theirs do not.
Yours got the right answer on that same 50-digit number (in 0.14 seconds), so it wasn't the length of the input number that was the problem.
Interesting...what I understand of it!
Anyway, here are some things I've noticed:
1. A correctness check is needed, as george2079 said.
eg, 12398 and 123476 have no solution, treated this way by the 3 codes:
- george2079's code gives "the 'closest' value", and, helpfully, his check announces "False";
- J. M.'s code just gives the 'closest' (I suppose) value - like george2079 - with no correctness announcement;
- Your code gives strange-looking answers...which probably indicates that they don't have a solution.
2. george2079's code has an error that prevents me from running his program (one of the closing brackets after Divide @@ # has to go), and should be:
m = 308460277;
Reap[NestWhile[{#[[1]] - #[[2]] Sow@Floor[Divide @@ #],
Floor[#[[2]]/10]} &, {m,
FromDigits@ConstantArray[1, Ceiling@Log[10, m]]} , #[[2]] >
0 &]][[2, 1]] // FromDigits
3. george2079's check could be improved by replacing the answer input with "%", like so (his way would have been for clarity's sake, I guess):
Total@NestWhileList[ Floor[#/10] &, %, # > 0 &]==m
4. Your code fails on some valid inputs (answers found by the other two guys' codes): eg, 12333, 12344, 12355, 12366, 12377, 12388, 12399.
They might be the only fails, but I didn't check right up to infinity.
5. A little tweak for your code (which I know you already know! )
First line: m = 308460277; n = IntegerLength[m];
I wonder what percentage of numbers fail, and their composition? But I don't really need to know...
Ah, yes...that's the one I missed.
I'd been looking in the Tuples, Permutations and Subsets general area, but overlooked Outer for some reason, even though it appears as a 'See Also' under Tuples.
Hi Bobby;
I tried to code it in M, but only succeeded with the BASIC approach like in my post #6 (but with slightly shorter code):
aa={A,G,P,W};
ff={F,P};
bb={B,T,Z};
ee={E,M,Q,R};
For[a=1,a<5,a++,For[f=1,f<3,f++,For[b=1,b<4,b++,For[e=1,e<5,e++,
Print[aa[[a]],ff[[f]],bb[[b]],ee[[e]]]]]]]
Anyway, something new I learned was that uppercase E (in variable ee) is reserved for exponential constant e.
At first I thought I'd have to change the letter, but then discovered that although M's output prints E as e, when the output is copied as plain text and pasted here (and in other software), e prints as E.
Hi thickhead;
Yes, that's how I did it too, but without the plus sign in column E (not needed).
Hi thickhead;
Looks like you left out the opening instruction about writing {B,T,Z} into Column C.
Works fine, otherwise.
Hi Edossa;
Here's a program in BASIC that generates all possible answers...which are the same as those already posted.
The code is in LibertyBASIC, and can be run online here. Click on the 'Write Your Own' tab if the editor page doesn't open.
a$="AGPW":f$="FP":b$="BTZ":e$="EMQR"
For a=1 To 4
For f=1 To 2
For b=1 To 3
For e=1 To 4
Print Mid$(a$,a,1);Mid$(f$,f,1);Mid$(b$,b,1);Mid$(e$,e,1)
Next e
Next b
Next f
Next a
Even so, my scratching implements are much shorter and blunter than yours. My time is taken up with so many other things that M will always have to take a back seat. Can't see that ever changing...
I have v10.2.0.0, and I'm still only starting out scratching the surface of that!
I was not able to solve the problem entirely using the new Geometry commands.
Do you mean the new ones in the recent new M version? I haven't upgraded...too costly and probably not needed for my junior use, I think.
So I guess that would be a different method from mine in post #21 of Mathegocart's thread.
I've since changed that to this, in radians:
r=3959*5280;
th=th/.FindRoot[2r Tan[th ]-100-2r*th==0,{th,0.02},WorkingPrecision->100]
h=r Sec[th]-r
0.01928719490295484482441479028250059270451052188967101077078489520191892182137176188340647018275855175
3888.614460593728239463379167602010692449187441461292338724354316092744378397068689244933991315452952
What answer do you get, and what is your M way?
It's been very interesting...thanks for starting us off!