| Author |
[Medium] Find 9 with a twist
|
Michael Morris
Ranch Hand
Joined: Jan 30, 2002
Posts: 3451
|
|
Find 9 is really a bad name for this one but it is similar in that we are looking for numbers whose last digit divided into itself results in 0. Using the set of digits 1-9 and input of the number of digits (always starting with 1 and going in sequence) and the grouping of digits, create a method that will return a count of all the permuations such that each sequetial group meets the rule stated above. For example: 637284591 (group by 3) 637/7 has no remainder. 372/2 has no remainder. 728/8 has no remainder. 284/8 has no remainder. 845/5 has no remainder. 459/9 has no remainder. 591/1 has no remainder. The correct count if digits were 3 and group were 2 would be 2 as follows: 123 false; 132 false; 312 true; (31/1 and 12/2) 321 true; (32/2 and 21/1) 231 false; 213 false; As a test (and I'm not 100% sure about this ) for 6 digits grouped by 3 I got 136 permutations that met the criteria. This one is worth a box of Peanut Butter cookies Eric. You'll have to use a form for this one. [ June 01, 2003: Message edited by: Michael Morris ]
|
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
Hey I can use forms if I want to and I can cry if I want to. I will play with it tom. morning....Have some other business to tend too. LOL Eric
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
okay this took longer since I have a really ugly, not well thought out code, but I got an answer of 686. It has 9 loops with checks after every loop. http://www10.brinkster.com/a1ien51/JavaRanch/FindNums3.htm Eric [get rid of the mistake] [ June 03, 2003: Message edited by: Eric Pascarello ]
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
|
6 is 136
|
 |
Michael Morris
Ranch Hand
Joined: Jan 30, 2002
Posts: 3451
|
|
So, what brand of cookies do you like? Or would you prefer some of my wife's homemade peanut butter cookies?
|
 |
Michael Morris
Ranch Hand
Joined: Jan 30, 2002
Posts: 3451
|
|
|
Upon further thought, you seem to have a problem. 987652413 does not meet the criteria. 413/3 = 137 R 2.
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18652
|
|
Homemade sounds good to me.
|
"I'm not back." - Bill Harding, Twister
|
 |
Michael Morris
Ranch Hand
Joined: Jan 30, 2002
Posts: 3451
|
|
Homemade sounds good to me. A man with true taste! Looking at your table, there seems to be a pattern there but I can't quite put my finger on it. Did you notice anything? Of course the 1 grouping always yields the factoral value. Maybe I'm just seeing things again.
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18652
|
|
Well I noted some general trends in the numbers, and wondered if we were to graph them, how smooth would the graph be, and is there some simple equation for it? Specifically I noted values for group = 1 for a series of factorials, as expectedvalues for group = 2 have a surprising number of zeros - though not quite all of them.from group = 2 on, count increases with increasing group or increasing digits Just for the heck of it, I tried running the program past 9 digits. It's rougly akin to using hexadecimal digits, but decimal rules of position. E.g. 3B = 3 * 10 + 11 = 41. Weird way to overload decimal. I include some of these results below - they're just an extension of the previous result table. But things bog down quite a bit as we go; I'd like to make a complete table for 16 hexadecimal digits, but need to refactor for speed first. Anyway, in case you can spot any futher patterns: [ June 02, 2003: Message edited by: Jim Yingst ]
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
That is pretty funny, lol, for some reason it is excepting 2's...hmmm. Just gpt pff pf wprl and have to be back ther in 8 hours, so I do not feel like messing with the code. Eric
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
LOL,,,,i see my problem...such a dumb @$$ I am.... I never upated the loop from playing with the four, so it was saying that anything was correct as long as the first two were,,,ugh, will change it tom. Eric [edit] I could not sleep. so i fixed it Got 686 which I see matches. [/edit] [ June 03, 2003: Message edited by: Eric Pascarello ]
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18652
|
|
Just gpt pff pf wprl Ummm... I may have an idea what's wrong with your code, Eric.
|
 |
 |
|
|
subject: [Medium] Find 9 with a twist
|
|
|