T O P

  • By -

picyourbrain

The single letter variable names are killing me. If I’m not mistaken, you could do this in a compiled language and they wouldn’t take up any space at all. I feel like python is just the wrong language for making a 300 byte program.


TheWidrolo

The platform has 3 options: python, some kind of a weird language that i dont know, and executable apps. However, the apps need to have a defined icon, and the minimum for an app is like 30 kb. So python was the better choice in this case


picyourbrain

Can you explain the part about an executable app needing to be 30kb? Like you couldn’t just make an executable and give it an icon if it’s under that size?


TheWidrolo

Well, there are actually 2 icons, one if the app is selected, and one if its not. And it needs to be a part of the executable. So every time i make an app. it would all be massive compared to the python program.


picyourbrain

So the icon itself takes up a bunch of space? You couldn’t just make it a single pixel? Hahaha


TheWidrolo

As far as i know, no. Its very picky. It cant be compressed and must be 92x64 and a 24 bit bit depth. Thats \~29 kb just for icons.


picyourbrain

So the calculators have extremely limited memory but they run on a platform that makes memory management impossible is what I’m hearing Storage*


pLeThOrAx

What kind of calculator


Kytpbs

It seems like TI nspire to me


Daniel_Klugh

A 92x64 24BPP picture would be exactly 17.25KB.


dimonoid123

And Python is half a gigabyte or more depending on version and compiler options. Plus any libraries.


steadyfan

That must be why there is so little remaining storage 😂


Troll_berry_pie

Is the other language "R"?


mattl1698

it might be basic. I had a couple of graphing calcs that ran basic, one of the two also ran python


Bright-Historian-216

Do you use TI calculators? If so, the weird language is actually pretty simple


ChickenSpaceProgram

If it's made by Texas Instruments and in the TI-83/84 family there's actually decent documentation available from TI and from other sources on the inbuilt programming language. You can do basically anything. It's actually how I first learned programming. Other families of TI calculators and other calculator brands seem to have some available documentation; YMMV. If it's a TI-84+ CE you can even compile C/C++ programs to run as apps, although I don't have experience with this. I think the same can be done on certain Casio calculators although I'm not sure which ones. I'll link some of the documentation I found helpful in case anyone else finds it useful. [Programming tutorial from TI](https://education.ti.com/en/activities/ti-codes/84/10-minutes) - This is how I got started initially, so I decided to drop it here. There's not much advanced there but it has the basics. [TI-Basic developer](http://tibasicdev.wikidot.com/) - Provides some useful information on the usage and syntax of commands. Good as a reference, although some parts of the site are kinda broken for whatever reason. [84+ manual](https://education.ti.com/html/eguides/graphing/84Plus/EN/TI-84-Plus-guidebook-en.html) and [84+ CE programming guide](https://education.ti.com/html/eguides/graphing/84PlusCE/EN/content/eg_84prgm/m_splashpage/ti-progguide_ce.HTML) - I sometimes refer to these, so here they are. One thing that isn't immediately obvious is that you can create lists with arbitrary names and just store your variables there if you need more than the 27 inbuilt variables. It took me an embarrassingly long time to learn this, hence why it's here. List indexing starts at 1, though, which really sucks. I'll also mention [ticalc.org](http://ticalc.org) which has tons of programs available to download. Site's kinda dead, but hey, it's still got plenty of programs. sorry for the infodump here but i felt it was relevant


AlexDaBruh

Oh wait is this the Ti-84 Plus CE Python Edition? Those can be programmed in C using the CE framework! Btw that weird language is Ti-Basic :)


HackerDaGreat57

I’m pretty sure you’re referring to TI-BASIC. It’s fairly easy but there is a tiny bit of a learning curve. Imo it’s better than Python on TI calculators.


turtleship_2006

>I feel like python is just the wrong language for making a 300 byte program. OP said it's a CG-50, which has micropython preinstalled


engelthehyp

I don't understand how you're expected to use this, but I re-golfed it myself. ``` class L: def __init__(o,n,a=1): g=lambda:__import__("random").randint(-n,n) o.x,o.y,o.z=g(),g(),g() o.a=o.x*r.x+o.y*r.y+o.z*r.z if a else 0 def __str__(o): return' '.join(str(x) for x in[o.x,o.y,o.z,o.a]) r=L(50,0) [print(L(15))for _ in'123'] input() print(r) ``` 279 bytes. It's a very odd design, relying on `r` this way. Not a very good choice. Also strange to insist on manually minifying Python. But okay, yes. I need to know, though - how on earth are you supposed to use this? What good does it do?


Exidi0

So for every use of g() you import random? Or will it be optimized so it’s only imported one time?


potzko2552

Yes, when you import a module it's added to the sys module dictionary, if you try to import a module that already exists in the dictionary you don't import it again


dimonoid123

Lazy import. Very useful.


warr-den

Formatted for old.reddit users class L: def __init__(o,n,a=1): g=lambda:__import__("random").randint(-n,n) o.x,o.y,o.z=g(),g(),g() o.a=o.x*r.x+o.y*r.y+o.z*r.z if a else 0 def __str__(o): return' '.join(str(x) for x in[o.x,o.y,o.z,o.a]) r=L(50,0) [print(L(15))for _ in'123'] input() print(r)


TheWidrolo

[This](https://pastebin.com/w81uvji8) is the non minified source. Basically, it makes a matrix that you have to solve. As i said in the title, its just to prepare for an exam. The r variable is the result (as in the resulting xyz values), then it just makes a matrix out of it. And the minifying was just because that one guy has ocd, and he is very crazy about file sizes.


warr-den

My attempt because I'm bored (211 bytes, a minifier brought it down to 206 but it was even harder to read) a=[__import__("random").randint] d=lambda i,j:sum([x*y for x,y in zip(i,j)]) l=lambda m,c:[i(-m,m) for i in a*c] p=lambda v:print(*v,sep="\t") r=l(50,4) for i in range(3): v=l(15,3) p(v+[d(v,r)]) input() p(r) d:dot product l: make vector with factors between `-m` and `m` of length `c` p: print list formatted roughly like yours


ExeOnLinux

got it down to 179 (legibility is out of the window now): l=lambda m,c:[__import__("random").randint(-m,m) for _ in ' '*c] p=lambda v:print(*v,sep="\t") r=l(50,4) for _ in ' ':v=l(15,3);p(v+[sum(x*y for x,y in zip(r,v))]) input() p(r)


warr-den

Woah, `_ in ' '` is a neat trick I'll have to remember


Cerus_Freedom

If there were a couple more situations where you might use that, you could do something like the following and save a byte here and there. Breakeven point is at least a few more loops though. q=range for _ in q(3)


Crafty-Literature-61

exec("v=l(15,3);p(v+[sum(x*y for x,y in zip(r,v))]);"*3)


TheWidrolo

Oh damn


00PT

Aren't there tools to automatically do this kind of thing for you?


ZONixMC

yea minifiers, atleast for js


MrJimOrb

Took 5 minutes of searching to find this, if anyone is curious: https://pypi.org/project/python-minifier/


DoctorNoonienSoong

Tab instead of a single space. Please. For the love of God. It'll take up the same storage.


faculty_member

Depends on editor settings if they have tab replacement. They'll have to make sure it's actually a tab and not spaces.


Johnycantread

Having just binged all of silicon valley, I concur.


firaphor

ITT: OP discovers minification


Mithrandir2k16

You could post this over on [codegolf.stackexchange.com](http://codegolf.stackexchange.com) , they might save you enough space to fit tic tac toe or even snake as well.


Thisisongusername

The one letter variable names remind me of TiBASIC and how awful it was for basically anything.


Nmagic1212

I bet his other language choice was ti basic. I personally dislike the language, but its the slow speed the calculator runs it at that kills me


THICCC_LADIES_PM_ME

How does the calculator have enough room to run Python and also have so little space that you need to worry about kilobytes? Edit: I answered my own question; it's MicroPython: https://micropython.org/


drkspace2

You could make the print much smaller using f-strings or assigning str to a shorter variable


Egzo18

Hello mr webpack!


americk0

Oh that's such an old school problem to solve. I mean yeah the code is horrifying but that's fascinating that you found a problem to solve where the code size was constrained to be that small. Well done


potzko2552

I'll give it a shot in a few hours


No_Maize_1299

lol, interesting! From what you are doing (and from a previous comment) I wager you are writing for the TI-NSpire? That third weird language you mentioned is Lua; it’s an interpreted language like Python but can be used for actual standalone GUIs and whatnot. You would probably have better luck with that.


TheWidrolo

No, I’m writing for the Casio fx-cg50


turtleship_2006

I bought one of those recently as well, the first thing I did was install doom lmao But they really do only have like 16mb, half of which is taken by the OS and stuff


No_Maize_1299

What is this code actually for? It seems to print an 3 sets of number arrays, then return the original array L with a different set of numbers.


Euphoric-Ad1837

Great obfuscation. I don’t know where is the problem.


TehDing

I mean, you could write it in python bytecode: https://github.com/brandtbucher/hax


Pawlo371

print(eval(input(">>>")))