Skip to content

Instantly share code, notes, and snippets.

View JeremyLWright's full-sized avatar
😎

Jeremy Wright JeremyLWright

😎
View GitHub Profile
@JeremyLWright
JeremyLWright / bubble_sort.tla
Created February 19, 2022 20:44
Part of the 4-part video series on Refinement & Abstraction in TLA+
---------------------------- MODULE bubble_sort ----------------------------
EXTENDS SequencesExt, Sequences, Integers, TLC, Naturals
CONSTANTS N
ASSUME NonEmptyArray == N \in Nat /\ N > 1
(*--fair algorithm BubbleSort {
@JeremyLWright
JeremyLWright / ABrilliantYoungMind.tla
Created January 12, 2022 18:00
TLA+ Specification of the a scene in the movie "A Brilliant Young Mind"
------------------------ MODULE ABrilliantYoungMind ------------------------
EXTENDS TLC, Sequences, Naturals
CONSTANTS NumCards
ASSUME NumCards > 1
VARIABLES Game

Jon is visiting New York City for the first time. He would like to make use of his stay by touring various places around the city. He wonders if there could be any system which helps him to find a most optimal route which covers as many tourist places as possible from his source to his desired destination point.

Luckily, we have Open Street Maps which contains "tags" on each road describing it. More information about it can be found here, http://wiki.openstreetmap.org/wiki/Elements#Tag.

Now, you as a Software Developer, need to develop a system to solve his problem. Here are the things that will help you,

Using these, when a source and destination points are given, you need to find a route which has a maximum number of tourist places in it.

@JeremyLWright
JeremyLWright / Rotor.scala
Created March 27, 2016 23:38
Problem compiling 2.9.1 scala program
/**
* Created by Jeremy on 3/27/2016.
*/
import collection.mutable.ListBuffer
class Rotor(var rotorMap: List[(Char, Char)], val notch: Char){
def this(alphabet: String, beginPos: Int, notch: Char) = this(
Rotor.rotate((Alphabets.realAlphabet zip alphabet).toList, beginPos), notch)
def this(alphabet: String, beginPos: Int) = this(alphabet, beginPos, 'Z')
@JeremyLWright
JeremyLWright / Enigma.scala
Created March 27, 2016 23:37
Cannot compile old 2.9.1 scala program
/**
* Created by Jeremy on 3/27/2016.
*/
class Enigma(val reflector: Reflector, val rotors: List[Rotor]) {
def window : String = rotors.map(_.showing).mkString
def findPositionOfChar(c:Char): Int = Alphabets.realAlphabet.indexOf(c)
def rotate(rotors: List[Rotor]): Unit = {
rotors.foldLeft(true)((b, r) => {val n = r.isAtNotch; if (b || n) r.rotate; n})
#-*- coding: utf-8 -*-
import re
import nltk
from nltk.tokenize import RegexpTokenizer
from nltk import bigrams, trigrams
import math
stopwords = nltk.corpus.stopwords.words('portuguese')