Skip to content

Commit 8dd8628

Browse files
authored
Merge pull request #26 from saxbophone/josh/19
Fix oversized line bug
2 parents b88ba39 + 86498b7 commit 8dd8628

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

saxbospiral.png

-12 Bytes
Loading

saxbospiral/solve.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ static length_t
9494
suggest_resize(spiral_t spiral, size_t index) {
9595
// check if collides or not, return same size if no collision
9696
if(spiral.collides != -1) {
97+
/*
98+
* if the colliding line's length is greater than 1, we cannot make any
99+
* intelligent suggestions on the length to extend the previous line to
100+
* (without the high likelihood of creating a line that wastes space),
101+
* so we just return the previous line's length +1
102+
*/
103+
if(spiral.lines[index].length > 1) {
104+
return spiral.lines[index - 1].length + 1;
105+
}
97106
// store the 'previous' and 'rigid' lines.
98107
line_t p = spiral.lines[index - 1];
99108
line_t r = spiral.lines[spiral.collides];

0 commit comments

Comments
 (0)