Giter VIP home page Giter VIP logo

morse_code's Introduction

morse_code

Morse Code Encoder and Decoder Using Binary Tree

The morse code binary tree in the program is explicitly build inside the morse module.

To make use of the available functions, morse module has to be import into the main environment.

import morse

the morse tree nodes can be called using the following method.

morse.tree

It points to the morse binary tree

Instantiate

This program provides three functions:

Encoder

  • The encoder function which encode the given string to morse code.

For example

import morse

encoded_text = morse.encode('usd')
print("Morse Code: " + encoded_text)

The Output of the code is

Morse Code: ..- ... -..

Example 2 Encoding of extra symbols

import morse

new_text = morse.encode('(?extra:)')
print(new_text)

The Output is

-.--. ..--. . -..- - .-. .- ---..- -.---.

Decoder

  • The decoder function which decodes the given morse code to equivalent string.

For example

import morse

decoded_text = morse.decode("..- ... -.. -")
print("String: " + decoded_text)

The Output of the code is

String: usdt

Example 2 Decoding of extra symbols

import morse

new_text = morse.decode("-.--. ..--. . -..- - .-. .- ---..- -.---.")
print(new_text)

The Output is

(?extra:)

Print Morse Binary Tree Stack

call the function after importing

morse.printTree()

It would print the stack directly

or to print a stack with any node

call the function and give the node to print the tree

import morse

node = morse.Node(1)
node = morse.insert_node(node, 2);
node = morse.insert_node(node, 3);

morse.getTree(node)

The following output would be

r - 1
   l - 2
   r - 3

morse_code's People

Contributors

7j4n1 avatar

Watchers

 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.