moves Function

pure function moves(istart, iend) result(imoves)

Arguments

Type IntentOptional Attributes Name
integer(kind=ip), intent(in) :: istart

indices for start and end nodes

integer(kind=ip), intent(in) :: iend

indices for start and end nodes

Return Value integer(kind=ip)


Called by

proc~~moves~~CalledByGraph proc~moves problem_8::moves program~problem_8 problem_8 program~problem_8->proc~moves

Source Code

    pure function moves(istart, iend) result(imoves)

        integer(ip),intent(in) :: istart, iend !! indices for start and end nodes
        integer(ip) :: imoves

        integer :: i
        integer(ip) :: idx

        i = 0
        imoves = 0
        idx = istart
        do
            !write(*,*) nodes(idx)%name
            if (idx == iend) exit
            ! if (idx == istart) write(*,*) 'back to start'
            imoves = imoves + 1 ! another move
            i = i + 1
            if (i>len(instructions)) i = 1
            idx = nodes(idx)%lr_idx(instructions_ints(i))
        end do

    end function moves