Skip to content

Instantly share code, notes, and snippets.

View Marrockx's full-sized avatar
:octocat:

Marrockx

:octocat:
  • Obafemi Awolowo University, Ile-Ife
  • X @Marrockx
View GitHub Profile
@samuelfvlcastro
samuelfvlcastro / RLE.js
Created October 4, 2016 18:42
Example of Run-length encoding (RLE) compression in javascript
var blocks = ["A","A","A","A","A","A","A","A","A","A","A","A","B","B","A","C","C","C","C","D","D","D","D","A","A","E","E","E","A"];
function Encode(input){
var segmentLength = blocks.length;
var run = 0, current = '', last = '', encoded = '';
current = last = blocks[0];
for(var i = 1; i <= segmentLength; i++){
if(current !== last){
def delete_first(self):
deleted = self.head
if self.head:
self.head = self.head.next
deleted.next = None
return deleted
// Using the JavaScript language, have the function LetterCount(str) take the str parameter being passed and return the first word with the greatest number of repeated letters. For example: "Today, is the greatest day ever!" should return greatest because it has 2 e's (and 2 t's) and it comes before ever which also has 2 e's. If there are no words with repeating letters return -1. Words will be separated by spaces.
// Input = "Hello apple pie" Output = Hello
// Input = "No words" Output = -1
function LetterCount( str ) {
var words = str.split( ' ' );
var longest = 0;
var longest_word;
for ( var i = 0; i < words.length; i++ ) {