Karpathy挑战第一集
Karpathy Challenge
As an analytical thinker, imagine the 5x5 grid ofrandom integers in the range [1, 10] as a spiral or a roll of tape. Your task is to unwind this roll in a Swiss Roll. Each cell is identified by a letter (A-E) and a number (1-5). Your task is to navigate this grid in a Swiss Roll pattern. **Coordinate System Introduction**: - Each row is labeled A-E, top to bottom. - Each column is labeled 1-5, left to right. **Ask Yourself**: - "At each step, which coordinate am I moving to next?" - "Does my path logically follow the Swiss Roll pattern?" **3x3 Example with Coordinates**: \`\`\` A1: 4 B1: 7 C1: 2 A2: 5 B2: 9 C2: 6 A3: 3 B3: 8 C3: 1 \`\`\` **Swiss Roll Order for 3x3 Example**: - Start at A1 (4), move to A2 (5), then A3 (3). - Move to B3 (8), then C3 (1). - Move to C2 (6), then C1 (2). - Move to B1 (7). - Finally, to B2 (9). Result: A1, A2, A3, B3, C3, C2, C1, B1, B2 Values: 4,5,3,8,1,6,2,7,9 **4x4 Example with Coordinates**: \`\`\` A1: 8 B1: 3 C1: 7 D1: 2 A2: 5 B2: 10 C2: 6 D2: 4 A3: 1 B3: 9 C3: 11 D3: 12 A4: 13 B4: 14 C4: 15 D4: 16 \`\`\` **Swiss Roll Order for 4x4 Example**: - Start at A1 (8), move down through A2 (5), A3 (1), A4 (13). - Move right across B4 (14), C4 (15), D4 (16). - Move up through D3 (12), D2 (4), D1 (2). - Move left to C1 (7), B1 (3). - Move down to B2 (10), B3 (9). - Move right to C3 (11). - Finally, move up to C2 (6). Result: A1, A2, A3, A4, B4, C4, D4, D3, D2, D1, C1, B1, B2, B3, C3, C2 Values: 8, 5, 1, 13, 14, 15, 16, 12, 4, 2, 7, 3, 10, 9, 11, 6 **Now, Apply to a 5x5 Grid with Coordinates**: 1. **Create a 5x5 Array**: Imagine a grid labeled A-E (rows) and 1-5 (columns) filled with random numbers. 2. **Start at the Top Left (A1)**. 3. **Navigate the Grid**: Follow the Swiss Roll order, moving through coordinates systematically. 4. **List the Coordinates**: Record the coordinates in the order you traverse them. 5. **List the values of the coordinates in the order you traverse them.** This approach demonstrated with the 3x3 and 4x4 examples, will guide you through the Swiss Roll order for any array size, now with an added coordinate system for clarity and precision.
来源
TheBigPromptLibrary · MIT · Episode 1 - By Alvaro A. Alvarez
英文原文,未做机器翻译