Skip to content

Instantly share code, notes, and snippets.

View kevinjoseph1995's full-sized avatar
🥑

Kevin Joseph kevinjoseph1995

🥑
  • AMD
  • Santa Clara
  • 23:20 (UTC -07:00)
View GitHub Profile
@kevinjoseph1995
kevinjoseph1995 / variable_rle.rs
Last active August 31, 2025 02:22
Variable RLE implementation
// Variable RLE implementation
// Reference: Data Compression (Summer 2023) - Lecture 5 - Basic Techniques | https://youtu.be/TdFWb8mL5Gk?si=ENq0CFiiz-uC7Mib
use anyhow::Result;
use bitvec::prelude::*;
fn min_number_of_bits_required_to_represent(value: usize) -> usize {
if value == 0 {
return 0;
}
// - This is a simple implementation of the LZW compression algorithm
// - The implementation is based on the https://www.youtube.com/watch?v=1cJL9Va80Pk&t=3962s by Bill Bird.
// - https://en.wikipedia.org/wiki/Compress_(software)
use bitvec::prelude::*;
use std::collections::HashMap;
use std::io::Read;
use std::io::Write;