hello my name is Nader Atef I’m new to Go programming
https://tour.golang.org/methods/23
this the link of the exercise I tried to solve and also google didn’t help …
I found some solutions but they didn’t work neither on the site or on my pc with the Go runtime environment
can you provide a solution to this problem ?
thats what I have tried (me or the solutions from google)
https://play.golang.org/p/RI1iTwtZN4
thanks in advance
You can make it much more pretty than what you have on the playground…
Also the playground you provided does work very well. It shows the same solution than mine.
But what problems do you have exactly to find your own solution? I think helping to understand your problems, may be better for you than just showing you even more solutions, which you then do not really understand…
Solving the exercise is pretty easy:
- in the method you implement,
Read
from the internalio.Reader
into the provided buffer, assigning ton
anderr
- iterate the buffer, if
p[i]
in range'a'-'m' || 'A'-'M'
, add 13, if in ranges'n'-'z' || 'N'-'Z'
subtract 13. (eg.p[i] += 13
) - return
n, err
This article actually contains a hidden link to a solution on the playground. I will reveal it, after you have shown that you actually try to implement but have serious problems with it and we at least tried to help with the actual problems.
then you mean that the printed “you cracked the code” means that it works???
What else had you expected?
You have the string "Lbh penpxrq gur pbqr!"
as input, which you then ROT13 decode in a reader, which read bytes are copied to stdout. Copying means writing, writing to stdout means writing to the terminal.
And that Lbh penpxrq gur pbqr!
is the ROT13 encoded version of You cracked the code!
can easily verified at rot13.com.
Lol I thought that this was a string error!!!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.