frankcollins3 / fcc-mcsft-cSharp

FreeCodeCamp & Microsoft C# course:
1 stars 0 forks source link

Reverse String. No bulls-eye! [9:14pm] #26

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

attempting to do: reverse each word in a string algorithm Screen Shot 2023-09-09 at 9 12 45 PM

error: Screen Shot 2023-09-09 at 9 12 51 PM

proposed approach: 👍 saw this below tip after getting this code to display as pictured above in the terminal. follow it; keep headbumping wall Important

This is a particularly difficult challenge. You will need to combine many of the concepts you learned in this exercise, including the use of the Split(), ToCharArray(), Array.Reverse(), and String.Join(). You'll also need to create multiple arrays, and at least one iteration statement.

possible improvements: once the iteration over split words became the go-to... a callback function that reversed words made this easier. also: realizing each word has to be it's own array even after looping. this is a nested loop but cb made it make more sense [updated improvement @ 9:40pm]

all the way below is microsoft's example. their example highlights that I didn't "make multiple arrays" to solve this, though that expectation is pictured right below this text within the "important" tip message. my provided example leverages every method they mentioned, though. Screen Shot 2023-09-09 at 9 49 32 PM [9:50pm]

frankcollins3 commented 1 year ago

the real problem is that I've reversed the whole array. this (algo?) expression calls for reversing each word. here's the code that's causing the not-precise-enough reversing of characters Screen Shot 2023-09-09 at 9 16 10 PM

[9:15pm]

frankcollins3 commented 1 year ago

code: Screen Shot 2023-09-09 at 9 21 12 PM

output: Screen Shot 2023-09-09 at 9 20 56 PM [9:21pm]

frankcollins3 commented 1 year ago

looping over split array and creating callback to reverse each word: Screen Shot 2023-09-09 at 9 36 51 PM

Screen Shot 2023-09-09 at 9 37 15 PM

[9:37pm]

frankcollins3 commented 1 year ago

👍 GOTTIT!

code: Screen Shot 2023-09-09 at 9 45 24 PM

Screen Shot 2023-09-09 at 9 39 40 PM

agreed. Screen Shot 2023-09-09 at 9 39 44 PM

[9:40pm]

frankcollins3 commented 1 year ago

microsoft's example: Screen Shot 2023-09-09 at 9 47 31 PM [9:47pm]