GithubHelp home page GithubHelp logo

ruby-morse-code-challenge's Introduction

General Assembly Logo

Morse Code Challenge

Convert Morse Code messages into text.

Adapted from these CodeWars exercises, created by user jolaf:

Prerequisites

  • None

Instructions

  1. Fork and clone this repository.
  2. Change into the new directory.
  3. Install dependencies.
  4. Create and checkout a new branch to work on.
  5. Fulfill the listed requirements.

Starter code is available in lib/challenge.rb. A pull request is not required, but it is necessary if you want a code review.

You may wish to refer to FAQs related to forking, cloning.

Requirements

Create a method, decode_morse, which takes a string of dots/dits ('.') and dashes/dahs ('-') and converts it into a readable message. A Morse Code dictionary, MORSE_CODE, has been provided for you. If an invalid letter code is passed in, decode_morse should replace that invalid letter with an asterisk ('*'). Letters are separated by space, while words are separated by a group of three spaces. Remove any leading or trailing whitespace.

You should be running rubocop before diagnosing any bugs, since it finds some of the most common sources of errors. After rubocop passes your code (ignore any warnings about spec_helper), you should run rspec to run the included tests, which will tell you whether or not you've met requirements.

Bonus : parse_bits

Let's imagine that a signal is being sent along a wire; at the receiving end, it is being sampled and converted into a set of 1s and 0s. i.e. '1010100010001000' => "see"

The Morse Code specification dictates that:

  • A 'dot' ('.') is one time unit long
  • A 'dash' ('-') is three time units long
  • The pause between each dot and dash in a letter is one time unit long.
  • The pause between letters in a word is three time units long.
  • The pause between words is 7 time units long

However, we don't necessarily know how fast the person on the other end is at sending their signals - the precise length of a 'time unit' is unknown. If they're a slow telegraphist, their dots and dashes might be stretched out, e.g.'111000111000111000000000111000000000111000000000' => "see"

The parse_bits method should take a string of 1s and 0s and convert it into the dots and dashes that were being sent. Be sure to disregard any stretches of silence (i.e. 0s) before or after the message.

Source code distributed under the MIT license. Text and other assets copyright General Assembly, Inc., all rights reserved.

ruby-morse-code-challenge's People

Contributors

ga-meb avatar

Watchers

James Cloos avatar Misha Herscu 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.