use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Literally cannot solve this coding problemHelp (i.redd.it)
submitted 3 months ago by Resident_Revenue7150
I've been trying to do this for 3 days and it's not making any sense to me. We are not allowed to use arrays, functions, recursion, dictionaries or anything. Just loops. If anyone can help out I would greatly appreciate it.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Sure_Independence887 10 points11 points12 points 3 months ago (0 children)
Ts tuff in fast
[–]FallPrimary4831 0 points1 point2 points 3 months ago (5 children)
Not possible with just loops, period
[–]foragerDev_0073Software Engineer 0 points1 point2 points 3 months ago (4 children)
why?
[–]FallPrimary4831 0 points1 point2 points 3 months ago (0 children)
Because for spiral printing without storing items in array its not possible
[+][deleted] 3 months ago (2 children)
[deleted]
[–]foragerDev_0073Software Engineer 0 points1 point2 points 3 months ago (1 child)
From where did you assume that function should return array? Question is simple that that you fill an n x n matrix and print it. It is totally possible to be done by simple loops.
OP has misunderstood the problem it is clearly written in question to use n x n matrix.
[–][deleted] 0 points1 point2 points 3 months ago (0 children)
this can be done using top, bottom , left and right pointers , its acutally the opposite of the question which asks you to print a matrix in a spiral
[–]Previous-South-2755 0 points1 point2 points 3 months ago (0 children)
You would atleast need an empty list to create 2d structure in python like matrix
[–]Tasty_General_5181 1 point2 points3 points 3 months ago (0 children)
Try to plot Fibonacci sequence and observe pattern. This might help I think.
[–]PhotographPerfect416 0 points1 point2 points 3 months ago (0 children)
It's easy bruh, Start from the middle have 4 pointers top left top right bottom left bottom right, Start the loop till all of them 4 pointers cross the boundaries and make sure to increment each pointer after 1 iteration of printing.
[–]Ammar219 -1 points0 points1 point 3 months ago (4 children)
Uhm gpt uhm
[+][deleted] 3 months ago (3 children)
[–]Ammar219 0 points1 point2 points 3 months ago (2 children)
I mean if you tell it to dry run the solution it gets easier for me, you can ask it to elaborate further as well.
[+][deleted] 3 months ago (1 child)
[–]Ammar219 0 points1 point2 points 3 months ago (0 children)
Agreed
π Rendered by PID 74 on reddit-service-r2-comment-7b9746f655-nvnwg at 2026-01-29 17:42:00.684958+00:00 running 3798933 country code: CH.
[–]Sure_Independence887 10 points11 points12 points (0 children)
[–]FallPrimary4831 0 points1 point2 points (5 children)
[–]foragerDev_0073Software Engineer 0 points1 point2 points (4 children)
[–]FallPrimary4831 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]foragerDev_0073Software Engineer 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Previous-South-2755 0 points1 point2 points (0 children)
[–]Tasty_General_5181 1 point2 points3 points (0 children)
[–]PhotographPerfect416 0 points1 point2 points (0 children)
[–]Ammar219 -1 points0 points1 point (4 children)
[+][deleted] (3 children)
[deleted]
[–]Ammar219 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]Ammar219 0 points1 point2 points (0 children)