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.

TI-Basic => TI-BASIC
 » Goto page 1, 2  Next
Author Message
nitacku

Joined: 23 Aug 2005
Posts: 408

 Posted: 25 Jan 2009 10:24:03 pm    Post subject: I while ago I had read a post where someone came up with the idea of having an obfuscated code topic. So... I figured I'd bring it to life :) Here's my obfuscated code example. Actually, now that I look at it, it's more of a compression/decompression technique... Code: ```0→Xmin:0→Ymin:1→∆X:1→∆Y Full:FnOff:AxexOff:GridOff:ClrDraw {4.3,3,6,6,5.4,6,5.4,7,6,5.3  (look closely, some of these are decimals) E4+1111int(Ans)-10fPart(Ans→L1 L1(6)-505→L1(6 For(Y,0,1 For(X,0,4 For(θ,1,5 int(10fPart(L1(X+5Y+1)/10^(6-θ {fPart(Ans/2),Ans<3,Ans<5,Ans<3,Ans≠2 and Ans≠4 and Ans≠7 For(Z,1,5 If Ans(Z Pt-On(18X+3θ,48-18Y-3Z,2 End End End End``` where E4 is the exponent E, L1 is the list, and 10^( is the single token For a site-based theme, replace this:Code: ```{4.3,3,6,6,5.4,6,5.4,7,6,5.3 E4+1111int(Ans)-10fPart(Ans→L1 L1(6)-505→L1(6``` with this: Code: `{0,16661,17771,55155,77177,13333,15552,77177,55155,0→L1`Last edited by Guest on 26 Jan 2009 12:32:34 am; edited 1 time in total
Galandros

Active Member

Joined: 29 Aug 2008
Posts: 565

 Posted: 28 Jan 2009 09:43:48 am    Post subject: wtf, I think ASM obfuscated code is more simple than that.
Trogdorgar

Newbie

Joined: 26 Jan 2009
Posts: 8

 Posted: 28 Jan 2009 05:50:48 pm    Post subject: Yeah man lol, right now, with the change you displayed, it's pretty much fully optimized as it is, as far as i know
bananaman
Indestructible

Calc Guru

Joined: 12 Sep 2005
Posts: 1124

 Posted: 28 Jan 2009 06:33:37 pm    Post subject: I typed that into my calculator and was pleasantly surprised. I never would have guessed what it would have done. We should make people learn how to do this for their very first basic program.
ticalcnoah

Member

Joined: 28 Oct 2007
Posts: 153

 Posted: 28 Jan 2009 10:39:20 pm    Post subject: Impressive how does it work?
nitacku

Joined: 23 Aug 2005
Posts: 408

 Posted: 29 Jan 2009 09:46:20 pm    Post subject: It's actually pretty simple. Breaking the characters down into pixels, one can find some similarities. Each character is comprised of a group of pixel combinations, creating total of 7 different pixel combinations in all. By assigning each character a number based on the pixel combinations that comprise it, encoding a graphical representation of a phrase becomes as easy as storing numbers to an array. Here is a graphical representation of what each digit translates to: In the original code, the list becomes: {14441, 13333, 16666, 16666, 15551, 16161, 15551, 17777, 16666, 15552} Using the pixel chart, one can translate the meaning of the numbers. 14441 = H 13333 = E 16666 = L 15551 = O 16161 = W 17777 = R 15552 = D As for how the numbers are turned into graphical data, through boolean logic of course. This list: {fPart(Ans/2),Ans<3,Ans<5,Ans<3,Ans≠2 and Ans≠4 and Ans≠7} is what turns each digit into pixel data. For example, if Ans is 3, the list becomes {1, 0, 1, 0, 1}. If you cycle through this list, displaying a pixel/point when the value equals 1, you can graph each pixel combination. Currently, only 7 pixel combinations are defined, but adding new ones in order to support different characters is easy to do. Just add more conditionals to the boolean list to produce the correct result. There is one drawback though, since each pixel combination is represented by a single digit, the current method only supports 9 pixel combinations. To support up to 99 combinations, 2 digits instead of 1 would have to be used to define each combination. With a few minor tweaks, this can be easily achieved.
Weregoose
Authentic INTJ

Super Elite (Last Title)

Joined: 25 Nov 2004
Posts: 3976

 Posted: 13 May 2009 11:23:15 am    Post subject: "int(NfPart((X[font="verdana"]²+1)/N→Y1 "gcd(N,abs(max([font="times new roman"]∆List(Ans→u Ans→N:{2,2 Repeat u≠1 Y1({Ans(1),Y1(Ans(2:End:u Once you know what this does, see if you can find out what it's called.Last edited by Guest on 01 Jul 2010 10:05:11 am; edited 1 time in total
woodswolf

Joined: 26 Feb 2009
Posts: 53

 Posted: 13 May 2009 01:52:16 pm    Post subject: It would be nice if someone tweaked the code for 3x5 tokens, since those are more natural. I like the code. It was totally unsuspected!
TI-newb

Member

Joined: 24 Dec 2008
Posts: 158

 Posted: 13 May 2009 09:15:31 pm    Post subject: Nitacku, you never cease to amaze me XD
ticalcnoah

Member

Joined: 28 Oct 2007
Posts: 153

 Posted: 13 May 2009 09:26:05 pm    Post subject: Weregoose wrote:"int(NfPart((X[font="verdana"]²+1)/N→Y1 "gcd(N,abs(max([font="times new roman"]∆List(Ans→u Ans→N:{2,2 Repeat u≠1 Y1({Ans(1),Y1(Ans(2:End:u Once you know what this does, see if you can find out what it's called. It appears to find smallest non-zero divisor of any number.Last edited by Guest on 01 Jul 2010 10:06:08 am; edited 1 time in total
woodswolf

Joined: 26 Feb 2009
Posts: 53

 Posted: 14 May 2009 07:01:20 am    Post subject: wooooow, the immense speed of the calculation! Can someone explain? EDIT: it appears to not give the smallest divisor! 8! should have 2 as an answer, but it says 21Last edited by Guest on 14 May 2009 07:02:57 am; edited 1 time in total
Weregoose
Authentic INTJ

Super Elite (Last Title)

Joined: 25 Nov 2004
Posts: 3976

 Posted: 18 Nov 2009 11:09:14 pm    Post subject: sum(L1=median(L1→X max(not(fPart(prod(2L1+1-7(L1=4))/{210,770,2002 Ans+6not(AnsfPart(2variance(L1 If X=3:2+(2=sum(L1=max(L1not(L1=median(L1 If X>3:X sub("S3H4YCL",Ans,1 Last edited by Guest on 01 Jul 2010 10:06:57 am; edited 1 time in total
GloryMXE7
Puzzleman 3000

Active Member

Joined: 02 Nov 2008
Posts: 604

 Posted: 19 Nov 2009 03:11:31 pm    Post subject: -if there are less than three occurrences of the list's median value : ans will equal "s","c", or"l" -if there are more than three occurences : ans will equal "4","y","c", or "l" depending the number of occurences -if there are exactly 3 occurences --and exactly 2 occurrences of the list's maximum value : ans will equal "h" --but if there is not exactly 2 occurrences of the max : ans will equal "3"
Weregoose
Authentic INTJ

Super Elite (Last Title)

Joined: 25 Nov 2004
Posts: 3976

 Posted: 19 Nov 2009 05:48:45 pm    Post subject: That's all about half right. Any guesses as to what this is for?
GloryMXE7
Puzzleman 3000

Active Member

Joined: 02 Nov 2008
Posts: 604

 Posted: 19 Nov 2009 09:08:28 pm    Post subject: nitacku wrote:There is one drawback though, since each pixel combination is represented by a single digit, the current method only supports 9 pixel combinations. To support up to 99 combinations, 2 digits instead of 1 would have to be used to define each combination. With a few minor tweaks, this can be easily achieved. well actually you only need 32 combinations try it with {23331,41111,23332,43332,32123,23232,32123,43333,33343,14141→L2 {27331,17777,27772,14427,88188,18181,76467,13333,76488,67776→L1 int(10fPart(L2(X+5Y+1)/10^(6-θ→A int(10fPart(L1(X+5Y+1)/10^(6-θ {A>2,not(fPart(A/2)),Ans<5,Ans<3 or Ans=6 or Ans=5,Ans≠2 and Ans≠4 and Ans≠6 and Ans ≠8 [attachment=2921:Avatar.gif]Last edited by Guest on 19 Nov 2009 09:52:11 pm; edited 1 time in total
Weregoose
Authentic INTJ

Super Elite (Last Title)

Joined: 25 Nov 2004
Posts: 3976

 Posted: 20 Nov 2009 10:10:05 pm    Post subject: Weregoose wrote:sum(L1=median(L1→X max(not(fPart(prod(2L1+1-7(L1=4))/{210,770,2002 Ans+6not(AnsfPart(2variance(L1 If X=3:2+(2=sum(L1=max(L1not(L1=median(L1 If X>3:X sub("S3H4YCL",Ans,1You feed it a five-element list made up of the integers 1 through 6—which is a standard dice roll in the game of Yahtzee—and it'll tell you whether you have a three- or four-of-a-kind, full house, small or large straight, Yahtzee, or chance.Last edited by Guest on 01 Jul 2010 10:07:56 am; edited 1 time in total
nitacku

Joined: 23 Aug 2005
Posts: 408

 Posted: 04 Dec 2009 05:53:47 am    Post subject: Create two programs (A & B). Call program B like so: Z:prgmB, where Z is a positive integer PROGRAM:A While Ans Ans→X θAns→θ X-1:prgmA PROGRAM:B Ans→X 1→θ X:prgmA:θ All program B does is initialize θ to 1. If you do this manually, then only program A is needed and can be called the same way as program B. While this code may not necessarily be obfuscated, it does demonstrate a method of recursionLast edited by Guest on 01 Jul 2010 10:08:19 am; edited 1 time in total
ztrumpet

Active Member

Joined: 06 May 2009
Posts: 555

 Posted: 04 Dec 2009 05:33:53 pm    Post subject: All I see is a memory leak. Last edited by Guest on 04 Dec 2009 05:34:01 pm; edited 1 time in total
nitacku

Joined: 23 Aug 2005
Posts: 408

 Posted: 11 Dec 2009 12:25:38 am    Post subject: Memory that is used when calling the program from within the program is released. However, memory used for the While loop is not. So there is a memory leak, but this code is simply to demonstrate recursion in ti-basic. As to the function, the code actually calculates the factorial of Ans and returns the result in Ans. I tried to find method for implementing branching recursion (which is useful for calculating the Fibonacci sequence), but I wasn't able to find one since Ans is changed for all branches, not just the immediate branch. Variables are no use either since they suffer the same problem as Ans. A list could be used, but that sort of defeats the purpose of using recursion.Last edited by Guest on 11 Dec 2009 12:27:05 am; edited 1 time in total
Ed H

Member

Joined: 30 Nov 2007
Posts: 138

 Posted: 13 Dec 2009 01:34:37 am    Post subject: Is recursion ever a good idea in TI-BASIC?
 Display posts from previous: All Posts Oldest FirstNewest First
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.

»
 » Goto page 1, 2  Next Page 1 of 2 » All times are UTC - 5 Hours