generate an output pattern
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Example: if n=9, display
*000*000*
0*00*00*0
00*0*0*00
000***000
-
2 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Tim Driven Development | Test until the fear goes away
-
2 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Tim Cooke wrote:I believe it satisfies your requirements.
Not quite I don't think. If the pattern depends on n, it suggests the pattern will be different for different values of n, so I think the code should be
Joanne
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
@chrstian Nobody is going to write the code for you (see NotACodeMill), but if you come up with a more detailed specification* we will certainly try to help you write the code.
* For example
How does that pattern relate to the value 9 ?
What are the patterns for other values of n ?
Is there an algorithm for working out the pattern given a value of n or are they just random patterns assigned to each value ?
Joanne
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
However, before we get off an a tangent, I threw in that somewhat glib response to highlight the fact that you have not specified your problem enough to be able to write a complete solution for it. A point that Fred has made in a more straightforward manner.
Another point to not is that we are NotACodeMill, which means that nobody is going to give you the solution. What we will do is help and guide you into solving the problem yourself. That's how we learn.
Tim Driven Development | Test until the fear goes away
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Joanne Neal wrote:* For example
How does that pattern relate to the value 9 ?
That's what I was trying to work out.
As far as I could see, each pattern is 9 characters long, and is made up of 6 '0's and 3 '*'s; but since 9 is the ONLY single-digit odd number that isn't prime, it doesn't seem to give much of a clue.
Winston
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Tim Cooke wrote:I threw in that somewhat glib response to highlight the fact that you have not specified your problem enough to be able to write a complete solution for it.
I certainly agree with your point, but it's actually kind of a neat challenge if you take it as one of those "intelligence test" questions.
My observations:
1. All patterns involve '*' and '0'.
2. All patterns are mirror images about a central '*'.
3. All patterns involve exactly one '*' in their "halves".
4. In order, they move from '*' on the outside, to '*' nearest the centre.
So my solution for n=7 would be:
"*00*00*"
"0*0*0*0"
"00***00"
and for n=5:
"*0*0*"
"0***0"
for n=3:
"***"
and if n=1 has a solution:
"*"
Anyone have a different solution?
Winston
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
chrstian ferma wrote:Write a program that will display a pattern depending on n. Assume n as a one digit odd number.
Example: if n=9, display
*000*000*
0*00*00*0
00*0*0*00
000***000
cause i cant understant how the pattern generated , i believe this one can easily done by for loop thank you , i appreciate the answers i believe n=9 then system.out the expected output is not what im trying to explain but it's a valid answer due to not detailed question
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Winston Gutkowski wrote:
Joanne Neal wrote:* For example
How does that pattern relate to the value 9 ?
That's what I was trying to work out.![]()
As far as I could see, each pattern is 9 characters long, and is made up of 6 '0's and 3 '*'s; but since 9 is the ONLY single-digit odd number that isn't prime, it doesn't seem to give much of a clue.
Winston
thank you what im looking is a guidance not the exact answer
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
chrstian ferma wrote:cause i cant understant how the pattern generated...
Well I'm afraid that's an absolute must. All I've been doing is musing about possibilities.
If this is for a class, then I suggest you ask your tutor, because what you've given us is definitely not enough to go on.
Winston
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
chrstian ferma wrote:cause i cant understant how the pattern generated
In that case it's not a Java problem, it's a logic problem.
And if that's all the information you have, then Winston's guess is as good as anyone else's. But for that matter, so is Tim's.
Joanne
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Winston Gutkowski wrote:
chrstian ferma wrote:cause i cant understant how the pattern generated...
Well I'm afraid that's an absolute must. All I've been doing is musing about possibilities.![]()
If this is for a class, then I suggest you ask your tutor, because what you've given us is definitely not enough to go on.
Winston
thanks i believe i need more details regarding this
| There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |









