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
from functools import cache | |
import itertools | |
import random | |
def unique_letters(word): | |
return sorted(list(set([letter for letter in word]))) | |
def fitness(word_list): | |
return len(set([c for c in "".join(word_list)])) |
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
cigar | |
rebut | |
sissy | |
humph | |
awake | |
blush | |
focal | |
evade | |
naval | |
serve |
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
words = File.read("NWL2020.txt").lines.map { |line| line.split(" ").first } | |
bigrams = words.map { |word| word.split("").each_cons(2).to_a.map(&:join) }.flatten.tally | |
letters = ("a".."z").to_a | |
all_bigrams = letters.repeated_combination(2).map(&:join).map(&:upcase!).to_a | |
unaccounted_bigrams = all_bigrams.select { |b| not bigrams.has_key?(b) } | |
puts unaccounted_bigrams.join(" ") |
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 'dart:io'; | |
import 'dart:async'; | |
void main() { | |
String f = new File('/home/hayden/journal.txt').readAsStringSync(); | |
RegExp wordSplit = new RegExp(r"(\w+)"); | |
Iterable<Match> words = wordSplit.allMatches(f); | |
words.forEach((e) { | |
String m = e.group(0); | |
print(m); |
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
require 'prime' | |
PRIMES = (1..Float::INFINITY).lazy.select(&:prime?) | |
#while primes.length > 0 do puts primes.pop; sleep 1 end | |
def make_prime_sayer(starting_time) | |
dt = starting_time | |
c = 0 | |
return lambda do || | |
begin | |
c += 1 if (Time.new.to_i - dt) >= 5 |
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
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
# current status: not broken | |
# this is a class documentation comment to shut rubocop up | |
class Minikov | |
WORD_SPLIT = /[\w'.,!?]+/ | |
attr_accessor :words |