Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(redblacktree). | |
-export([insert/2, empty_node/0,test/0]). | |
-define(BLACK, 'b'). | |
-define(RED, 'r'). | |
-define(BLACK_EMPTY_NODE, {?BLACK, nil, nil, nil}). | |
-define(RED_EMPTY_NODE, {?RED, nil, nil, nil}). | |
% 1 - black | |
% 0 - red |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bubble(l_elems, is_sorted, step): | |
if step is 1 or is_sorted: | |
# base case: l_elems is already sorted or we pass through the list len(l_elems) times | |
return l_elems | |
else: | |
is_swapped = False | |
for i in range(len(l_elems) - 1): | |
# compares each pair of adjacent items and swaps them if they are in the wrong order | |
if l_elems[i] > l_elems[i + 1]: | |
is_swapped = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The program recommends to you a movie list based on the responses about movies ratings. | |
# How it works? It calculates the similarity between your responses and other users in the system, and recommends to you | |
# movies from the user with higher similarity (cosine index similarity: https://en.wikipedia.org/wiki/Cosine_similarity). | |
## How to run it? > Rscript retflix_improvement.R --test | |
getRecommendations <- function () { | |
# returns vector with the responses in order about the movies selected by the ids from indices | |
movieSurvey <- function (indices, movies) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The program recommends to you a movie list based on the responses about movies that you have already seen. | |
# How it works? It calculates the similarity between your responses and other users in the system, and recommends to you | |
# movies from the user with higher similarity (jaccard index similarity: https://en.wikipedia.org/wiki/Jaccard_index). | |
## How to run it? > Rscript retflix.R --test | |
## Use --test command parameter to use for the user data frame a small sample with 8 movies and 3 users. | |
getRecommendations <- function () { | |
# returns vector with the responses in order about the movies selected by the ids from indices |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
John Snow created a map in 1854 about the cholera outbreak in London. | |
Snow plotted cholera cases in the Soho area of London around Broad Street and noticed a cluster around a water pump. | |
This led to improved sanitation facilities and also the discovery that cholera infection was water-borne rather than airborne. | |
This program: | |
* initally have a set of sample points - x,y (representing locations of chollera infection cases) | |
* allow the user to introduce Points of Interest - x,y (representing water pipes, buildings, markets ...) | |
* calculate the final result, representing the Point of Interest closer to all the cholera infection cases. | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
SYMBOLS = ['X', 'O'] | |
def main(argv): | |
game = Game() | |
game.welcome() | |
game.start_game() | |
class Game: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @file Trie class | |
* @author Jose E. Martinez <jootse.84@gmail.com> | |
* @description A class that saves MQTT topics in a trie structure. The trie structure is represented by an Object which keys contains the topics levels. In addition, the topic levels with the key '$' as 'true' are the completed topics. | |
* | |
* @see [Project info]{@link https://jootse84.github.io/notes/create-your-own-MQTT-broker.-part-1} | |
* @see [Trie structure]{@link https://en.wikipedia.org/wiki/Trie} | |
* @see [MQTT topic]{@link http://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices} | |
* | |
* @example |