Skip to content

Instantly share code, notes, and snippets.

View btawney's full-sized avatar

Brian Tawney btawney

View GitHub Profile
@btawney
btawney / FunctionalTypes.cs
Last active December 20, 2015 20:19
Functional lists and some higher order functions in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FunctionalTypes
{
public static class FunctionalList
{
public static FunctionalList<char> FromString(string s)
@btawney
btawney / ToylModel20130322.cs
Last active December 15, 2015 07:39
C# expression of model Toyl program ToylModel20130322
using System;
namespace ToylModel20130322
{
public delegate TReturn ToylFunc<TReturn>();
public delegate TReturn ToylFunc<T1, TReturn>(ISignature<T1> p1);
public delegate TReturn ToylFunc<T1, T2, TReturn>(ISignature<T1> p1, ISignature<T2> p2);
public interface ISignature<T> {
T Value();
@btawney
btawney / ShortCipherSolver.cpp
Last active December 15, 2015 06:28
Short ciphers are relatively immune to a frequency analysis attack, but if they are long enough they can be solved with this approach, which checks all possible solutions given a lexicon of possible words and the pattern of repeated characters in the cipher. This approach would be vastly improved by adding some likelihood checks that would cause…
// ShortCipherSolver.cpp
#include <stdio.h>
#include <string.h>
void SolutionFound(char *solution, char *cipher);
void TrimBuffer(char *buffer);
void Solve(char *cipher);
// Solve ciphers provided as arguments to the command