I came down at 14:20 from the library, and we worked on one problem. One single problem, for 40 minutes. I think this was the longest and most draining problem I have encountered in CodingBat. Mr. Daly and I tried every single possible Java method and different ways to try and solve the problem - still unsolvable.
After enduring 40 minutes of mental torture on a Friday afternoon, we finally managed (I don't know how) to solve the problem.
Here it is :
----------------------------------------------------------------------------------------------------------------------------------
Given a string and a non-empty word string, return a string made of each char just before and just after every appearance of the word in the string. Ignore cases where there is no char before or after the word, and a char may be included twice if it is between two words. wordEnds("abcXY123XYijk", "XY") → "c13i" wordEnds("XY123XY", "XY") → "13" wordEnds("XY1XY", "XY") → "11" |
I think it was also the longest piece of code I have written all year. It was long, but worth it in the end when we finally had the joy of seeing the "All Correct".
I only have 5 problems left in String 2. Let's do it ! Until next class.
No comments:
Post a Comment