java_fundamentals icon indicating copy to clipboard operation
java_fundamentals copied to clipboard

We need some examples about Strings and StringBuilder

Open xaca opened this issue 8 years ago • 14 comments

We are looking for String problems to solve in java, easy medium and hard.

xaca avatar Sep 27 '17 22:09 xaca

hi there,

What is it you are after in regards to this? Example programs that do something string related?

eg,

  • count the vowels/upper case chars/whatever
  • Build a string using a string builder (CSVs could be quite a good example for this)
  • String formatting using String.format?

Are you after solutions or problems? What kind of tasks would you consider easy, medium and hard?

webpigeon avatar Sep 27 '17 22:09 webpigeon

@webpigeon I'm a teacher, from a cs1 course, so i'm looking for different problems, more like a challenge for my students. Some are really good programming, but another are starting. So we like to have, easy problems like reverse a string, change vowels to upper case that maybe is easy, compare if to string are palindrome is medium, and a game like hangman could be hard. So you could help with code, or with the problem. Thank you

xaca avatar Sep 28 '17 01:09 xaca

Hey @webpigeon I would be glad to help. Let me know whether you want me to help with the problem statements or the code.

balachandarsv avatar Sep 28 '17 08:09 balachandarsv

@balachandarsv Go ahead, we need different level of dificulty.

xaca avatar Sep 28 '17 12:09 xaca

What do think about an easy problem of string anagram?

claspina avatar Sep 28 '17 18:09 claspina

@balachandarsv can i help too?

matheuscr30 avatar Sep 28 '17 21:09 matheuscr30

@claspina Easy is fine, go ahead please.

xaca avatar Sep 29 '17 00:09 xaca

@balachandarsv Course, we appreciate your help

xaca avatar Sep 29 '17 00:09 xaca

Can I help you?

domitilacrispim avatar Sep 29 '17 01:09 domitilacrispim

One of the best uses of StringBuilder is implementing the .toString() method of abstract data types. Take for example returning the String representation of a Set: "{a,b,c,...}", a vector: "[1,2,3]", or even better a polynomial: "ax^2+bx+c".

jmlon avatar Sep 29 '17 02:09 jmlon

How about this problem: Convert a int/long to its base B representation (e.g. to Hexadecimal) Also interesting from the performance perspective to compare implementations using String concatenation vs using a StringBuilder.

jmlon avatar Sep 29 '17 02:09 jmlon

@domitilacrispim Course, we want each topic goes from easy to hard, because we have students from any levels.

xaca avatar Sep 29 '17 20:09 xaca

I have added some string examples in PR #62

vlasebian avatar Oct 08 '17 20:10 vlasebian

PR #72 contains fixes and a request for feedback on the "pokemon" example

webpigeon avatar Oct 11 '17 09:10 webpigeon