Subscribe to MentalFloss Minutes

## Design: Snake

I saw a couple posts about the Snake game recently, and I realized that I've never actually tried to tackle this game. This post is only about design, so if that idea doesn't interest you, feel free to skip this entry.

Alright, so Snake is played on a grid of W,H where W = some width and H = some height. A snake segment is a 1x1 cell at...

## Deck of Cards

Been seeing a few posts on here about building a deck of cards, so I figured I'd work it out in C++.

`...`

## Programming Construct Idea

So, I was thinking about OOP and inheritance, and I got to thinking about a new construct in OOP where you specify dominant and recessive properties/methods like with real inheritance.

Consider two objects Mother, Father in a fictional language:

`...`

## 600 Reputation

Maybe the reputation points might not mean a lot to most people here, but I don't generally post in areas outside of assisting people with problems, so this means that my points are a fairly good indicator for how many people I've actually helped, and it feels pretty good.

I think back to the first people that I helped with C# problems...

## Parsing : Polynomials

Part 1
Part 2

Recall:

`poly -> term | term + poly | term - polyterm -> coef | coef x | coef x ^ DIGIT DIGIT*coef -> INT | REALINT -> - DIGIT DIGIT* | DIGIT DIGIT*REAL -> - DIGIT DIGIT* . DIGIT DIGIT* | DIGIT DIGIT* . DIGIT DIGIT*DIGIT-> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9`

Here is the bare-bones parser:

`...`

## Tokenizer : Polynomials

Recall last post: [link]

`poly -> term | term + poly | term - polyterm -> coef | coef x | coef x ^ DIGIT DIGIT*coef -> INT | REALINT -> - DIGIT DIGIT* | DIGIT DIGIT*REAL -> - DIGIT DIGIT* . DIGIT DIGIT* | DIGIT DIGIT* . DIGIT DIGIT*DIGIT-> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9`

Let's think about tokens.

`...`

## Context-free Grammar Exploration : Polynomials

I read a pretty cool project idea the other day where you're to read in some polynomial and do operations on it. I figured that this is a pretty nice project to apply my newly acquired knowledge of grammars on. It might be overkill, but it'll be fun none the less.

A polynomial of degree n of one variable is a function of the form: f(x) =...

## Theory of Computation (TOC): Introduction

What you do with this information is up to you. I personally see no use for most of it.

Anyway, I'm working through Introduction to the Theory of Computation (3rd) by Michael Sipser.

Automata and Languages

Context-Free Languages

Church-Turing Thesis

Decidability

Undecidability

Relationships

...

## Two Pronged Design

Sometimes you have a project to complete that has a clear implementation strategy, and requires very little design, but most of the time you have multiple related features of varying difficulty.

In such cases, an approach I've found that works fairly well is to design from both ends at the same time. You pick what you think to be the easiest...

## Blind Trust of Test Cases

There may come a point in your programming adventures where you are forced to write code against a set of tests which cannot be seen by you. This is most likely in an academic setting, since they don't want students coding to tests.

There may also come a point where you are shown to be passing all test cases of some particular tested feature,...

• (2 Pages)
• 1
• 2

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
29 3031