Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic Brain Teasers => TI-BASIC
Author Message
Flofloflo


Member


Joined: 07 Nov 2007
Posts: 120

Posted: 03 Jan 2008 02:10:38 pm    Post subject:

Okay, I am gonna try to make a Text to Binary program, I wonder how small I can make it.Laughing
Let's just make it converting 1 letter to 1 binary code. Making it translate entire texts can;t be too difficult afterwards!

26 letters.

Z becomes 11010


Last edited by Guest on 04 Jan 2008 12:29:26 pm; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 03 Jan 2008 04:30:23 pm    Post subject:

26 letters are all we're focusing on? Saying "yes" would keep it less complicated for the sake of comparing answers afterward. Smile

Last edited by Guest on 03 Jan 2008 04:51:09 pm; edited 1 time in total
Back to top
Harrierfalcon
The Raptor of Calcs


Super Elite (Last Title)


Joined: 25 Oct 2006
Posts: 2535

Posted: 03 Jan 2008 04:41:37 pm    Post subject:

It'd probably help to specify what form of binary the answer should be in. An actual numeric value, a list, or a string?
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 03 Jan 2008 04:52:05 pm    Post subject:

By method of straightforward conversion, I have a program that weighs 62 bytes after subtracting the length of the title. I'm now starting on a different approach that should do the same thing, but would output as a string instead of a list.

[EDIT]

Done, 89 bytes.


Last edited by Guest on 03 Jan 2008 05:22:26 pm; edited 1 time in total
Back to top
Taricorp


Member


Joined: 09 Mar 2006
Posts: 188

Posted: 03 Jan 2008 07:10:26 pm    Post subject:

Well.. I don't have a TI-BASIC solutions to this, but here's a nice little assembly solution that saves to a string (yeah, I'm a little offtopic):

Code:
;takes c as input for letter to convert, hl as pointer to string location
  ld b,8
loop:
  rl c
  xor a
  adc a,a
  add a,'0'
  ld (hl),a
  djnz loop

11 bytes! It only adds 4-5-ish bytes to read from a null-terminated string at de.
Back to top
luby
I want to go back to Philmont!!


Calc Guru


Joined: 23 Apr 2006
Posts: 1477

Posted: 03 Jan 2008 08:59:55 pm    Post subject:

Hey Goose, what are you using for translations? Like does A = 00000001?
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 04 Jan 2008 03:32:49 am    Post subject:

A = 01000001
B = 01000010
C = 01000011

Z = 01011010

[EDIT]

Got the string version down to 85 bytes. Will press further...


Last edited by Guest on 04 Jan 2008 08:15:30 am; edited 1 time in total
Back to top
Flofloflo


Member


Joined: 07 Nov 2007
Posts: 120

Posted: 04 Jan 2008 12:30:43 pm    Post subject:

I am so looking forward to the solution..... My program would involve tons of loops and calculations and stuff......!!!

Hmm, there is of course a great logic in the binary language, but I realy can't find out how to do this in one or two or three calculations...:P

Oh, 0x5, I never knew Bytes where such small Creatures; First try is something over 150 bytes, I dunno how to substract the title....
But now I can start shaving off useless bytes :0x5:

133, including title! Now let's see how much I can remove still...

Can't go any further, and I can't find a place to use ans:( 130 bytes.


Last edited by Guest on 04 Jan 2008 04:56:49 pm; edited 1 time in total
Back to top
spandiv
-- Retired --


Active Member


Joined: 25 May 2003
Posts: 650

Posted: 04 Jan 2008 08:53:51 pm    Post subject:

Are we allowed to use routines that other people posted elsewhere on the forum? The reason I ask is because I looked in the thread I started for routines, and somebody (Goose) has already created a routine for converting to binary. It only needs a simple modification to work for this brainteaser. Who knows, maybe Goose is already using it for his answer? Very Happy
Back to top
Flofloflo


Member


Joined: 07 Nov 2007
Posts: 120

Posted: 05 Jan 2008 06:54:05 am    Post subject:

All I care about it that you get the smallest solution you can:)

I'll post mine, I have never used spoilers before though, so let's see if it works.
Quote:

Input Str 1
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"->Str 2
For (A,1,26
If Str = sub(Str2,A,1
A->G
end
0->A
For(C,0,4
4-C->R
G>=2^R->L
G-L2^R->G
A+L10^R->A
End

I dunno if I am supposed have the input and the definition of variables in the program, right now they are included and the program minus the name is 107 bytes.

Moved into a [­quote] to make the text more invisible. –Goose


Last edited by Guest on 05 Jan 2008 07:12:21 pm; edited 1 time in total
Back to top
spandiv
-- Retired --


Active Member


Joined: 25 May 2003
Posts: 650

Posted: 05 Jan 2008 11:46:05 am    Post subject:

Thanks, I just wanted to make sure. Here's the routine in question:

:inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ",Ans
:2fPart(.5int(2fPart(Ansseq(2^-I,I,1,1+int(log(Ans)/log(2


Note that the routine returns the binary number backwards to save space.


Last edited by Guest on 30 Aug 2010 08:39:37 pm; edited 1 time in total
Back to top
Flofloflo


Member


Joined: 07 Nov 2007
Posts: 120

Posted: 05 Jan 2008 12:31:28 pm    Post subject:

Could you also explain it? Surprised
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 05 Jan 2008 01:00:11 pm    Post subject:

Here's my attempts (61+name for the list, 80+name for the string):
Quote:
:64+inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ",Ans
:int(2fPart(Ans2^seq(I,I,-7,-1

Quote:
:inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ",Ans→A
:"10
:For(B,-5,-1
:Ans+sub(Ans,2-int(2fPart(A2^B)),1
:End
:Ans
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 05 Jan 2008 07:34:24 pm    Post subject:

Well, after a bad storm, I have the Internet again, finally.

As a list (62 bytes):
Quote:
64+inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ",Ans
int(2fPart(Ans.5^(9-cumSum(binomcdf(7,0
I didn't backtrack enough on that one, apparently.

As a string (85 bytes):
Quote:
"010"+sub("000010100100010110011010110000", …
inString("ABEJTIRDHQCGOWNYSFMZUKVLXP",Ans),5
That's a De Bruijn cycle of order 5, prefixed with the common first three bytes.

At about the time I experienced a power outage yesterday (I was away from my computer at the time), I had a computer program targeted towards finding the seed that would make this sequence emerge with int(2rand(30. I don't know how far it went or if it returned any results at all.


Last edited by Guest on 30 Aug 2010 08:40:02 pm; edited 1 time in total
Back to top
pugboy


Active Member


Joined: 11 Apr 2007
Posts: 544

Posted: 05 Jan 2008 10:00:33 pm    Post subject:

DarkerLine, your string routine seems to output 7 characters, not 8... Do you know if it outputs 8, and I am doing something wrong?
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 05 Jan 2008 10:13:41 pm    Post subject:

DarkerLine's program disregards the first zero bit, which is technically still correct (especially for 7-bit characters).

Last edited by Guest on 05 Jan 2008 10:15:14 pm; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 06 Jan 2008 12:23:32 am    Post subject:

Weregoose wrote:
At about the time I experienced a power outage yesterday (I was away from my computer at the time), I had a computer program targeted towards finding the seed that would make this sequence emerge with int(2rand(30. I don't know how far it went or if it returned any results at all.
[post="118244"]<{POST_SNAPBACK}>[/post]
The (only) seed that will work is 654242254, but I'm curious to see what you're doing with that.

Last edited by Guest on 30 Aug 2010 08:40:35 pm; edited 1 time in total
Back to top
Flofloflo


Member


Joined: 07 Nov 2007
Posts: 120

Posted: 12 Jan 2008 04:12:10 pm    Post subject:

Hey, I just tried it out but Instring gives me a Error: Data....
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 12 Jan 2008 04:14:51 pm    Post subject:

Well you do have to pass it the letter you want to encode. As a string in Ans is the preferred method (e.g. "A":prgmBINARY)

Last edited by Guest on 30 Aug 2010 08:39:20 pm; edited 1 time in total
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 

Advertisement