moves_any_z Function

pure function moves_any_z(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), dimension(:) :: iend

Return Value integer(kind=ip)


Called by

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

Source Code

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

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

        integer :: i
        integer(ip) :: idx

        i = 0
        imoves = 0
        idx = istart
        do
            !write(*,*) nodes(idx)%name
            if (any(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_any_z