From 2c4e45d9a9bafc367ef5a07ee411d81979bbd2d8 Mon Sep 17 00:00:00 2001 From: Zafir Stojanovski Date: Mon, 6 Oct 2025 13:02:32 +0200 Subject: [PATCH] Update spiral_matrix.py (#511) * Improve spiral matrix instructions with clearer movement description and hint --------- Co-authored-by: Andreas Koepf --- reasoning_gym/algorithmic/spiral_matrix.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/reasoning_gym/algorithmic/spiral_matrix.py b/reasoning_gym/algorithmic/spiral_matrix.py index 651e5d69..228d15d6 100644 --- a/reasoning_gym/algorithmic/spiral_matrix.py +++ b/reasoning_gym/algorithmic/spiral_matrix.py @@ -14,12 +14,14 @@ from ..factory import ProceduralDataset, register_dataset QUESTION_TEMPLATE = """Given a matrix, your job is to generate a list of elements in spiral order, starting from the top-left element. The spiral order is clockwise, starting from the top-left corner. More precisely: -- Start from the top-left corner and move right. -- Move down towards the bottom-right corner. -- Move left towards the bottom-left corner. -- Move up towards the top-right corner. +- Start from the top-left corner and move right along the top row. +- Move down along the right column. +- Move left along the bottom row. +- Move up along the left column. - Repeat the steps for the inner elements of the matrix until every entry is visited. +Hint: Think of peeling the matrix layer by layer from the outside inward. Each layer forms a rectangular frame, and you traverse each frame clockwise starting from its top-left corner. + Your output should be a space-separated list of integers, e.g. 1 2 3 4 5 6 For the matrix below, what is the list of elements in spiral order?