#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    I need a program


    Hi. I need a program like this. When you start it it will want you to select a .txt file. When you select it, it will add "*-" between every letter. Then it will save the txt.

    Example:

    Hello.
    I'm living in England.
    I like swimming.
    ....

    Result:

    H*-e*-l*-l*-o*-.*-
    I*-'*-m*- *-l*-i*-v*-i*-n*-g*- *-i*-n*- *-E*-n*-g*-l*-a*-n*-d*-.*-
    I*- *-l*-i*-k*-e*- *-s*-w*-i*-m*-m*-i*-n*-g*-.*-

    The programming language is not important. Please help me.
    ....
  2. #2
  3. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1802
    Originally Posted by Seytingui
    it will add "*-" between every letter.
    Your example however adds "*-" after every character; so that's two ambiguities in your requirements already!


    Note that this site is not a free programming service, nor a homework cheating service, but is intended for those genuinely interested in programming and learning more. If you were genuinely interested you would have at least made a start and be asking more specific questions about areas you do not understand.

    Since I can think of no practical purpose for such a program, I have to assume that this is a homework exercise?
  4. #3
  5. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,379
    Rep Power
    1871
    > The programming language is not important. Please help me.
    Sweet.

    The input, the program and the output
    Code:
    $ cat foo.txt
    Hello.
    I'm living in England.
    I like swimming.
    $ cat foo.bf
    +
    >
    +++++++
    +++++++
    +++++++
    +++++++
    +++++++
    +++++++
    >
    +++++++
    +++++++
    +++++++
    +++++++
    +++++++
    +++++++
    +++
    <<
    [
    ,
    .
    >
    .
    >
    .
    <<
    +
    ]
    $ cat foo.txt | bf foo.bf
    H*-e*-l*-l*-o*-.*-
    *-I*-'*-m*- *-l*-i*-v*-i*-n*-g*- *-i*-n*- *-E*-n*-g*-l*-a*-n*-d*-.*-
    *-I*- *-l*-i*-k*-e*- *-s*-w*-i*-m*-m*-i*-n*-g*-.*-
    *-�*-$
    Not a perfect match, but enough for a proof of concept :winkgrins

    Comments on this post

    • ptr2void agrees : Sweet indeed!
    • MrFujin agrees : Did think about making something obscure too.. but not at this level of craziness :D
    • Scorpions4ever agrees : For even attempting to write a program in brainf*ck.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    3
    Rep Power
    0
    It is very difficult. I nedd same programs end i send at programmer undian!
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,145
    Rep Power
    2222
    Originally Posted by Ion83
    It is very difficult. I nedd same programs end i send at programmer undian!
    Does that mean this is for a job application?

    So then when you do get the job, you will be pestering us non-stop for us to do your work for you?
  10. #6
  11. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    Salem kicked my buttocks. I've never heard of bf .

    This j program exactly matches the description (not the example)
    Code:
    (;,&'*-'^:(e.&Alpha_j_)&.>1!:1<'input')1!:2<'output'


    Code:
       NB. corrected per following posts
       anyLanguage=: {: ,~ [: ; 2&(<@({.`('*-' ,~ {.)@.(1 1 -: e.&Alpha_j_))\)
    
       I
    this long test
    makes me
    sweat
    
       anyLanguage I
    t*-h*-i*-s l*-o*-n*-g t*-e*-s*-t
    m*-a*-k*-e*-s m*-e
    s*-w*-e*-a*-t
       NB. end correction
    input:

    this long test
    makes me
    sweat


    output (wrong (given that we haven't yet discerned correct)):

    t*-h*-i*-s*- l*-o*-n*-g*- t*-e*-s*-t*-
    m*-a*-k*-e*-s*- m*-e*-
    s*-w*-e*-a*-t*-
    Last edited by b49P23TIvg; September 4th, 2012 at 09:06 AM.
    [code]Code tags[/code] are essential for python code and Makefiles!
  12. #7
  13. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1802
    Originally Posted by b49P23TIvg
    This j program exactly matches the description (not the example)

    t*-h*-i*-s*- l*-o*-n*-g*- t*-e*-s*-t*-
    m*-a*-k*-e*-s*- m*-e*-
    s*-w*-e*-a*-t*-
    The description says between every letter. You have it after every letter. There should be no *- after the final letter because that is not between anything.

    Your output also has *- between a letter and a newline.

    Strictly to teh description, output should be:
    Code:
    t*-h*-i*-s l*-o*-n*-g t*-e*-s*-t
    m*-a*-k*-e*-s m*-e
    s*-w*-e*-a*-t
    and for the original example:
    Code:
    H*-e*-l*-l*-o.
    I'm l*-i*-v*-i*-n*-g i*-n E*-n*-g*-l*-a*-n*-d.
    I l*-i*-k*-e s*-w*-i*-m*-m*-i*-n*-g.
    i.e. the test is if the previous character was a letter, and the next character is a letter, output !*-".

    I am of course just pointing out the ambiguity in the specification in the hope that the OP would clarify the requirements. If this is how the question was posed to him by his tutor, perhaps he needs to ask the tutor to clarify.

    Comments on this post

    • b49P23TIvg agrees : mmm good point. Also in error, I have heard of bf by its unabbreviated name. See whitespace code:
    Last edited by clifford; September 4th, 2012 at 04:53 AM.

IMN logo majestic logo threadwatch logo seochat tools logo