how wud you write a code that wud convert a string of any input into a cool X formation

for example if you had a string "names" how would you write it in the formation:

[I]n    n
 a  a
  m
 e  e
s    s[/I]

Or for example if you had something like "places" would appear as:

p     p
 l   l
  ac
  ac
 e   e
s     s

Edited 5 Years Ago by jacksparrow01: n/a

And what have you tried?
Do not forget the CODE-tags.

I do not get your second example. I coded the thing and this is what my program managed to produce from the two words.

n     n
 a   a
   m
  e  e
 s    s

p      p
 l    l
  a  a
    c
   e  e
  s    s

Coding this is easiest for me at least by prove and fix, first before middle loop, then printing middle, lastly bottom half.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Comments
thanks

I used a for loop just for a little variety. And I would also think it should be (but that is just my opinion)

p     p
 l   l
  aa     <-- not reversed
  cc     <-- reversed
 e   e
s     s

Edited 5 Years Ago by woooee: n/a

well my thought was to use an if statement to check whether it has an odd or even number of letters something like:

if (len(string)%2==0):

and then do the loop for the even numbered string

Edited 5 Years Ago by jacksparrow01: n/a

I used a for loop just for a little variety. And I would also think it should be (but that is just my opinion)

p     p
 l   l
  aa     <-- not reversed
  cc     <-- reversed
 e   e
s     s

is your code generalised or does it nly work with that word

I did generalized version, but it is not in one loop but in three phases above, center and down.

n    n
 a  a
  m
 e e
s   s

p     p
 l   l
  aa
  cc
 e  e
s    s

P                       P
 y                     y
  t                   t
   h                 h
    o               o
     n             n
                   
       l         l
        a       a
         n     n
          g   g
           uu
           aa
          g  g
         e    e
                
       R        R
      O          O
     C            C
    K              K
   S                S
  !                  !
 !                    !
!                      !

how the heck did you code that??? my code only works for a length 5 string. excuse me but im new to programming. 3 weeks new in fact.

This article has been dead for over six months. Start a new discussion instead.