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
# FUNCTION TO CHECK WHETHER TWO WORDS ARE ANAGRAMS | |
# Based on the following logic by @fermatslibrary: | |
# 1. Map each of the 26 English characters to a prime number | |
# 2. Multiply the characters of each word | |
# 3. Two words are anagrams if their products are the same | |
# This works because every integer is a prime or a unique product of primes | |
library(magrittr) |
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
############################## | |
# 1. SETUP # | |
############################## | |
library(tidyverse) | |
library(sparklyr) | |
library(formattable) | |
set.seed(1234) |
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
# Load the relevant packages | |
library(NCmisc) | |
library(stringr) | |
# Load the script and parse lines | |
file_name <- "example_script.R" | |
file_lines <- readLines(file_name) | |
# Save the function and package names | |
functions_list <- list.functions.in.file(file_name) |