• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to delete duplicate characters

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey so big test tomorrow, worth like 15% of final grade and I was doing some study on past papers and one of the questions asks to convert all words into stem words. A stem word is produced from a suspect word by first removing all characters except for consonants. Then all duplicate letter sequences are removed. The Stem word for "Viagra" would be "vgr and the stem word for "vla-grrra" is also "vgr".
This is what I'v done so far


Any help would be great
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what has it to do with webservices?
 
Sara Lyons
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Praful Thakare wrote:what has it to do with webservices?


Sorry had no idea its meant to be a java question, I just joined
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I moved the thread to "Beginning Java".
 
Sara Lyons
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:I moved the thread to "Beginning Java".


Thanks!
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sara Lyons wrote:
//this loop doesnt really work and I don't know what to do after the if statement
//im trying to delete duplicate characters in this loop and if statement but not really sure how to go about it
...Any help would be great


Before you even write a line of code, you need to stop and think about how you do things.

Think about it in English - not Java. If I gave you a piece of paper with a string of characters on it, how would YOU remove duplicate characters?
 
security forum advocate
Posts: 236
1
Android Flex Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


 
Sara Lyons
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

fred rosenberger wrote:

Sara Lyons wrote:
//this loop doesnt really work and I don't know what to do after the if statement
//im trying to delete duplicate characters in this loop and if statement but not really sure how to go about it
...Any help would be great


Before you even write a line of code, you need to stop and think about how you do things.

Think about it in English - not Java. If I gave you a piece of paper with a string of characters on it, how would YOU remove duplicate characters?


Emm I'd cross them off the paper?? I'm so bad at java epic fail tomorrow .
 
Sara Lyons
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sai Hegde wrote:


THANK YOU SO MUCH!
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sara, is it possible that you might be asked to explain that solution? Because I have the feeling that you don't completely understand it. If that happened, then you might be in trouble for plagiarism. And it's not a beginners technique that you've been given there, so using it might well cause the examiners to become suspicious.

Unless the rules for your exam specifically allow you to get help from other people, that is. In that case you would be in the clear.
 
Sara Lyons
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Sara, is it possible that you might be asked to explain that solution? Because I have the feeling that you don't completely understand it. If that happened, then you might be in trouble for plagiarism. And it's not a beginners technique that you've been given there, so using it might well cause the examiners to become suspicious.

Unless the rules for your exam specifically allow you to get help from other people, that is. In that case you would be in the clear.



No it's no problem if I get help, sure my lecturers always saying when your stuck ask anyone but if this was an assignment then it would be a different story.
No I didn't really understand what ("(\\w)\\1+", "$1") and ("\\P{L}", "") mean in "String enter3= enter2.replaceAll("(\\w)\\1+", "$1")" and "String enter1 = enter.replaceAll("\\P{L}", "")".
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sara Lyons wrote:

Paul Clapham wrote:Sara, is it possible that you might be asked to explain that solution? Because I have the feeling that you don't completely understand it. If that happened, then you might be in trouble for plagiarism. And it's not a beginners technique that you've been given there, so using it might well cause the examiners to become suspicious.

Unless the rules for your exam specifically allow you to get help from other people, that is. In that case you would be in the clear.



No it's no problem if I get help, sure my lecturers always saying when your stuck ask anyone but if this was an assignment then it would be a different story.
No I didn't really understand what ("(\\w)\\1+", "$1") and ("\\P{L}", "") mean in "String enter3= enter2.replaceAll("(\\w)\\1+", "$1")" and "String enter1 = enter.replaceAll("\\P{L}", "")".




Another issue is that you may be using a feature that you didn't learn.... In this case, using the regular expression engine when the goal of the assignment is to use loops, conditions, arrays, and assignments is not a good idea.

Henry
 
Sara Lyons
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Sara Lyons wrote:

Paul Clapham wrote:Sara, is it possible that you might be asked to explain that solution? Because I have the feeling that you don't completely understand it. If that happened, then you might be in trouble for plagiarism. And it's not a beginners technique that you've been given there, so using it might well cause the examiners to become suspicious.

Unless the rules for your exam specifically allow you to get help from other people, that is. In that case you would be in the clear.



No it's no problem if I get help, sure my lecturers always saying when your stuck ask anyone but if this was an assignment then it would be a different story.
No I didn't really understand what ("(\\w)\\1+", "$1") and ("\\P{L}", "") mean in "String enter3= enter2.replaceAll("(\\w)\\1+", "$1")" and "String enter1 = enter.replaceAll("\\P{L}", "")".




Another issue is that you may be using a feature that you didn't learn.... In this case, using the regular expression engine when the goal of the assignment is to use loops, conditions, arrays, and assignments is not a good idea.

Henry


Ye thats grand just figured out how to do it in a loop and we're already using that feature just hardly attend the lectures to know it
 
fred rosenberger
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sara Lyons wrote:Emm I'd cross them off the paper?? I'm so bad at java epic fail tomorrow .


And how would you know/decide which to cross off? What if you couldn't write on the original piece of paper, but only on a NEW piece of paper?
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sara Lyons wrote:

Henry Wong wrote:
Another issue is that you may be using a feature that you didn't learn.... In this case, using the regular expression engine when the goal of the assignment is to use loops, conditions, arrays, and assignments is not a good idea.

Henry


Ye thats grand just figured out how to do it in a loop and we're already using that feature just hardly attend the lectures to know it



Not sure if I understand what you are trying to say. Are you saying... "you figured it out using loops -- you solved it. And everything is all good"? Or are you saying ... "you just found out that you need to do it using loops -- and you can't use the previously provided solution that you don't understand"?

Henry
 
Sara Lyons
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Sara Lyons wrote:

Henry Wong wrote:
Another issue is that you may be using a feature that you didn't learn.... In this case, using the regular expression engine when the goal of the assignment is to use loops, conditions, arrays, and assignments is not a good idea.

Henry


Ye thats grand just figured out how to do it in a loop and we're already using that feature just hardly attend the lectures to know it



Not sure if I understand what you are trying to say. Are you saying... "you figured it out using loops -- you solved it. And everything is all good"? Or are you saying ... "you just found out that you need to do it using loops -- and you can't use the previously provided solution that you don't understand"?

Henry


No i figured out how to just check for duplicates using a loop. But anyway just had my test and that kind of question never came up
 
reply
    Bookmark Topic Watch Topic
  • New Topic