cinemast / sudoku

Sudoku solver based on the initial work of Michael Kennett
11 stars 3 forks source link

multiple puzzle output on postscript #2

Open anarcat opened 8 years ago

anarcat commented 8 years ago

it seems that the postscript output doesn't respect the -gN option: if i use sudoku -g3, i get three puzzles:

$ sudoku -g 3
% randomly generated - medium
 . . . | . 4 . | 9 2 .
 8 . 7 | 9 . . | . . .
 9 . . | . . 6 | . 4 .
-------+-------+-------
 . . 3 | . 7 . | . 9 .
 1 . . | 8 . 4 | . . 5
 . 8 . | . 5 . | 3 . .
-------+-------+-------
 . 5 . | 7 . . | . . 6
 . . . | . . 3 | 2 . 1
 . 1 8 | . 6 . | . . .
% randomly generated - easy
 . 3 . | 1 . 5 | . 6 .
 . 1 9 | . . . | 7 4 .
 2 . . | . . . | . . 9
-------+-------+-------
 . . 6 | 4 3 1 | 9 . .
 . . . | . . . | . . .
 . . 5 | 7 2 8 | 6 . .
-------+-------+-------
 6 . . | . . . | . . 5
 . 5 4 | . . . | 2 8 .
 . 9 . | 6 . 3 | . 7 .
% randomly generated - medium
 . 7 . | 8 . . | 5 6 .
 5 . . | . 1 . | 8 . 7
 6 . . | . 9 . | . . .
-------+-------+-------
 . 9 8 | . . 1 | . 7 .
 . . . | . 2 . | . . .
 . 6 . | 4 . . | 1 2 .
-------+-------+-------
 . . . | . 7 . | . . 3
 9 . 7 | . 6 . | . . 2
 . 3 2 | . . 8 | . 1 .

but then when i send this into a postscript file, only a single one is rendered, or more precisely, three postscript files are created in a row, which doesn't render correctly in my PDF rendered (evince in linux):

$ sudoku -g 3 -fps
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 211 301 401 491
%%Creator: Sudoku by Michael Kennett
%%CreationDate: Mon Dec 28 17:52:04 2015
%%Title: randomly generated - medium
%%EndComments
(5   9   813     57   2 7    6  8  74  9   1  85  4  2    6 4   91     437   3   5)
211 301 translate
0 setgray
1 setlinewidth 1 8 {dup 20 mul 5 add dup dup dup
  5 moveto 185 lineto 5 exch moveto 185 exch lineto 1 add} repeat pop stroke
3 setlinewidth 1 2 {dup 60 mul 5 add dup dup dup
  5 moveto 185 lineto 5 exch moveto 185 exch lineto 1 add} repeat pop stroke
1 setlinejoin 5 5 moveto 5 185 lineto 185 185 lineto 185 5 lineto closepath stroke
/Helvetica-Bold findfont 12 scalefont setfont
0 81 {2 copy 1 getinterval dup stringwidth pop
  20 exch sub 2 div 2 index 9 mod 20 mul add 5 add
  8 3 index 9 idiv sub 20 mul 10 add
  moveto show 1 add} repeat pop pop
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 211 301 401 491
%%Creator: Sudoku by Michael Kennett
%%CreationDate: Mon Dec 28 17:52:04 2015
%%Title: randomly generated - hard
%%EndComments
(2 54 69 7  9   5  78     41   7 9    2     1    3 4   59     83  2   4  8 19 37 2)
211 301 translate
0 setgray
1 setlinewidth 1 8 {dup 20 mul 5 add dup dup dup
  5 moveto 185 lineto 5 exch moveto 185 exch lineto 1 add} repeat pop stroke
3 setlinewidth 1 2 {dup 60 mul 5 add dup dup dup
  5 moveto 185 lineto 5 exch moveto 185 exch lineto 1 add} repeat pop stroke
1 setlinejoin 5 5 moveto 5 185 lineto 185 185 lineto 185 5 lineto closepath stroke
/Helvetica-Bold findfont 12 scalefont setfont
0 81 {2 copy 1 getinterval dup stringwidth pop
  20 exch sub 2 div 2 index 9 mod 20 mul add 5 add
  8 3 index 9 idiv sub 20 mul 10 add
  moveto show 1 add} repeat pop pop
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 211 301 401 491
%%Creator: Sudoku by Michael Kennett
%%CreationDate: Mon Dec 28 17:52:04 2015
%%Title: randomly generated - medium
%%EndComments
(2   7   9 7  9  6 1  5 6  87 5   9 3  32 97  9 1   4 28  7 3  4 1  6  9 6   8   7)
211 301 translate
0 setgray
1 setlinewidth 1 8 {dup 20 mul 5 add dup dup dup
  5 moveto 185 lineto 5 exch moveto 185 exch lineto 1 add} repeat pop stroke
3 setlinewidth 1 2 {dup 60 mul 5 add dup dup dup
  5 moveto 185 lineto 5 exch moveto 185 exch lineto 1 add} repeat pop stroke
1 setlinejoin 5 5 moveto 5 185 lineto 185 185 lineto 185 5 lineto closepath stroke
/Helvetica-Bold findfont 12 scalefont setfont
0 81 {2 copy 1 getinterval dup stringwidth pop
  20 exch sub 2 div 2 index 9 mod 20 mul add 5 add
  8 3 index 9 idiv sub 20 mul 10 add
  moveto show 1 add} repeat pop pop

it should at least merge those into multiple pages of the same postscript file or something... ideally, it would show as a grid, with a subtitle describing the level as well...

cinemast commented 8 years ago

If you have a patch for fixing that, it would be great. I currently don't have the resources to fix it.

Anyway thanks for taking the effort reporting it here.

anarcat commented 8 years ago

ok cool, i'll look what i can do, if anything... can't believe it should be that hard... ;)

cinemast commented 8 years ago

I agree, I just have no knowledge of the postscript yet. I just kind of rehosted the project because there was no active upstream anymore.