FLL Homework

October 3, 2017

FIRST Lego League update after Tuesday’s mtg (3rd October 2017)

Previously, we’d discussed the following approach for our “project”: one of the ‘problems’ with how we transport and dispose of water, specifically, is the issue of polluted run-off from roads, etc. thru drains to our lakes and rivers.  {This is a bit of a biased story-line, based on my interpretation only.}  A way to alleviate this would be to replace at least part of parking lots with gardens; schools could do this, and we could start small — just schools in Bloomington, then Minnesota… eventually, the world!

But today, the team wasn’t putting it all together, and also some discussion went off on tangents, etc.  Therefore the coaches tried to let the kids sort out for themselves what direction to go — we both were a little frustrated with the lack of focus [again, editorial by the author].

So, the eight of them moved in this direction (after some stern warning):

FF68F83A-9125-4E43-8E4C-6DE1811E7B45916496AA-2125-4D0B-8516-80413E32D694
D5E4EFEA-7E9C-448D-97B1-AEDF43155C6F

8B16E34A-E09E-44E4-A5F1-12C2A8328326

yes, there is the grammatical (affect/effect) error; it’s not a big deal.

HOMEWORK: Come up with [two] solutions to our problem (which is: yard waste going down drains, getting into [lakes and rivers, etc.])

 

Advertisements

First Lego League

October 1, 2017
For those who find this from my FB feed, or Twitter -- probably not what you're 
expecting from me; if you're coming here because I e-mailed you, read on.
(Anyone can read this, but most probably don't know: I'm one of the coaches
for the FIRST Lego League team, which my son is member of...)

WARNING

Let me preface this blog post by saying: this is in no way intended to be a full and complete report of what the first Seven Hills FIRST Lego League team has done or is doing — my main point, in fact, is only to share the links at the end; but I thought, as long as I’m here, I’ll write a bit about what we’ve done so far…

Second, note that this blog contains other, very unrelated, posts – comp. sci. and op. eds of mine; these should probably be ignored, for the most part!

Finally, note that in addition to being incomplete (to put it mildly), the information here is somewhat scattered — much like the absent-minded person I am.

 

IDEAS

Last Tuesday (9/19), last Saturday (9/23) we discussed ideas for the challenge project.

Some of the many ways we find, transport, use or dispose of water: [we] use water in card, [transport] water through pumps underground, [use] water for cooking; find –> rain, in houses, for washing dishes/cleaning/shower & bath, to wash clothes, hands and dishes, glasses of water, dispose –> flush toilet; find –> groundwater; firetruck, [by] sweat[ing] –> “make” water; use water in aquariums, to water plants, for swimming; we use water in trains, planes, for brushing teeth; we dispose of [a lot] of water in car washes.

Problems that we have with the human water cycle include not enough water (due to) poor sanitation; flush toilets [result in] dirty water not handled properly; car washes use lot of unnecessary water — and soap pollutes water, which we can’t use again.  Rain can cause destructive floods.  (Note: many of the ideas we thru out during brain-storming were never fully flushed out after that)

Well, if I continue to write all of even my abbreviated notes, I won’t get to the main point:

 

LINKS

Field Setup Guide video and an image of the full field, and instructions.

The FIRSTChallenge, Updates & Resorces” page has those links and more, including the Mission Model Building Instructions.   (This is already done, but for reference…)

But the “most important” link for this post is: downloading the EV3 software.
(Note: I tried several times to download the “English (U.S.)” version for Windows 7, 8.1, 10; every time it seemed to work, but when I tried to run the install, I got a dialog box saying the file was corrupt.  Eventually, I downloaded the U.K. English version — it works the same, and I haven’t noticed a problem.  If it works for you, please let me know!)

 

Elements

September 8, 2017

I like the way the Wikipedia entry puts it: “The history of the periodic table is also a history of the discovery of the chemical elements.”

Before Chemistry

Alchemy began in Egypt in the 4th century BC and migrated to Spain by the 8th centry CE.  Separately, the timeline for its development in China is much less clear, though it is sometimes dated anywhere from the 5th centry BC (though there is no word for gold in Chinese at tat time, and thus not the focus on changing lead to gold) to definite discussions during the 1st centry BC.

(See Lloyd Library entry on the history of alchemy and Wiki entry on Chinese alchemy.)

Although it was more than that, alchemy is remembered as the pursuit of a mystical way to convert lead to gold.  Say what you will, as it became more “disciplined,” it became the fore-runner of modern chemistry.

 

Rebooting…

September 5, 2017

Four years later

I haven’t posted in a long, long time.  That doesn’t mean I’ve been doing nothing; on the contrary.

First, I’ve become a father of a ten year old (when did he get so old?).  I’ve heard it said that one of the surest signs we were meant for eternity/immortality is when we see someone we haven’t for a long time and are shocked by the changes brought by time.

I’ve become a real estate agent in the state of Minnesota.

I just re-read my history post, and I find some changes — esp. regarding our cat status: those that owned my wife and me then have all passed on; we are now owned by two new cats.

My job as a computer programmer has also changed – I’ve gone thru a stint as an IBM consultant, and now working at a diff. healthcare company (though I’m still not responsible for any of their policy decisions).

Though I find both of the quotes still apply.

Things I still want to say

I am going to write more here, including some things for my “little boy” (who’s now in 5th grade!) to read.

I may write some short stories here — or, at least, ideas

And I’ve got to save some notes of things I meant to keep track of, that I keep losing.

 

Book Review – Empyrean Key

October 22, 2014

I just finished reading the first book in the Ardentia Series.  And I can’t wait for the second installment “due out early 2015” according to the end of the book.

cover photo

I enjoyed the book. While not what I’d call “excellent,” it was very good, definitely readable — one that I’d recommend to my friends who love the fantasy genre. (Full disclosure: the author is related to a friend of my wife.)  Though SparrowHawk gives it high marks.

There are a couple things to highlight in the positive category, and minor criticism.

This story builds a believable world and likeable characters — in fact, characters, like Jahna, who I want to see succeed.

Creating a world is, in my opinion — not to take anything away from Tomlinson — easy; introducing it to the reader is trickier.  A writer who creates their own world always has a choice, and a fine line to walk.  On the one hand, he or she can chose to not “explain” anything, instead telling the story wholly within the setting, and leave it to the reader to figure out the workings of the world as they go.  The other path is to write the story as one telling someone who is not at all familiar with the setting, taking time (and precious pages) to elaborate on the differences between their world and ours.

Of course it’s not a black and white, either/or decision.  In this case, I think, Tomlinson could’ve provided a more gentle introduction to the unfamiliar places, and meaning of some of the geography.  It’s not horrible, just be ready to keep track of Aedentia, and the gods and heroes, the Pithart, the place of worship, and the backwater town of Groden Cove.  None of this is hard, and perhaps I’m being overly picky.

I’m a little more critical of the introduction of the characters:

I feel now that my third point (below) is closely related to the character intros in this sense: the book, in retrospect, feels too short; and the introduction of the primary characters seemed either a little forced, or missing in depth.  What I mean is, after the fact, i read the description on Amazon.

As a not-so-perceptive telepath and amateur scam-runner, Jahna Mornglow has filled the void left by an absent father, with the friendships of a bloodthirsty bar-maid and a bullied book-worm. Her mother, scarred by the racial prejudices of her past, refuses to nurture Jahna’s Narcean abilities of prophecy and telepathy, warning her of the hate beyond the safety of Groden Cove – a beachside safe haven for misfits and those who wish to be left alone.

I wouldn’t describe Lilac as a “blooodthirsty bar-maid” — not exactly.  And Jahna’s mother’s story seems far too short to fill out that line (maybe, but I failed to get all that from just the few pages she gets).  I guess Lilac maybe is, but I don’t know if I actually think I know her, because we haven’t spent enough time together.  I don’t know if that’s just “first impression” (which, it actually isn’t), or if that’s really who she is.    Moreso with the “bookworm,” he’s acted in ways that are surprising, like I would never have expected that of him.  Again, because I haven’t spent enough time “observing” him to know what he’d do in an unfamiliar situation.

And, yet, I think that if I had another fifty pages, maybe I’d have a better sense of any of them, Lilac included.

All in all, though, I have to say, I do want to continue reading, and my last point is really just this: I just think the cliff-hanger at the end came too soon.  I want to read more, and I find that there isn’t any more, yet.

All that being said, the book did draw me in, as a story should, and I found myself experiencing the characters, and not just “reading” a book.

I did find the author’s blog.  And I eagerly look forward to reading more.

C++ Exception Problem

October 4, 2014

This is going to be a very technical post.

Gory details forthcoming, you’ve been warned.

I think I have a problem with some C++ code, and I’ve narrowed it down as much as I can.  I am using the standard exception, std::overflow_error (though that probably doesn’t matter).  I’m compiling with GCC 4.9.1 (this, I think, does matter).

So here’s the summary, with a fairly complete set of exception-handling clauses, when I throw the overflow_error exception from an activity by itself, it works; but if I have even a fairly simple string declaration and assignment, then all the exception handling gets skipped.

Details, Details

Let’s start with a “working” example; here’s the main body:


#define CHAR char
#define ATOL atol
#define MAIN main

Never mind what I was doing here


int MAIN(int argc, CHAR* argv[])
{
  SixFactor t(26757, -1);
  cout << "t = " << static_cast<std::string>(t) << endl;
  try {
    SixFactor e(0,0);
    e = t*t;
    cout << "got here - no exception" << endl;
  } catch (overflow_error &oe) {
    cout << "caught overflow exception: " << oe.what() << endl;
  } catch (...) {
    cout << "caught an unknown exception" << endl;
  }
  return 0;
}

Strange class name?  It’s pulled from the context of the program where I noticed this.

So what’s in the constructor(s), and the operator* overload function?


class SixFactor
{
  public:
    SixFactor(const ulong m, const int o): _mult(m), _offs(o) {};

and later

SixFactor operator*(const SixFactor &othr) throw(overflow_error) {
  // std::string err_msg = "SixFactor mult. overflow of (";
  // err_msg += static_cast(*this) + ") * (" +
  // static_cast(othr) + ")";
  /// cerr << "throwing an exception: " << err_msg << endl;
  // throw std::overflow_error(err_msg.c_str());
  ////////////////////////////////////////
  // If I uncomment even one of the preceding lines (the string decl. line)
  // then the exception below is *not* caught, but the program terminates
  // abnormally. As it stands w/ the exception only, it "works"

  throw overflow_error("this works");
}

Note that right now, the only un-commented code in this function is the throw statement.

What happens:

Compiling

g++  -g -std=c++11 -Wall -Wextra -v -Weffc++ -Wold-style-cast  -c
      -o test_exception2.o test_exception2.cpp

Running

./test_exception2

Output:

t = 6*26757 - 1
caught overflow exception: this works

When it breaks

Let’s change the code

SixFactor operator*(const SixFactor &othr) throw(overflow_error) {
  std::string err_msg = "SixFactor mult. overflow of (";
  // err_msg += static_cast(*this) + ") * (" +
  // static_cast(othr) + ")";
  /// cerr << "throwing an exception: " << err_msg << endl;
  // throw std::overflow_error(err_msg.c_str());
  ////////////////////////////////////////
  // If I uncomment even one of the preceding lines (the string decl. line)
  // then the exception below is *not* caught, but the program terminates
  // abnormally. As it stands w/ the exception only, it "works"

  throw overflow_error("this works");
}

Note: all I did is add a declaration and assignment (never mind the string doesn’t mean anything).  It shouldn’t change the operation at all.  But it does.

./test_exception2
t = 6*26757 - 1

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
make: *** [test_exc2] Error 255

And Windoze puts up a dialog box:
err_dlg_box

 

So what’s going on here?

That’s my question.  I’m at the point of starting to examine assembly code; right now I don’t know, but I’m putting this out to the “world.”  In a sense, I’m crowd-sourcing for an answer, but I think my crowd might be too small.

 

Books Review

December 28, 2012

Finishing up blog posts from this last year; things I started, but never finished.

I’ve read two books that I ought to write a short review of.  One written by an acquaintance — a colleague of my wife’s.  Ashes, Ashes.  I have two overall reactions: first, it’s quite a long novel for a debut, but parts of it are quite well written — esp. where Darrell writes to his strength (his psychological profiles and descriptions are believable, vivid and still readable); there are points where the writing could use finer editing.  Second, I recall thinking at the end that there was a large aspect of deus ex machina — and this critique from someone who embraces the supernatural.

But speaking of the Supernatural, the second book is Heaven is For Real.  The true story of a boy who saw Heaven and returned to tell the story.

The second book is touching, and endearing, and had all the more impact on me that it was written from the perspective of the dad; and it rings true to me all the more because he admits times when he made mistakes and is honest about all the things he doesn’t understand.

So, the first is interesting, but long; I’m curious to read the sequel, and then I’ll probably have a different opinion.  I give it three stars of five, but know that it does not “end” as I’d like — and, in some sense, it doesn’t end.  But I don’t want to give away the end.  There are definitely parts, and a lot of them, that I’d emphasize, and they make great conversation starters, and the overall arch of the story is great.

And both stories — maybe a little more the second — make me want to sit down and have a talk with the author(s): ask questions, find out more, write a guide for readers…

(You may be able to tell that this post is quite old, and the stories have undoubtedly circulated, but if you haven’t yet read either or both, it’s still worth doing; neither story is specifically “dated” and both can be fresh at any time.)

Haskell Sudoku

December 22, 2012

This post is incredibly technical – it is software engineer at a deep level.  I’m not sorry.

I have a working Haskell program to solve Sudoku puzzles; right now, the board name is hard-coded, but I’m at least reading from a file, and I am quite sure there are boards I cannot solve – given my method is incomplete.
But next I am going to work on a program to run tests fr. outside Haskell, and other improvements.

The code is 17 lines in the main file (plus forty lines of “test” code); and SBoard.hs is 261 lines total. Finally, 24 lines of file reading: one main function, one sub-function and a one-liner for typed Integer square root of an Int

*BoardIO> :t sqrtInt
sqrtInt :: (Integral b, Integral a) => a -> b

(I’m no longer sure why I did that, but here’s the actual code:

sqrtInt i = floor $ sqrtFloat $ 1.0 * (fromIntegral i)

Now then, the primary function is:

main =
    do
      b <- doRead "n.sdk"
      -- print b
      -- return (solve b)
      solv_dbg b

As you can see, I orignally called solve, which takes a Board as input and returns a Board, but since main has an IO monad, I needed the return there — which has nothing to do with “return” as most programmers know it and love it.

Sans putStrLn and print expressions, here is my main function for solving:

solve b =
  let b1 = calcUniqs b
       b2 = calcOpen b1
  in
   if b2 == b
      then b
     else solve b2

calcUniqs

To examine the function to calculate “unique” cells (by that I mean cells where only one value is posssible – being forced by being unique), first I need to example this utility function

{- 
    calculate a cell - if it's already known, done; 
         if there's only one possibility, done
    otherwise, it's zero for now
 -}
calc_cell c =
  let d = fst c
       u = snd c
   in
     if d > 0
        then d
       else if length u == 1
               then head u
              else 0

This is used in the “final” expression, below.  Given tuples (a, [a]) wehere a is an Ord and also a Num (due to its usage in the function); the first is the current value of the cell (zero = blank), and the second part is the list of “possible” values for this cell — it’s possible, given the calculation of this list, that there may be multiple values even though the cell is already solved, but this function doesn’t care.  The logic is,

If this “cell” is already calculated, then we’re done, return that value; else, if the list (of possible values) length is 1, then that is the new value; otherwise, the value is (still) unknown/blank, so return zero.

I should explain, this “fell out” naturally from the way I decided to encode the Board itself, and also the resulting possible values and so on.

type Symbols = [Char]
data Board = B Symbols Int [String]

A Board is, initially, a list of symbols (identical to a string, by the way), an integer which is the square root of symbols (for a 9×9 board, this is 3), then a list of Strings (technically, I ought to make that a list of symbols, I suppose…)

One very important helper function converts the list of strings — each of which is one row — into a list of lists of integers;

“toSolve”

The following is the “heart” of most of the calcs that follow (and precede)

{-
   convert a board into an array of "cells,"
   where each cell is (d, [Ints]) - if d is zero, the cell is open
   the list of integers represents the possible* values there
   (* note that is not true if d is non-zero, but in that case, we don't care)
-}
toSolve b =
    let
        rs = arrFromBoard b
        cs = transpose rs
        ps = patches b
        unf_r = map avail rs
        unf_c = map avail cs
        unf_p = map avail ps
        sq = square b
        unf = map (\x -> map (intersect x) unf_c) unf_r
        -- the following creates an "array" (list of lists)
        -- which is the same dimensions as arrFromBoard
        idx_p = map (\r -> map (\c -> sq * (sect r sq) + (sect c sq))
                           [0..(sq*sq-1)]) [0..(sq*sq-1)]
        cmplx = map (\r -> zip (fst r) (snd r)) $ zip unf idx_p
        unf2 = map (\r -> map (\i -> intersect (fst i) (unf_p !! snd i) ) r) cmplx
    in 
        map (\r -> zip (fst r) (snd r)) $ zip rs unf2

From the inside out, the underlined map takes a list (e.g. “[0..8]”) of column indicies and returns a list of indicies of the patch for this “cell” (r, [0..8]).  That map is within a func. mapped over a list of row indicies

At the end of this, idx_p is a list of lists which represents the patch index of the corresponding cell in the board array.

So, the let section of this calculates the rows (rs), then the columns (cs), then the patches (ps) — my term for the sub-squares, 3×3 on a 9×9 board; the remaining values per row (unf_r), column (unf_c) and patch (unf_c).  Next, unf represents the “intersection” of remaining values per row and column. 

Now “cmpx” is an array of (p, [Int]) tuples – same dimensions as the Sudoku board — twice is use the “pattern”

   map (\r (zip (fst r) (snd r)) $ zip <something> <else>

Where <something> and <else> represent matching arrays; in one case, “elements” of <something>” are lists, in the other, elements of <else> are lists.   The result is an array of tuples (s_i, e_i) where each “s” and each “e” are an element of <something> and <else> respectively.
In both cases, <something> and <else> are lists of lists of elements – either [[a]], or [[[a]]]; in the easier case, a list of rows, where each row is a list of columns, where each column is a single value (an Int, say) which is the value of a cell; in the more complex case, a list of rows, of columns, where each column ‘value’ is itself a list of some data representing a list of possible values, for instance, for this cell.

… and that is perhaps the most complex description I’ll write.  (I only hope that, should I come back to read this later, it will still make sense.)

Finally

calcOpen b =
  let syms = symbols b
   in
   --  the following assumes that the blank space (" ") is not a symbol
   B syms (square b) $ arrToSyms (map (\r -> map calc_cell r) (toSolve b)) syms ' '

So this calls toSolve on b, the Board, then “map (\r -> map…” because it’s a list of lists calls calc_cell on each element — and that’s why calc_cell takes the input it does.

The function toSolve takes a Board as input, as we’ve seen, and returns an array [a list of lists] of cells, where each cell is a tuple, which can be input to calc_cell far above.

After the map-map, the result is an array of new values, zero thru nine for a 9×9 board, and arrToSyms <array> syms ' ' converts that back to the [String] data to store in the Board.  “B...” is the board constructor.

show

The following code, in three functions, allows me to (pretty) print a Board

rowToStr r s =
 
  if length r > s 

     then show (take s r) ++ "  " ++ (rowToStr (drop s r) s)

    else show r



extraRow a s =

  if length a > s

     then (take s a) ++ [[]] ++ (extraRow (drop s a) s)

    else a



instance Show Board where

  show b =
 
    let s = square b
 
        rows = map (\r -> rowToStr r s) $ arrFromBoard b

     in unlines $ extraRow rows s

The magic, which I ought to remember, is in “instance Show Board where\n show…”

The function takes a Board [type] and returns a string.

 

What I’ve learned

There’s a lot to write here, but I’ve started to get the “hang” of monds — which I’ll have to write later, but others have done better.

Most important, for now, is this: the book Real World Haskell recommends that “beginners” should write the type signature first, to validate the code they get is what they intended.  I, however, took only half that advise — I thought carefully about what I wanted, but coded the function then checked the result, without including the “declaration.”  (I think I’d get the book, if I can find an updated version; there is a lot more in there than I know, yet.)

 

 

Pie in the face

November 16, 2012

Ryan was here.

A Conversation about Apps

February 1, 2012

I wrote this, literally, last year, and never published it.  Sorry it’s so late.

It started with a tweet from a friend (Siri can access Best Buy’s product catalog thru Wolfram Alpha), which encouraged me quite a bit after reading this downer (“Siri Is Apple’s Broken Promise“).

As is my wont, I responded, “I see this happening more and more (call it “app hyper linking”); I’m doing it more and more. Kids today will think no more of –”  And also, an example (Siri and Watson, or Cyc [or, now that I think of it, Wikipedia!]).

But I’m not sure Mark got that I only used Kinect as one “fer instance.”

Or maybe he did, and linked to another thought.  Then more:

“Trick is to figure out a way to get synergy from hi-res display, simultaneous site/app access and standard api for data exchange”

“I think we understand data interactions pretty well. The next breakthrough requires increased density and scale of visualization…”

I didn’t realize the full import of what that meant till now; I replied in a different direction.  Since we were talking (initially) about Siri, and I still think there’s some future to voice UI.

Then Mark added more, different thoughts (for him, the main UI of the most interesting UI of ‘the future’ is Kinect).

But I got stuck on the data thing.  Was I wrong?  I added a ref. to a story I never fully read, until now.  Here’s the conclusion from that article:

The field of astronomy is starting to generate more data than can be managed, served and processed by current techniques. This paper has outlined practices for developing next-generation tools and techniques for surviving this data tsunami, including rigorous evaluation of new technologies, partnerships between astronomers and computer scientists, and training of scientists in high-end software engineering engineering skills.

But back to what we were saying… what were we saying?

I started on the subject of “app-linking.”  The best example I have, simple though it be, is a link in my (work) e-mail to a WebEx.  From the mail app, I click the link, which switches to Safari, which somehow recognizes this is not a normal web page and launches the WebEx app.  People have complained of the lack of integration in Siri (I expect more from Apple in the months and years to come).  I remember the first time I had a full multi-OS/multi-platform experience: an old Mac iBook, running Linux, running VMWare, connected to a Windows virtual machine (it looked like Windows, felt like Linux, and had the shell of Apple).  I think this type of cross-ness will only increase, to the point where kids today won’t give a hoot (most of the time) about what “platform” their on.  Except maybe the specs of the display — and then only to figure out how to configure three “monitors” (including a wall-projector and/or a multi-panel configured LCD), and a wireless mic/headset to a back-room server of ginormous proportions [running Windows, Mac and Linux respectively] — and “apps” running in the monitor itself, communicating flawlessly with “traditional” applications, and data-manipulating back-ends software I haven’t even thought of, yet.

Our other main tangent was UIs — I like voice, Mark favors Kinect.  I think the computer from Star Trek is not that far away; but gesture-based interaction is coming nearer, too.