Given the long, long, long overdue announcement of Rebol's impending release as open source software, I returned to my pet dialect to solve this Bingo problem. I may soon be able to distribute Rebmu as its own, teensy GPL package. :)
Rebmu 88 characters
In the compact notation:
rtZ5[GisGpcRaZisGaAPgPCaSB6zAPv'*]l5[AgL5[apGfAsk+A5]]hd+Gu[raGin-NTrM'*fisGv5]p"BINGO!"
The dialect uses a trick I call mushing which is explained on the Rebmu page. It's "legit" in the sense that it doesn't cheat the parser; this is valid Rebol...and can actually can be freely intermingled with ordinary code as well as (ahem) "long-form" Rebmu...which BTW would be 141 characters:
[rt z 5 [g: is g pc r a z is g a ap g pc a sb 6 z ap v '*] l 5 [a: g l 5 [ap g f a sk+ a 5]] hd+ g u [ra g in- nt r m '* fis g v 5] p "BINGO!"]
(Given that I claim the compression is a trick that one can do without the help of automation or compilation, I actually develop the code in the mushed form. It's not difficult.)
It's actually quite simple, nothing special--I'm sure other Rebol programmers could shave things off. Some commented source is on GitHub, but the main trick I use is to build all the possible solutions in a long series ("list", "array", what-have-you). I build the diagonal solutions during the input loop, as it takes five insertions at the head and five appends at the tail to make them...and there's already a five-iteration loop in progress.
The whole thing easily maps to Rebol code, and I haven't yet thrown any "matrix libraries" into Rebmu with transposition or other gimmicks that seem to come up often. Someday I will do that but for now I'm just trying to work relatively close to the medium of Rebol itself. Cryptic-looking things like:
[g: is g pc r a z is g a ap g pc a sb 6 z ap v '*]
...are rather simple:
[
; assign the series pointer "g" to the result of inserting
; the z'th element picked out of reading in some series
; from input that was stored in "a"...this pokes an element
; for the forward diagonal near the front of g
g: insert g (pick (readin-mu a) z)
; insert the read-in series "a" from above into "g" as well,
; but *after* the forward diagonal elements we've added...
insert g a
; for the reverse diagonal, subtract z from 6 and pick that
; (one-based) element out of the input that was stored in "a"
; so an element for the reverse diagonal is at the tail
append g (pick a (subtract 6 z))
; so long as we are counting to 5 anyway, go ahead and add an
; asterisk to a series we will use called "v" to search for
; a fulfilled solution later
append v '*
]
Note: Parentheses added above for clarity. But Rebol programmers (like English speakers) generally eschew the application of extra structural callouts for indicating the grammar in communication...rather save them for other applications...
Just as an added bonus to show how interesting this actually is, I'll throw in some mix of normal code to sum the board. The programming styles are actually...compatible:
rtZ5[GisGpcRaZisGaAPgPCaSB6zAPv'*]
temp-series: g
sum: 0
loop 5 * 5 [
square: first temp-series
if integer! == type? square [
sum: sum + square
]
temp-series: next temp-series
]
print ["Hey grandma, the board sum is" sum]
l5[AgL5[apGfAsk+A5]]hd+Gu[raGin-NTrM'*fisGv5]p"BINGO!"
That's valid Rebmu as well, and it will give you a nice board sum before playing Bingo with you. In the example given, it says Hey grandma, the board sum is 912
. Which is probably right. But you get the point. :)