I have written a LZW decoder algorithm in Go for a programming task required as part of a job application. A LZW code is a sequence of integers which can be decoded as a string. I have basically written a function that looks like this:
func LZWdecoder(code []int) String {
// * perform decoding *
return decodedString
}
They have provided me with a .z
file which is encoded using LZW encoding so I can test my algorithm on it (it decodes to human readable text).
However, I don't know how to "load" that file into an integer slice that I can run through my function. Any help would be greatly appreciated.
CodePudding user response:
I think you need to convert the slice of byte from os.ReadFile to a slice of int. that's explained here : Convert byte slice to int slice