Programmer Challenge

Discussion in 'Programming' started by Vinil Mehta, Aug 23, 2011.

  1. #1
    How to write a program that will return numbers when user enter some string like two thirty,it must return 230 as output?:)
     
    Vinil Mehta, Aug 23, 2011 IP
  2. [GotHost] James

    [GotHost] James Guest

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Now you're talking language processing, because a user could type 'two thirty', 'two hundred thirty', 'two-thirty', etc.
    If you want to interpret it literally as 'two' followed by 'thirty' then you could just replace each number with its digit equivalent.

    e.g. two => 2, thirty => 30

    Would cause issues with 'two thirty two' though, you'd end up with 2302. Hence the language processing issue.
     
    [GotHost] James, Aug 23, 2011 IP
  3. Vinil Mehta

    Vinil Mehta Member

    Messages:
    190
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    48
    #3
    then what happens when user types two hundred thirty two?I want that when user types two thirty two ten then 232 gets multiplies by 10 and displays the result i.e 2320.help me regarding this
     
    Vinil Mehta, Aug 23, 2011 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    As James said, you have to write a language processor. That's not something someone can post the code for here - a language processor that can handle human language is a lot more complex than, say, a processor to handle a computer language like PHP.
     
    Rukbat, Aug 23, 2011 IP
  5. Histori007

    Histori007 Banned

    Messages:
    142
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #5
    Only one I think,,,230 is very strings
     
    Histori007, Aug 23, 2011 IP
  6. Vinil Mehta

    Vinil Mehta Member

    Messages:
    190
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    48
    #6
    so what should i do ?Please tell me that .
     
    Vinil Mehta, Aug 23, 2011 IP
  7. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #7
    Learn how to write a human language processor. It should take about a year or two of full-time study. (IOW, this is not a trivial task.)
     
    Rukbat, Aug 24, 2011 IP
  8. Vinil Mehta

    Vinil Mehta Member

    Messages:
    190
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    48
    #8
    what is human language processor?kindly tell me how does it help me in java programming
     
    Vinil Mehta, Aug 24, 2011 IP
  9. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #9
    A "number" like "two hundred thirty" is human, or "natural", language, unlike 230, which is something a computer can read with no help. You need a program that can read that and figure out what the person who entered it meant. The person could enter "two thirty", "two hundred thirty", "two hundred and thirty", etc., and they're all 230.

    Writing a program like that will take you a very long time (a year or so if you include the time it will take you to learn enough about programming to do it), so I don't recommend that you even try until you've learned enough so you don't have to ask about it.
     
    Rukbat, Aug 25, 2011 IP
  10. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #10
    MyVodaFone, Aug 25, 2011 IP
  11. Vinil Mehta

    Vinil Mehta Member

    Messages:
    190
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    48
    #11
    thanks for the help
     
    Vinil Mehta, Aug 25, 2011 IP
  12. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #12
    MyVodaFone, that's numbers to words. The OP wants words to numbers. Numbers to words is trivial.
     
    Rukbat, Aug 26, 2011 IP
  13. skylark11

    skylark11 Greenhorn

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #13
    you can make dictionary imput on every single word what will it be its meaning in numbers... we've done it in our faculty... the program ise easy to be made.
     
    skylark11, Aug 26, 2011 IP
  14. thetechtalk

    thetechtalk Active Member

    Messages:
    233
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #14
    @OP what we're saying is it's extremely hard to do.
     
    thetechtalk, Aug 26, 2011 IP
  15. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    819
    Best Answers:
    7
    Trophy Points:
    320
    #15
    If you allow the user to use free form entry, you will find it is far beyond your current capabilities to write such a program.

    However, if you strictly limit what the user can enter, or better yet, only allow the user to select from a drop down list, the programming to do what you want is relatively trivial.
     
    mmerlinn, Aug 27, 2011 IP
  16. Vinil Mehta

    Vinil Mehta Member

    Messages:
    190
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    48
    #16
    then i think javascript would be helpful for restricting user from delivering such inputs
     
    Vinil Mehta, Aug 28, 2011 IP
  17. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #17
    6 or more drop down boxes across the screen would be a really simple way, with titles like, Million, Hundred Thousand, Thousand, Hundred, Tenths, Units

    Or a harder way would be through a database, if you consider auto increment each id = a number.

    Populating the first one - one hundred would be the most tiresome, then php could do the rest.

    User input could be preg_match after a few checks, to display the corresponding id number.
     
    MyVodaFone, Aug 29, 2011 IP
  18. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #18
    Last edited: Sep 1, 2011
    MyVodaFone, Sep 1, 2011 IP