File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -290,20 +290,23 @@ public static int Steps {
290290 }
291291
292292 private static void Show ( ) {
293- Goal [ ] goalsArray = Goals . ToArray ( ) ;
293+ // when the stack is converted to an array
294+ // it is done in reverse!!
295+ // this caused bugs when
296+ // adapting this from the JavaScript version
297+ // (which just uses array push/pop)
298+ Goal [ ] goalsArray = Goals . Reverse ( ) . ToArray ( ) ;
294299
295300 if ( goalsArray . ElementAtOrDefault ( 0 ) == null ) {
296301 return ;
297302 }
298-
299- int len = goalsArray . Length - 1 ;
303+
300304 int size = 0 ;
301305 double reciprocal = 1 ;
302306 double multiplier = 0 ;
303-
304- // this MUST loop backwards
305- for ( int i = len ; i >= 0 ; i -- ) {
306- for ( int j = len ; j > i ; j -- ) {
307+
308+ for ( int i = 0 ; i < goalsArray . Length ; i ++ ) {
309+ for ( int j = 0 ; j < i ; j ++ ) {
307310 size = goalsArray [ j ] . Size ;
308311
309312 if ( size == 0 ) {
You can’t perform that action at this time.
0 commit comments