Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5976593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:15:04+00:00 2026-05-22T21:15:04+00:00

Before you say this is old question, I spent 24 hours trying to solve

  • 0

Before you say this is old question, I spent 24 hours trying to solve and read everything. I swear.

The code is supposed to receive one system id and then scan around that system in all directions, with each direction having its own length. It is like scanning a rectangle around that system where 9*9 = 81 systems.

The code works very well; but the problem. I get 8 duplicate results and there is a complete row missing from the results. The one just above the middle row. I think the problem is in the topsystem integer but I don’t know what is wrong with it.

here is the code:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" verticalAlign="middle">


<mx:Script>
    <![CDATA[


        private function startscan():void {
            var startsystem:int = int(system.text);
            var resultsys:String = systemsaround.text;
            var leftsystem:int = -4;
            var rightsystem:int = 4;
            var topsystem:int = -400;
            var downsystem:int = 400;
            var mediumsys:int = 0;
            var tempdownsystem:int = 0;
            var temptopsystem:int = 0;


            if(startsystem + downsystem > 10000){
                downsystem = 400 -((startsystem + downsystem) - 10000);
                downsystem = Math.floor(downsystem/100)*100;
                topsystem = topsystem - (400 - downsystem);
            }
            if(startsystem + topsystem < 1){
                topsystem = -400 + (1+(-1*(startsystem + topsystem)));
                topsystem = Math.ceil(topsystem/100)*100;
                downsystem = downsystem + (400 - (topsystem * -1));
            }
            if(startsystem + leftsystem < 1){
                leftsystem = -4 + (1+(-1*(startsystem + leftsystem)));
                rightsystem = rightsystem + (4 - (leftsystem * -1));
            }
            if(startsystem + rightsystem > 10000){
                rightsystem = 4 -((startsystem + rightsystem) - 10000);
                leftsystem = leftsystem - (4 - rightsystem);
            }

            resultsys = systemsaround.text;
            systemsaround.text = resultsys + "down" + downsystem + "top" + topsystem + "left" + leftsystem + "right" + rightsystem + ":" + startsystem + "\r";
            resultsys = systemsaround.text;

            while (rightsystem > 0) {
            resultsys = systemsaround.text;
            mediumsys = startsystem + rightsystem;
            systemsaround.text = resultsys + mediumsys + "\r";
            resultsys = systemsaround.text;
            tempdownsystem = downsystem;
            temptopsystem = topsystem;
            rightsystem--;

                        while (downsystem > 0) {
                            resultsys = systemsaround.text;
                            mediumsys = mediumsys + downsystem;
                            systemsaround.text = resultsys + mediumsys + "\r";
                            resultsys = systemsaround.text;

                            downsystem = downsystem - 100;


                        }
                        while (topsystem < 0) {
                            resultsys = systemsaround.text;
                            mediumsys = mediumsys + topsystem;
                            systemsaround.text = resultsys + mediumsys + "\r";
                            resultsys = systemsaround.text;

                            topsystem = topsystem + 100;


                        }
            downsystem = tempdownsystem;        
            topsystem = temptopsystem;


            }





            while (leftsystem < 0) {
            resultsys = systemsaround.text;
            mediumsys = startsystem + leftsystem;
            systemsaround.text = resultsys + mediumsys + "\r";
            resultsys = systemsaround.text;
            tempdownsystem = downsystem;
            temptopsystem = topsystem;
            leftsystem++;
                        while (downsystem > 0) {
                            resultsys = systemsaround.text;
                            mediumsys = mediumsys + downsystem;
                            systemsaround.text = resultsys + mediumsys + "\r";
                            resultsys = systemsaround.text;

                            downsystem = downsystem - 100;


                        }
                        while (topsystem < 0) {
                            resultsys = systemsaround.text;
                            mediumsys = mediumsys + topsystem;
                            systemsaround.text = resultsys + mediumsys + "\r";
                            resultsys = systemsaround.text;

                            topsystem = topsystem + 100;


                        }
            downsystem = tempdownsystem;        
            topsystem = temptopsystem;  



            }

                        while (downsystem > 0) {
                            resultsys = systemsaround.text;
                            mediumsys = startsystem + downsystem;
                            systemsaround.text = resultsys + mediumsys + "\r";
                            resultsys = systemsaround.text;

                            downsystem = downsystem - 100;


                        }
                        while (topsystem < 0) {
                            resultsys = systemsaround.text;
                            mediumsys = startsystem + topsystem;
                            systemsaround.text = resultsys + mediumsys + "\r";
                            resultsys = systemsaround.text;

                            topsystem = topsystem + 100;


                        }






        }
    ]]>
</mx:Script>


    <mx:VBox width="488" height="304" horizontalCenter="0" verticalCenter="-16" horizontalAlign="center" verticalAlign="middle">
        <mx:TextInput id="system" text="3375"/>
        <mx:TextArea width="80%" height="228" fontSize="10" id="systemsaround"/>
        <mx:Button label="start"  click="startscan()" id="start"/>
    </mx:VBox>

</mx:WindowedApplication>

if you supply the starting system as 3375, you get 81 results with those 8 duplicates:

  • 3379 3378 3377 3376 3371 3372
    3373 3374

and the missing numbers are (8 is missing):

  • 3279 3278 3277 3276 3274 3273
    3272 3271

I hope someone can point me in the right direction. Thanks.

update:

if you watch the part of the code that has if statements. this part handle the edges.specially zero and 10k. about what i want to do. think about it like a 9*9 dots field in rectangular shape. has 9 rows and 9 columns. each dot has an id from 1 to 10k. the input is the id of the dot in the center of the field (column 5, row 5). as now i know this centeral dot id. i want to loop through the whole field to find the other dots ids using topsystem(the distance between the centeral dot to the upper edge).downsystem (the distance between central dot to the lower edge).leftsystem (the distance between central dot and left edge).rightsystem (the distance between central dot and right edge).

the code is working fine but there is 8 missing ids that replaced by 8 duplicated ids. i dont know where they come from.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:15:04+00:00Added an answer on May 22, 2026 at 9:15 pm

    I am not sure what you are trying to do, so let me explain what I think you are trying to do.

    You have 10000 “systems” arranged in a 100×100 grid. Given a system number, you want to output all 81 system numbers around it. Except on the edges of the grid, you don’t want to output those.

    In that case, delete all of your code and try this instead:

    var x = int(system.text)%100;
    var y = Math.floor(int(system.text)/100);
    for(var dx=-4; dx <= 4; dx++)
    for(var dy=-4; dy <= 4; dy++) 
      if(0 <= x+dx && x+dx <= 100 && 0 <= y+dy && y+dy <= 100)
        systemsarround.text += x+dx + (y+dy)*100 + "\r";
    

    This is untested, but you get the idea.

    Another attempt:

    var x = int(system.text)%100;
    var y = Math.floor(int(system.text)/100);
    for(var dx=-4; dx <= 4; dx++)
    for(var dy=-4; dy <= 4; dy++){
      var sys = x+dx + (y+dy)*100;
      if(1 <= sys && sys <= 10000)
        systemsarround.text += sys + "\r";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Read on before you say this is a duplicate, it's not. (as far as
i've done this before but i cannot find my old code. how do you
This is quite a controversial topic, and before you say no, is it really,
Before someone said that I did not read I may say that I read
Before starting let me say: It's not homework, just plain, old, fun. Now, I'm
I have a simple question about .net delegates. Say I have something like this:
I am trying to refine my custom jquery plugin. I have asked this before
I know, variations of this question had been asked before. But my case may
Let's say before a user is allowed to view the creation page of a
Now, before you say it: I did Google and my hbm.xml file is an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.