Skip to content

Instantly share code, notes, and snippets.

View thunklife's full-sized avatar

Jesse Williamson thunklife

View GitHub Profile
@thunklife
thunklife / FebruaryKatas.md
Last active February 18, 2020 20:59
February Katas

Hangman

Taken from Haskell Programming From First Principles (aka The Haskell Book) Chapter 13

Description

In case anyone is not familiar with the game, Hangman is a game with 2 (in this case) player. The first player picks a word at random and the second has to guess that word letter-by-letter. Typically game also involves drawing an empty gallows pole and each incorrect guess adds a body part to the gallows starting at the head, then body, one arm, then the other and so on until there is second player has guessed the word (win) or all the body parts have been drawn (lose). The second player can make as many correct guesses as is needed to fully 'expose' the word; each correct guess exposes a part of the target word.

Example

Start

Guessing Game

Taken from The Rust Programming Language (chapter 2) https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html

Description / Challenge

[T]he program will generate a random integer between 1 and 100. It will then prompt the player to enter a guess. After a guess is entered, the program will indicate whether the guess is too low or too high. If the guess is correct, the game > will print a congratulatory message and exit.

@thunklife
thunklife / OctoberKatas.md
Last active October 18, 2019 17:11
October Katas

October 2019

Hutton's Razor

Hutton's Razor is a minimal interpreted language the consists of two things: literal integers and the ability to add the them together.

Problem

  1. Find a way to express the basic Abstract Syntax Tree of Hutton's Razor. For example, in Haskell we can use a recursive sum type:
data Razor

Mastermind

Description

Mastermind is a boardgame with 2 players, the code maker and the code breaker you are the code breaker. The code maker creates a code using 4 colored pegs in any order they wish. The code breaker attempts to guess the code in 12 turns. With each turn, the code breaker is given two pieces of information: 1) The number of exact matches 2) The number of color matches.

A Few Details

  • Colors can be repeated, a code does not have to contain all colors.
  • Valid Colors: Red, Green, Blue, Yellow

Conway's Game Of Life

From Wikipedia

The universe of the Game of Life is an infinite, two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead, (or populated and unpopulated, respectively). Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

  • Any live cell with fewer than two live neighbours dies, as if by underpopulation.
@thunklife
thunklife / AprilKatas.md
Last active April 18, 2019 21:54
April Katas

Bowling

Description

http://codingdojo.org/kata/Bowling/

Create a program, which, given a valid sequence of rolls for one line of American Ten-Pin Bowling, produces the total score for the game. Here are some things that the program will not do:

Optional

Check for valid rolls. Check for correct number of rolls and frames.

@thunklife
thunklife / FebruaryKatas.md
Last active February 23, 2019 18:42
February Katas

February Katas

The application is a simulation of a toy robot moving on a square tabletop, of dimensions 5 units x 5 units.

There are no other obstructions on the table surface.

The robot is free to roam around the surface of the table, but must be prevented from falling to destruction. Any movement that would result in the robot falling from the table must be prevented, however further valid movement commands must still be allowed.

November Katas

Algorithms

Binary Search

Given an ordered list of elements, and an element you are searching for, provide the position of the element if it is in the list. A binary search follows these steps:

  1. Check if the middle element is the item you are looking for
  • If so, return the position of the element
@thunklife
thunklife / AugustKatas.md
Last active August 23, 2018 23:07
August Katas

August Katas

Recursive Functions

Write a function that recursively sums all numbers from 1 to n, n being the argument. So that if n was 5, you’d add 1+2+3+4+5 to get 15.

Write a recusive version of map and filter. Try, if your language of choice has a way, to make it as polymorphic as possible. Ideally, the functions so know as little as possible about their arguments.

The definitions of map and filter should reveal a pattern. Define a function based on that pattern, and see if you can redefine map and filter in terms of it, again trying to be as polymorphic as possible. Bonus points if you can redefine the adding function above.

Write a recursive binary search function that takes a sorted list/array of integers, and an integer to attempt to lookup. If the integer is found, return its index. If the integer is not found, return -1, false, anything really as long as it denotes that the integer was not found.

@thunklife
thunklife / cfp.md
Last active September 2, 2017 17:17

Title:

Types For Frontend Developers

Description:

It's hard to bring up static types in JavaScript without starting a debate. The benefits of using static types are real, and so are the tradeoffs. As with so many things in software, the key to figuring out if the benefits outweigh the costs for you and your team. At Reflexion Health, we recently looked at introducing static types; I'd like to share some of the lessons we learned, and shed some light on how static types can help your team.

Topics:

Frontend Tools (maybe Future JS?)

Subtopics: