Search Results  Total results: 10 
1 
JB Programming Discussions
/ Re: how many jumps 
on: Today at 3:43pm 
Started by zzz000abc  Post by bplus 
Here is a version using iif function: Code:input "Jump height = ";up
input "Slide down = ";down
input "Number of walls = ";nWalls
advance = up  down
for w = 1 to nWalls
print "For wall ";w; : input ", enter height = ";wall
remain = wall  up
j = j + 1 + iif(remain > 0, int(remain/advance) + (remain mod advance <> 0), 0)
next
print "Total jumps = ";j
function iif(bool, tValue, fValue)
if bool then iif = tValue else iif = fValue
end function


2 
JB Programming Discussions
/ Re: how many jumps 
on: Today at 12:41pm 
Started by zzz000abc  Post by zzz000abc 
on Today at 12:01pm, bplus wrote:I like this line! Code: j=((hhr)/(xy))+(r<>0)+(h>=x) 

Inspired by Rod from here [url=http://justbasic.conforums.com/index.cgi?board=code&action=display&num=1492436827][/url] in reply #3 Quote:I had to figure out why decimals weren't popping up 

remainder is subtracted.


3 
JB Programming Discussions
/ Re: how many jumps 
on: Today at 12:01pm 
Started by zzz000abc  Post by bplus 
Thanks for explanation for walls of 0 height. OK I can accept that. ;))
I like this line! Code:j=((hhr)/(xy))+(r<>0)+(h>=x)
I had to figure out why decimals weren't popping up.


4 
JB Programming Discussions
/ Re: how many jumps 
on: Today at 02:23am 
Started by zzz000abc  Post by zzz000abc 
Quote:Another problem, try this for input:
5 1 1 999999999999999 

here is the solution Code:input"values";v$
x=val(word$(v$,1))
y=val(word$(v$,2))
ind=val(word$(v$,3))
dim h(ind+1),a(ind+1)
print ind
for i=1 to ind
h(i)=val(word$(v$,i+3))
next
for i=1 to ind
j=0
h=h(i)
if h=0 then
j=1
else
if h>=x then hh=hx else hh=h
r=hh mod (xy)
j=((hhr)/(xy))+(r<>0)+(h>=x)
end if
a(i)=j
next
for i=1 to ind
print a(i),
kk=kk+a(i)
next
print
print "total jumps";kk
edit 1. zero height is also considered. for example you may have 11inch wall ie., wall of 0 ft height. edit 2. on the other hand if there no wall at all then also we can say it's zero height wall but we should not enter this zero in input.if so there will be infinite walls of zero height. so when we enter zero for wall height we assume the case similar to one described in edit1.


5 
JB Programming Discussions
/ Re: how many jumps 
on: Yesterday at 3:08pm 
Started by zzz000abc  Post by bplus 
Another problem, try this for input:
5 1 1 999999999999999


6 
JB Programming Discussions
/ Re: how many jumps 
on: Yesterday at 1:44pm 
Started by zzz000abc  Post by bplus 
How about when the "walls" are negative in height, then they are ditches/rivers/moats the hero has to jump across them.
Make the jumps parabolic with dx and dy calculations involving gravity.


7 
JB Programming Discussions
/ Re: how many jumps 
on: Yesterday at 1:41pm 
Started by zzz000abc  Post by zzz000abc 
Quote:Error when wall height is 1 

Now it works Code:input"values";v$
x=val(word$(v$,1))
y=val(word$(v$,2))
ind=val(word$(v$,3))
dim h(ind+1),a(ind+1)
print ind
for i=1 to ind
h(i)=val(word$(v$,i+3))
next
for i=1 to ind
j=0
while j*(xy)<h(i)
if j<>0 and ((j*x)((j1)*y))>=h(i)then exit while
j=j+1
wend
a(i)=j
next
for i=1 to ind
print a(i),
k=k+a(i)
next
print
print "total jumps";k


8 
JB Programming Discussions
/ Re: how many jumps 
on: Yesterday at 1:24pm 
Started by zzz000abc  Post by zzz000abc 
on Yesterday at 12:00pm, bplus wrote:Well I hope y is always < x OR x > wall. 

yes B+ you are right. Quote:Here is zzz000abc's code with more descriptive variable names and more wordy reporting 

nice B+ ,actually I am thinking to make it a game using graphics. It can be like this: thief should run trying to escape jumping over the walls ,user should shoot him arrows or with gun.


9 
JB Programming Discussions
/ Re: how many jumps 
on: Yesterday at 12:47pm 
Started by zzz000abc  Post by bplus 
Here is zzz000abc's code with more descriptive variable names and more wordy reporting: Code:print "Enter all values seperated by spaces:"
print "jumpHeight slideDownDistance nWalls wallHeight1 wallHeight2 wallHeight3... "
input "> ";values$
upDistance = val(word$(values$,1))
downDistance = val(word$(values$,2))
nWalls = val(word$(values$,3))
dim wallHeights(nWalls+1),jumps(nWalls+1)
print "Number of walls ";nWalls
for i=1 to nWalls
wallHeights(i)=val(word$(values$,i+3))
next
for i=1 to nWalls
j=0
while j*(upDistancedownDistance) < wallHeights(i)
if ((j*upDistance)((j1)*downDistance)) >= wallHeights(i)then exit while
j = j+1
wend
jumps(i) = j
next
for i=1 to nWalls
print "For wall ";i;" the number of jumps is ";jumps(i)
totJumps = totJumps + jumps(i)
next
print
print "Total jumps ";totJumps
Output: Code:Enter all values seperated by spaces:
jumpHeight slideDownDistance nWalls wallHeight1 wallHeight2 wallHeight3...
> 5 1 2 9 10
Number of walls 2
For wall 1 the number of jumps is 2
For wall 2 the number of jumps is 3
Total jumps 5
Error when wall height is 1: Code:Enter all values seperated by spaces:
jumpHeight slideDownDistance nWalls wallHeight1 wallHeight2 wallHeight3...
?5 1 1 1
Number of walls 1
For wall 1 the number of jumps is 0
Total jumps 0


10 
JB Programming Discussions
/ Re: how many jumps 
on: Yesterday at 12:00pm 
Started by zzz000abc  Post by bplus 
Well I hope y is always < x OR x > wall. I predict (assuming x < wall) jumps equals int((wall  x) / (xy)) + 1 if (xy) divides (wall  x), if not, add one more jump .


