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

  • SEARCH
  • Home
  • 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 8535939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:32:58+00:00 2026-06-11T10:32:58+00:00

Can somebody explain why this doesn’t work? (meaning the variable colorChange stays the same

  • 0

Can somebody explain why this doesn’t work? (meaning the variable colorChange stays the same throughout function)

Each array (leftRing and rightRing have integer values of numbers ranging from 1 through 4)

    Private Sub Solve_Click(sender As System.Object, e As System.EventArgs) Handles Solve.Click

    countColorChangesInRings(colorChanges)
    RotateLeftRingClockwise()
    countColorChangesInRings(colorChanges)

    End Sub

    Sub countColorChangesInRings(ByRef var As Integer)

    Dim colorChangesLeft As Integer = 0
    Dim colorChangesRight As Integer = 0
    Dim totalChanges As Integer = 0
    ' Count Color Changes in Left Ring
    For i = 1 To 20
        If (i = 20) Then
            If (leftRing(i) <> leftRing(1)) Then
                colorChangesLeft += 1
            End If
        Else
            If (leftRing(i) <> leftRing(i + 1)) Then
                colorChangesLeft += 1
            End If
        End If
    Next

    ' Count Color Changes in Right Ring
    For i = 1 To 20
        If (i = 20) Then
            If (rightRing(i) <> rightRing(1)) Then
                colorChangesRight += 1
            End If
        Else
            If (rightRing(i) <> rightRing(i + 1)) Then
                colorChangesRight += 1
            End If
        End If
    Next
    totalChanges = colorChangesLeft + colorChangesRight
    var = totalChanges
End Sub

 Sub RotateLeftRingClockwise()
    Dim temp As Integer = leftRing(1)
    ' Rotates Rings clockwise direction
    For i = 1 To 20
        If (i = 20) Then
            leftRing(i) = temp
        Else
            leftRing(i) = leftRing(i + 1)
        End If
    Next
End Sub
  • 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-06-11T10:33:00+00:00Added an answer on June 11, 2026 at 10:33 am

    From what I can see, it will stay the same.

    You basically have a circular buffer of values (due to your special handle when i = 20) and you count the number of times the value changes from index to index.

    That number is not going to change if you simply rotate the values through the circular buffer.

    Take for example, the array {1, 2, 2, 2, 3, 4}. There are four transitions there, 1-2, 2-3, 3-4 and 4-1.

    If you then rotate the list clockwise, you get {4, 1, 2, 2, 2, 3} and the transitions are 4-1, 1-2, 2-3 and 3-4.

    In other words, the order of the transitions may change, but the quantity does not.


    Based on your addition of the RotateLeftRingClockwise code, this is where your problem lies.

    Because it simply rotates the left ring, you’re not handling the intersection points of the Hungarian rings correctly. Rotating the left ring would, as well as moving the values around the left ring, change two of the array elements in the right ring (and vice versa), as per the diagram below:

       array element 1 (in a 32-element array)
              |
          +---+---+
          |       |
          V       V
         LLL     RRR
       LL   LL RR   RR
      L       *       R      <- shared cell is left(29)/right(5)
     L       R L       R
     L       R L       R
    L       R   L       R
    L       R   L       R
    L       R   L       R
     L       R L       R
     L       R L       R
      L       *       R      <- shared cell is left(21)/right(13)
       LL   LL RR   RR
     \   LLL     RRR   /
      \               /
       \----->>>-----/
         Direction of
           increasing
             array index
    

    Because your rotate code does not do this, the transition count of both rings will remain identical and hence the sum of them will not change.

    For example, say the top-middle cells are array element 1 (as shown) and it increases in a anti-clockwise direction (as your code seems to indicate from the fact that a clockwise rotation shifts from ring[i+1] to ring[i]).

    What your code needs to do is first rotate the left ring and then force the new values for the * cells into the right ring, something like:

    Sub RotateLeftRingClockwise()
        Dim temp As Integer = leftRing(1)
        For i = 1 To 19
            leftRing(i) = leftRing(i + 1)
        Next
        leftRing(20) = temp
    
        rightRing( 5) = leftRing(29)
        rightRing(13) = leftRing(21)
    End Sub
    

    Those array indexes in the last two lines are specific to my diagram above (32 cells rather than 20), you’ll need to adjust them for your own puzzle.

    If you make those changes (and similar ones to your other three rotation functions), you should find that the function starts returning different values. Specifically, rotating the left ring will leave the left value unchanged but should change the right value as different balls come into the intersection point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this snippet of the code. can somebody explain why It doesn't work,
Can somebody explain me why the small piece of code doesn't work? This is
Can somebody please explain to me why this doesn't work? I'm sorry I'm a
Hello, can somebody explain to me why this block of code doesn't work? ArrayList<Object>
Can somebody explain to me what this does in javascript? (function (x,y){}(x,y)); or this
Can somebody please explain to me the meaning of this line of code? val
Can somebody explain me the flow of control in this tutorial : http://www.vogella.de/articles/AndroidSQLite/article.html#tutorialusecp I
Can somebody explain to me why this works (in Python 2.5) : class Foo(object):
Can somebody explain to me where I'm going wrong with this login setup? I've
Can somebody explain to me what the below code is doing. before and after

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.