Coder Social home page Coder Social logo

exercise-compression-algorithm-python's Introduction

Compression Algorithm

Lets create a compression algorithm ๐Ÿคฏ It sounds hard but it's something achievable for almost anyone.

๐Ÿ“ Instructions

Create an algorithm that given a string, replaces its words matching the symbols dictionary keys and replaces them with their respective values on the same dictionary.

symbols = {
    "implementation": "๐Ÿคฏ",
    "practicality": '๐Ÿคฉ',
    "better": '๐Ÿ˜…',
    "Although": "๐Ÿฅบ"
}

For example:

Although, this is a great implementation of time โ†’ should become โ†’ ๐Ÿฅบ, this is a great ๐Ÿคฏ of time

The current project has 3 main files:

Name Description
compress.py Contains the algorithm to compress the content, it has a function "compress" that receives the raw text and returns the compressed version of it
decompress.py It's very similar to compress.py but it contains the algorithm to convert back the content from its compressed version to the original content
app.py This is entry file, and there is no need to update it, it imports and uses the other two files

๐Ÿ”ข Steps

  1. Take time to understand the code, start by opening and reading the app.py and follow the algorithm with your brain, review the compress.py and decompress.py files to understand where your solution must be implemented.
  2. Run the app.py by typing python3 app.py and undestand what is the output and why.
  3. Edit the compress.py to create the compression algorithm.
  4. Test your compression algorithm by running the app.py again.
  5. Edit the decompress.py to create the decompression algorithm.
  6. Test your decompression algorithm by running the app.py again.

๐ŸŒฑ How to start this project

This project comes with the necessary files to start working, but you have two options to start:

a) Open this link in your browser with gitpod: https://gitpod.io#https://github.com/breatheco-de/exercise-compression-algorithm-python.git

b) You can clone this repository on your local computer:

$ git clone https://github.com/breatheco-de/exercise-compression-algorithm-python.git

Type the following in the command line:

python3 app.py

You should get a response similar to this:

โœ…No data lost.
document.txt has 824 size, compressed.txt has 768 size, compression of 7% in 0.0003972053527832031 seconds 

๐Ÿ’ก Important: Remember to create a new repository, update the remote (git remote set-url origin <your new url>), and upload the code to your new repository using add, commit and push.

๐ŸŽฏ Metrics

  1. Compression power: Ratio is defined as the ratio between the uncompressed size and compressed size.
  2. No Data lost: If we compress and decompress document.txt the result should be the original string of content.

๐Ÿฉ๐Ÿฌ๐Ÿญ Feeling confident?

By adding more words to the symbols dict you can achieve more compression power.

Try to re-do the algorithm to achieve a compression power above 15% with no data lost without just adding more words.

exercise-compression-algorithm-python's People

Contributors

alesanchezr avatar elviraqdp avatar tommygonzaleza avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.