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
using System.Text; | |
public class BinaryCode | |
{ | |
public string[] decode(string message) | |
{ | |
int[] messageInts = new int[message.Length]; | |
{ | |
for (int i = 0; i < message.Length; i += 1) | |
messageInts[i] = message[i] - '0'; |
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
// Example: distinguishing between vowels and consonants | |
val corpus = | |
Seq( // I swear these are all English words | |
"antidisestablishmentarian", "ablutophobia", "automatonophobia", "autotonsorialist", | |
"arachibutyrophobia", "automysophobia", "batrachophagous", "ballistocardiograph", | |
"blandiloquence", "brachydactylous", "bathythermograph", "cacodemomania", | |
"caesaropapism", "catapedamania", "cheiloproclitic", "chronosynchronicity", | |
"dendrochronology", "deorsumversion", "dermatoglyphics", "dolichocephalic", | |
"dysmorphophobia", "eellogofusciouhipoppokunurious", "electroencephalograph", "epiphenomenalism", |
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
;; http://www.cs.brown.edu/courses/csci1730/2012/Assignments/Interpreter/ | |
#lang plai | |
(define-type Binding | |
[binding (name symbol?) (named-expr CFWAE?)]) | |
(define-type CFWAE | |
[num (n number?)] | |
[binop (op procedure?) (lhs CFWAE?) (rhs CFWAE?)] |
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/ruby | |
############# Day 1 ############# | |
# Print the string “Hello, world.” | |
puts 'Hello, world' | |
# For the string “Hello, Ruby”, find the index of the word“Ruby”. | |
puts 'Hello, Ruby'.index('Ruby') |
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
//* ------------------------------------------------------------------------ | |
//* Rfc822DateTimeParser - Parse Date-Time In RFC-822 Format | |
//* Copyright (C) 2009 Tom Dong | |
//* | |
//* This library is free software; you can redistribute it and/or | |
//* modify it under the terms of the GNU Lesser General Public | |
//* License as published by the Free Software Foundation; either | |
//* version 2.1 of the License, or (at your option) any later version. | |
//* ------------------------------------------------------------------------ |
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
# Homework 1 - Part 1 | |
def palindrome?(string) | |
string = string.downcase.gsub(/\W/, '') | |
string == string.reverse | |
end | |
def count_words(string) | |
Hash[ | |
string.downcase.scan(/\w+/). | |
group_by{|s| s}. |
NewerOlder