Author |
Message |
|
Recursive Acronym
Advanced Member
Joined: 11 Dec 2006 Posts: 499
|
Posted: 14 Dec 2006 10:04:55 pm Post subject: |
|
|
The teaser:
What is the smallest program in BASIC for the 83(+) or 84+ that will ask for the values of A and B, then calculate the length of the hypotenuse of the right triangle with leg lengths A and B, displaying it and storing it to Ans? Of course, you can't use libraries or external programs, and you should give it a one character name.
My solution:
It is 20 bytes in size on the Memory Menu. I don't know if it is the best solution, but I think that it is.
EDIT:
Never mind. This is stupidly easy. I screwed up; the smallest program is 19 bytes. Darn...
Last edited by Guest on 28 Sep 2007 09:10:06 pm; edited 1 time in total |
|
Back to top |
|
|
c_plus_plus My Face Hertz
Active Member
Joined: 30 Jan 2006 Posts: 575
|
Posted: 14 Dec 2006 10:20:11 pm Post subject: |
|
|
I got 21. I can't find where to clip off the last byte. Did your memory screen actualy say 20?
[SPOILER (HIGLIGHT)]
:Prompt A,B
:√(A²+B²
[/SPOILER]
EDIT: How about a quadratic formula one of the same sort. mine is 45 bytes.
EDIT X2: now 44.
Last edited by Guest on 14 Dec 2006 10:47:38 pm; edited 1 time in total |
|
Back to top |
|
|
WikiGuru ADOS (Attention deficit... Oh! Shiny!)
Elite
Joined: 15 Sep 2005 Posts: 923
|
Posted: 14 Dec 2006 11:03:38 pm Post subject: |
|
|
What you name the program makes a difference
Edit:
Never mind, I just tried it and I can't get it any smaller than 21 bytes, either.
Also for the quadratic program, I got 39 bytes.
[SPOILER Highlight]
: Prompt A,B,C
: ({-1,1}√(B2-4AC)-B )/(2A
[END SPOILER]
Last edited by Guest on 14 Dec 2006 11:16:19 pm; edited 1 time in total |
|
Back to top |
|
|
todlangweilig
Advanced Member
Joined: 14 Feb 2006 Posts: 470
|
Posted: 14 Dec 2006 11:04:28 pm Post subject: |
|
|
ditto, I keep getting 21. |
|
Back to top |
|
|
thornahawk μολών λαβέ
Active Member
Joined: 27 Mar 2005 Posts: 569
|
Posted: 15 Dec 2006 05:19:12 am Post subject: |
|
|
Here:
[SPOILER (HIGHLIGHT)]
:Prompt A,B
:R►Pr(A,B
[/SPOILER]
*sigh* Do I get the cookie?
thornahawk |
|
Back to top |
|
|
todlangweilig
Advanced Member
Joined: 14 Feb 2006 Posts: 470
|
Posted: 15 Dec 2006 05:41:50 am Post subject: |
|
|
thornahawk's is 19 bytes
Impressive. |
|
Back to top |
|
|
Recursive Acronym
Advanced Member
Joined: 11 Dec 2006 Posts: 499
|
Posted: 15 Dec 2006 07:24:03 am Post subject: |
|
|
Yeah, my solution was:
Prompt A, B
abs(A+Bi
I thought that that was really clever over using sqrt(A^2+B^2), resulting in a 21 byte prog, but like 5 minutes after submitting the post I realized that the calculator had a built in function for converting rectangular coordinates to the polar radius, and it was one byte smaller. Stupid me... This is kind of like the time when I made a BASIC program to convert a number in a string to a variable. Only later did I find out about the expr( function, by reading my manual . Good job thornahawk.
Last edited by Guest on 15 Dec 2006 07:27:04 am; edited 1 time in total |
|
Back to top |
|
|
Harrierfalcon The Raptor of Calcs
Super Elite (Last Title)
Joined: 25 Oct 2006 Posts: 2535
|
Posted: 15 Dec 2006 07:31:54 am Post subject: |
|
|
Recursive Acronym wrote: Yeah, my solution was:
Prompt A, B
abs(A+Bi
I thought that that was really clever over using sqrt(A^2+B^2), resulting in a 21 byte prog, but like 5 minutes after submitting the post I realized that the calculator had a built in function for converting rectangular coordinates to the polar radius, and it was one byte smaller. Stupid me... This is kind of like the time when I made a BASIC program to convert a number in a string to a variable. Only later did I find out about the expr( function, by reading my manual . Good job thornahawk.
[post="92775"]<{POST_SNAPBACK}>[/post]
*golf clap*
Lol. I still don't even know how this works....is it trig? Cause I'm only a freshie in honors geometry . I can calculate the angle theta given 2 out of 3 sides length . Learned how in some crazy engineering class. |
|
Back to top |
|
|
luby I want to go back to Philmont!!
Calc Guru
Joined: 23 Apr 2006 Posts: 1477
|
Posted: 15 Dec 2006 08:52:00 am Post subject: |
|
|
i is sqrt(-1) so if you do 3+4i it really is sqrt(-3^2+-4^2) The abs gets you the positive which is 5 |
|
Back to top |
|
|
simplethinker snjwffl
Active Member
Joined: 25 Jul 2006 Posts: 700
|
Posted: 15 Dec 2006 04:04:05 pm Post subject: |
|
|
For the hypotenuse one I got 19, same as Recursive Acronyms
On the quadratic I got 38 bytes:
:Prompt A,B,C
:-2/^-1/A/^-1/(B-sqrt(B/^2/-4AC){1,-1 |
|
Back to top |
|
|
c_plus_plus My Face Hertz
Active Member
Joined: 30 Jan 2006 Posts: 575
|
Posted: 15 Dec 2006 04:40:24 pm Post subject: |
|
|
simplethinker wrote: For the hypotenuse one I got 19, same as Recursive Acronyms
On the quadratic I got 38 bytes:
:Prompt A,B,C
:-2/^-1/A/^-1/(B-sqrt(B/^2/-4AC){1,-1
[post="92788"]<{POST_SNAPBACK}>[/post]
Whoo Hooo! I was going to post that exact thing,but it only saves 1 byte, so I decided not to. |
|
Back to top |
|
|
|