Skip to content

Repository files navigation

Boggle Solver in J

See the Jtude file for some simple boggle-related calculations.

reading and querying word lists

WL =: '',.~^:2 (_1{.a.),~];._2@(1!:1)@<
NL =: ''$~0,{:$ PF=: WL'collins-prefixes.txt'[EX=: WL'collins-words.txt'
L =: {:@$-+/"1@(''&=)
W =: (-:"1 EX {~ EX&I.) @: (NL&,)
P =: (-:"1 PF {~ PF&I.) @: (NL&,)

graphs for boards & expansions for paths

G =: [:<@-.&_1"1@|:[:;"_1 (<:33#:4-.~i.9) |.!._1i.
A =: [,"_ 0/[-.~]{::~{:@:[

handling Qs

QU =: ('U'(1+[:I.'QQ'E.])}(#~1+'Q'&=)) ^: ('Q'&e.)
Q =: (QU :. (#~[:-._1|.'QU'&E.))"1

the search

E =: {{ ([: (#~ P @: Q @ ({&u)) [:;<@(A&v)"1) ^: (0<#) &.> }}
S =: {{ (,y) E (G$y) ^:a:<,.i.#,y }}
B =: {{ (\: L) /:~ (#~ W) ~. Q ; ({&(,y)) &.> S y }}

generating boards

BW =: Q (#~10< L) EX
SC =: 00011235813{~8<.#
RW =: {{try. (({~?@#) @ A&(G x)) ^: (<:y) ?*/xcatch.x RW yend.}}
RB =: 4 : 0
assert. (#y=.Q^:_1y) <: n=.*/xx$ toupper (y,a.{~65+?(n-#y)$26) ((p-.~i.n),~p=.x RW #y)} n $y
)
RL =: {{ y RB > ({~?@#) BW }}

z defs

shake_z_ =: RL_joggle_
board_z_ =: RB_joggle_
boggle_z_ =: B_joggle_
score_z_ =: SC_joggle_

About

Boggle solver in J

Topics

Resources

Stars

4 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages