Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Medium] Find 9 with a twist

 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
6 is 136
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Upon further thought, you seem to have a problem. 987652413 does not meet the criteria. 413/3 = 137 R 2.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Homemade sounds good to me.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 expected
  • values 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
    Posts: 15385
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 15385
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 18671
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Just gpt pff pf wprl
    Ummm... I may have an idea what's wrong with your code, Eric.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic