Another 1 hour learn and write post: Test Driven Design – First shot

I ran over by ten mins, however this is a return to the hour long “how do I do this” and post blogs. I’ve read about TDD but hadn’t used it in the real world. So today’s exercise was attempt to use this practice along with Nunit to begin creating a new program. The program is a very simple Soduku solver that I’m using as a fundamental exercise.

Highly recommended blog post available here: 30 Days of TDD

I haven’t addressed any other issues in this sample outside of eliminating numbers that we can’t use. Simple data structures make the code shorter and a small rules engine simplifies the algorithm..

When first learning to use Nunit, use the Library Package manager to install both Nunit AND the Nunit Adapter into your project, the latter makes the test running simpler when starting out.

My first test experience:

1) The first fault was returning all the values 1 – 9 instead of just {6, 9}. So swapping “rules.all” to “rules.any” fixed that schoolboy error.
2) Then it was returning all the values that should have been eliminated with the matrix. The nest for loops were at fault here, returning false too early.
3) The last fault was the function was left implicit in the return type – something the test didn’t like much. So this was added and the Assert altered to see {9} rather than 9 – they are different types!

A simple, single function with only a handful of lines, presented me with a small number of school errors; the kind that I may have taken a lot longer to pick up further down the line if the subtleties hadn’t been picked up by the unit testing.

Imports NUnit.Framework
Module Module1

Sub Main()
End Sub

Function returnCandidateNumbers(rowNumbersUsed As List(Of Integer),
                                columnNumbersUsed As List(Of Integer),
                                ThreeByThreeMatrix As Integer(,)) As List(Of Integer)

    Dim numbersToCheck As New List(Of Integer) From {1, 2, 3, 4, 5, 6, 7, 8, 9}
    Dim tempList As New List(Of Integer) From {1, 2, 3, 4, 5, 6, 7, 8, 9}

    Dim rules() = {Function(a As Integer) If(rowNumbersUsed.Contains(a), True, False),
                   Function(a As Integer) If(columnNumbersUsed.Contains(a), True, False),
                   Function(a As Integer)
                       For i = 0 To 2
                           For j = 0 To 2
                               If a = ThreeByThreeMatrix(i, j) Then
                                   Return True
                                   Exit For
                               End If
                       Return False
                   End Function}

    numbersToCheck.ForEach(Sub(n) If rules.Any(Function(r) r.Invoke(n)) = True Then tempList.Remove(n))
    Return tempList
End Function

Public Class NumberTest
    <Test()> _
    Public Sub DoesFunctionEliminateNumbersAsAppropriate()
        Dim row As New List(Of Integer) From {1, 4, 5}
        Dim column As New List(Of Integer) From {2, 3}
        Dim matrix = {{2, 5, 0},
                      {3, 7, 1},
                      {8, 6, 0}}
        Assert.AreEqual({9}, returnCandidateNumbers(row, column, matrix))
    End Sub
End Class
End Module

How to write software to help people to learn faster and more effectively?

Fair warning – I had a few beers before I wrote this but it’s been on my mine off and on for 9 months and perhaps needs a LOT more work.

Since I was maybe, I had an obsession with how to learn faster, how to increase so called “IQ” and how to memorize more effectively. I didn’t believe in rote learning as a true way to learn, I wanted the principles with which to generate the rules.

I investigated mind maps, memory strategies, took some false turns down the NLP route and plenty of other things. I didn’t get any perfect answers, though some good ideas on how to study if I needed to cross train.

One thing I learnt early, was simply this: the more you learnt and properly understood, in a wide variety of fields, the easier it is to learn new things. I’ve found this to be true. I don’t remember having a job I was trained or qualified for. I taught myself – isn’t that what one is supposed to do?

I do think people are patterns, what happens in the brain in the micro, actually is reflected – in a fractal nature – in small groups and families, team and societies, towns, cities and nations. It’s a self similar network.

With any pattern, you can start to predict it. It occurred to me that actually you could predict and enhance how fast people can learn specific subjects.

The perfect way to examine such data could be evolved, created, hour by hour, day by day, context by context.

This idea is the ultimate vision of combining neural networks and gene expression programming. All I’ve got to do is learn how to use both.

The bare outline would be that instead of trying to work out the best algorithms to analyse the data as it comes in, you work out how to make a program that LEARNS how to generate the best algorithms.

I don’t know yet if this vision is actually possible, the data realm in question may simply be too complex for this approach in a commercially viable time span.

But if even half of this was possible, it would be good wouldn’t it?

You might have as many “data scientists” as you’ve got CPU’s to run them on.

And of course, there is the real question – interpretation. Correlation does not imply causation and a program probably can’t be built that can do the most useful interpretation work.

But what are we looking for here? Can we make it easier for people to learn complex subjects?

Are the roadblocks to understanding measurable? Can we find the leverage points that make the biggest difference to just how fast someone can learn something?

How we represent and compare information mentally is a massive determiner of how well we truly understand it.

It is possible to mentally hold a perspective of a subject in such a way that it is a struggle for it to ever make sense, like the four blind men describing an elephant. Yet, change the perspective, the comparison, the means of mental representation and it will blaze into comprehension.

Can we perhaps predict from software, just how a person is representing elements of a subject to themselves?

Can we model precisely how the most successful individuals in any given area have represented their understanding?

Can we nudge an individual into deliberately gaining a “meta cognitive” view of their mental strategies for understanding what it is they are studying? Or indeed how they are linking it to prior knowledge.
Can we find out just how they do memorize and learn, according to subject and context, and then enhance this?