#How to print this pattern using double dimensional array

65 messages · Page 1 of 1 (latest)

civic cave
#

The word (in this case HAPPY) which is used in the dda to print that pattern needs to be accepted from user and has to be an odd number of characters which is >=5 and <=19.
I do not have any code written as I'm not aware how to get this type of a pattern in a DDA

still duneBOT
#

This post has been reserved for your question.

Hey @civic cave! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

civic cave
#

I need help for both the patterns, never seen something like this before

quaint talon
#

let's do the second one first, that one's easier

#

what's the pattern there?

#

not as in "rectangle", but in rows and columns

civic cave
#

the rows need to be the length of the word for example if the length of word entered by user is 7 so there needs to be 7 rows (eg: tuesday, so the rows need to be spelled as tuesday)
as for the columns i think we can do double number of rows

quaint talon
#

yep

#

and then how do you fill the pattern there

grand geyser
still duneBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

civic cave
#

defeats the purpose of asking us to write the code

civic cave
#

i didnt understand

quaint talon
#

describe what the pattern is like in words

civic cave
#

so the second one

#

is a rectangle

#

u accept word from user in the example of the picture i sent its happy

#

so essentially its like

#

the first row is supposed to be filled with the first letter of the word

#

and the number of times is supposed to be 2x the number of rows

#

so column = 2 x row

#

and the middle parts is supposed to be empty

quaint talon
quaint talon
civic cave
#

like

#

its all blank in the middle

quaint talon
#

what about the sides

#

and what about the last row

civic cave
quaint talon
#

no, put it in words

civic cave
#

as in?

#

i dont get it

quaint talon
#

just like you've done for the first row

#

once you have those in words, you effectively have a concrete description of the pattern
you can then implement that

civic cave
#

ok got it, lemme try it now

#

but wait before i attempt

#

how do i get the blank spaces in

quaint talon
#

that would be in the loop, you print a space for each character of the pattern you print

#

but you can ignore that for now, get the actual pattern down first

civic cave
#

How do i even put the letters of the word in the rows

quaint talon
#

generally you can use loops for that

still duneBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

civic cave
#

im not aware of how to like put it in the rows

#

like ik for the first row it'd be like extracting the first character and printing it and for last extracting the last character

quaint talon
#

yep

#

use 2 loops
the outer one represents rows and the inner one represents columns

quaint talon
#

you can loop over the string with String.length() and String.charAt(int index)

civic cave
#

loop over the string?

#

as in

quaint talon
#

with a for loop, for example

still duneBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

civic cave
#

is dm'ing u an option? coz this post has been open for a while

quaint talon
#

no

still duneBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

civic cave
#

got an idea from what u said

#

thnx for the help much appreciated