More about Number Puzzles

Started by Gymbo, December 31, 2022, 02:59:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Gymbo

Hi,

This is something I've been working and playing with for a long time. See "Anyone for number puzzles?" in the Off-Topic section of this forum. That didn't get much of a response but it got me going.

There is a zip file attached that has a setup file called psetup.exe, and a ReadMe.txt.
See it for a complete explanation. It also has the DesignCAD macro (Puzzles.d3m) that started all this, there used to be 16 of them.

I've included a shortened version of the code for the Puzzles.d3m here if you want to see what it does.

'Puzzles.d3m
'12/23/22
'Includes puzzles from 5 thru 20

INCLUDE "dcadalias.d3i"
Precision 0
dim num(62), z$(12)

'****************************************************************
'this is a sample. path$ needs to be modified for the user's path
'path$ = "d:\users\user name\AppData\Roaming\Gymbo\Puzzles\"

open "I", 1 path$ + "Which.txt"
  input #1, ps
close 1

'these are the variable for the individual puzzles
if ps = 5 then
    k2 = 3
     j2 = 11
     h1 = 48
     h2 = h1 + 2 * ps - 1
     h3 = 43
     h4 = 47
end if
|
|
|
if ps = 20 then
    k2 = 11
     j2 = 41
     h1 = 169
     h2 = h1 + 2 * ps - 1
     h3 = 63
     h4 = 68
end if
' end individual variables

Qs$ = ps 
'ps = puzzle size
'ts = text file size
ts = 3 * ps + 2

msg$ = "star" + Qs$ + ".txt"  'star##.txt
fname$ = path$ + msg$
'these text files hold the random numbers produced by "Star Choose"

open "I", 1, fname$
  for i = 1 to ts
    input #1, num(i)
  next
close 1

i = 1
k = 1
for j = 1 to ts
GetAttr j, type, select, laynum, group, red, green, blue, solid
entity j
ltr$ = sys$(1)

if ltr$ = "#" then
a$ = num(1)
fname$ = "Star" + Qs$ + "_" + a$ + ".dcd"  'star##_n.dcd
  else
        if ps = 5 then gosub five
|
|
|
        if ps = 20 then gosub twenty
  end if
 
  if j > j2 then
PutAttr j, 13, 0, 2, Group, 0, 0, 0, solid
end if

a$ = num(i)

  i = i + 1
change t_text, a$
update
next

for k = 1 to k2
'break->
For h = h1 to h2 
GetAttr h, type, select, laynum, group, red, green, blue, solid
entity h
ltr$ = sys$(1)
if ltr$ = z$(k) then
ltr$ = " "
change t_text, ltr$
update
end if
next
next

for h = h1 to h2
GetAttr h, type, select, laynum, group, red, green, blue, solid
entity h
ltr$ = sys$(1)
next

sys(3) = 2 'set current layer
layer(3) = 0

sys(1174) = 0

Precision 2

sys(12) = 0.15  'text size

for h = h4 to h3 step -1
  entity h
  PutAttr h, t, 1
  >erase
{
}
next

fname$ = path$ + fname$

>saveAs
{
     <filename [fname$]
}
 
> FitToWindow
{
}
end

five:
if ltr$ = "B" or ltr$ = "F" or ltr$ = "I" then
PutAttr j, 13, 0, 2, Group, 0, 0, 0, solid
      a$ = num(i)
      z$(k) = a$
k = k + 1
    end if   
return

|
|
|
twenty:
if ltr$ = "B" or ltr$ = "D" or ltr$ = "F" or ltr$ = "H" or ltr$ = "J" _
or ltr$ = "L" or ltr$ = "N" or ltr$ = "P" or ltr$ = "R" or ltr$ = "n" or _
        ltr$ = "U" then
PutAttr j, 13, 0, 2, Group, 0, 0, 0, solid
a$ = num(i)
z$(k) = a$
k = k + 1
end if
return
end
Regards,

Jim

Gymbo

Regards,

Jim