We're goin' Loopy

Steven G

Elite Member
Joined
Dec 30, 2014
Messages
14,382
With getting actual 5digit numbers (missed that!),
there are 30 solutions:
1: 13999
2: 19399
3: 19939
...
28: 99391
29: 99913
30: 99931
Now that you have 200 posts you have to go to the corner for 40 minutes for this mistake.
 
With getting actual 5digit numbers (missed that!), there are 30 solutions …
My nested loopers gave me the numbered list last night, in less than one second. (But the coding took about three minutes; forgot Maple's weird closing delimiter 'od' -- had to look it up.)

Also, I had thought kolev02 was taking a beginning programming course (where "efficiency" doesn't matter).

I will, however, go to the corner for 2,187 seconds, as I mistakenly posted 'combinations' when I meant 'permutations'.

Edit: And, no, I'm not going to play Xs & Os with you, Denis. :p
 
Last edited:
Edit: And, no, I'm not going to play Xs & Os with you, Denis. :p
....ah c'mon...I'll let you go first....

Is your program along the lines of:

FOR a = 1 TO 9 STEP 2
...
FOR e = 1 TO 9 STEP 2

???
 
Yeah, but, nah. (I wasn't concerned about "efficiency".)

Instead of stepping through the odds, you could write a new looping subroutine (in machine language -- for extra efficiency) that starts with index 1, incrementing by a factor of 3, until the index reaches 9, whereupon the loop is closed.

And, thanks for reminding me; I need to delete my temp file.

Code:
[FONT=Courier New]> n:=0;
> for a from 1 to 9 do
>   for b from 1 to 9 do
>     for c from 1 to 9 do
>       for d from 1 to 9 do
>         for e from 1 to 9 do
>           if a*b*c*d*e=2187 then
>             n:=n+1;
>             print(a,b,c,d,e);
>           fi
>         od
>       od
>     od
>   od
> od;
> print(n);[/FONT]

That's right! I do not annotate my code, either. :cool:
 
Top