Talk:Spiral matrix: Difference between revisions

Deleted my post of a couple of days ago. On reflection it didn't add anything to the conversation.
(Deleted my post of a couple of days ago. On reflection it didn't add anything to the conversation.)
 
(16 intermediate revisions by 9 users not shown)
Line 43:
['C',1],
['D',2],
['E',0] ],
['F',3] ]
 
Pulling out the second column from the matrix (the integers), you'd get this:
 
[4,5,1,2,0,3]
 
Which is the grade.
Line 267 ⟶ 268:
:--[[User:Paddy3118|Paddy3118]] 16:56, 5 August 2008 (UTC)
::This one includes a sort, too :) That's one of the neatest parts! Alright, let me write out the algo real quick (I'll gloss over details and may fib a bit, to get the idea across quickly).
 
 
== Python array initialisation edit problem ==
Hi Spoon, your edit to Spiral of substituting <python>array = [[None]*n]*n</python> for <python>array = [[None]*n for j in range(n)]</python> [[http://www.rosettacode.org/w/index.php?title=Spiral&curid=2967&diff=16906&oldid=16746 here]] doesn't work because of:
<lang python>>>> n=2
>>> a = [[None]*n]*n
>>> a
[[None, None], [None, None]]
>>> a[0][0] = 1
>>> a
[[1, None], [1, None]]
>>></lang>
You are referencing the inner list multiple times instead of creating new copies. --[[User:Paddy3118|Paddy3118]] 06:17, 14 August 2008 (UTC)
:Oh yeah, sorry. You're right. --[[User:Spoon!|Spoon!]] 18:58, 14 August 2008 (UTC)
 
==Lua spiralling error?==
Task says:
"where the numbers increase sequentially as you go around the edges of the array spiralling inwards"
Lua says:
"returns the value at (x, y) in a spiral that starts at 1 and goes outwards"
 
I haven't run the program to see its output, but could someone check that the spiral is as in the task description? Thanks. --[[User:Paddy3118|Paddy3118]] 08:24, 29 January 2010 (UTC)
 
: Lua output is
<pre>
14 15 16 17 18 19 20 21
13 38 39 40 41 42 43 22
12 37 54 55 56 57 44 23
11 36 53 62 63 58 45 24
10 35 52 61 60 59 46 25
9 34 51 50 49 48 47 26
8 33 32 31 30 29 28 27
7 6 5 4 3 2 1 0</pre>
 
: which seems correct (even though starting from lower-rightmost corner). &mdash; [[User:ShinTakezou|ShinTakezou]] 10:35, 21 May 2010 (UTC)
 
== Spiral Matrix implementation in VBA ==
 
hii
i came across this page during a search for a mechanism to implement the spiral matrix in VBA bt unfortunately it was not listed here. But afrterwards by translating the java code i manage to obtain the result. I beleive a lot f peopla have manage to do this but didnt come across anyone who has shared it
so here it goes....
 
:Howdy, and welcome to RC (if appropriate). Might I suggest creating an account?
:Having said that, code submissions really should go on [[Spiral matrix|the task's page]], and not its talk page. I've moved it for you: [[Spiral matrix#VBA]]. I made some changes so that it is more generalized; your use of <code>Init</code> (which I assume sets up certain starting conditions) doesn't help anyone without access to your code.
:(As a minor aside, I have to wonder at your use of cells way down in the 400+ range. For something like this, I'd think that just starting at A1 would be acceptable.)
:Not trying to be a jerk, just trying to help. -- [[User:Eriksiers|Erik Siers]] 18:28, 21 September 2010 (UTC)
 
==Really long line in C#==
It doesn't look like best coding practice to have that really long line. Wouldn't it be better with some newlines and spacing to better show its structure and cut the line length? --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 06:58, 30 September 2015 (UTC)
 
: I wrapped it. Hopefully that makes it ok... --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 12:28, 30 September 2015 (UTC)
 
:: It's a lot better, thanks. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 12:46, 30 September 2015 (UTC)
1,462

edits