Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - 3298

Pages: 1 [2]
Community Contests / Re: Code Golf Contest #5
« on: August 16, 2014, 11:08:44 am »
I'm on vacation, but who cares, my calculator is with me. This time I wrote my first real-time game in SysRPL ... well, by posting here I pretty much told you what game it is. ;) It measures 276 bytes and has some aspects where I'm not really sure if they are allowed:
1. A snake segment is 2*1 black pixels, the food texture is black pixel on the left, white pixel on the right. The board size is 64*64 snake segments with black lines as borders below and to the right. (Results: graphics are stretched horizontally, and strictly speaking the border texture conflicts with the food and snake textures, but the white pixels beyond the border make it easy to tell where the border really is.)
2. The screen size would support a 65*65 board, but using 65 instead of 64 makes the wrap-around logic more complicated. (BINTS have a bitwise AND operator, but the MOD operator is not present.)
3. In fact, with a few bits of Saturn and ARM assembly I could use 4-bit grayscale graphics, so I could shrink the snake segments to 1*1, resize the board to 80*80 with a line to the right, and make the border, snake and food use different colors. The downside: that means a larger code size.
4. Speed with the VERYSLOW (=300ms) delay command is a tiny bit too slow, and SLOW (=15ms) instead makes it too way fast. Five or six SLOWs are fine, but each takes 2.5 bytes. :/
5. ON (usually does Cancel) makes the game bug out, but reversing the snake direction will kill you instantly, so it can replace ON to quit the game.

Community Contests / Re: Code Golf Contest #4
« on: August 09, 2014, 06:14:29 am »
Well, I could remove the _ in mapM_ if some garbage looking like [(),(),(),()] below the output is okay. But other than that, I ran out of ideas.
In other news, I reduced my Java program size by 4 bytes, so I claim the first place in that category again. :P The XTend entry is also reduced by 7 bytes. And finally there is a new C entry with 154 bytes.

Community Contests / Re: Code Golf Contest #4
« on: August 08, 2014, 04:48:39 am »
Quote from: JWinslow23
Actually, there are 2-byte tokens in TI-BASIC, and lots of them. That is part of the reason why we don't like lowercase letters. :P
Yes, of course, there's more than 256 commands, so 2-byte tokens are necessary. Casio does the same, by the way, On my old calculators there were 2 categories of 2-byte tokens (each beginning with its own prefix byte), later calculators, such as the 9860 series, expanded that. The 9860 series somewhen (I think it was also with OS 2.00) also introduced lowercase letters, and guess what? they use 2-byte tokens, >:( I noticed that when I got a program including these sent to my 9750 from a 9860. All lowercase letters were converted to sequences of two tokens each because they used a prefix which wasn't present in the old calcs.
 The funniest thing is: At least on the old calculators there actually were 1-byte lowercase letters in the usual ASCII range, it was just impossible to type them. But once you got them through a cable or through one of the 9x50 series' at least 3 different bugs allowing you to edit memory directly, you could copy them anywhere you want through a rudimentary 6-slot clipboard called function memory.
There were other instances of such Casio silliness: in addition to the lowercase letters, some special characters were impossible to type, but they could be displayed. This includes the => token on the AFX series, which behaves like a shorter If. Other calculators can type them (including the 9860 series released after the AFX), and they work fine on the AFX, but they are not in the menus. A trick to get it is to send it from a 9x50 series calc through the undocumented and hidden compatibility receive mode (the AFX normally uses a slightly different protocol at slightly higher speed).
More silliness: Casio introduced a second program type for base-n (n=2, 8, 10 or 16) calculations. These use a tiny special command set, disallow use of most normal commands, and round numbers to integers automatically. Though with the same tricks you can get these commands into normal programs, and they seem to behave normally, excluding auto-rounding. (The function memory is disabled in base-n programs, so copying them directly is impossible.)

In the end, I mostly went away from those stupid Casio calcs. HP calcs, especially the 48/49/50 series, are much more capable. The Prime looks nice too (fast programs, color screen), but it apparently has lots of bugs, no RPN programmability, a way too small keyboard (no digit input in alpha mode, one less shift key), Casio-style icon menus and more. I'm staying with the 50G, the Prime isn't worth the money.
Quote from: JWinslow23
Looks like things are getting pretty heated in the Haskell category! 3298 and bb010g are slashing bytes like crazy! Only thing to wonder now is, when will they stop? (And will it be before the competition's over?)
This could be the end, considering that we have the same score now. Maybe we hit the global optimum. ;)

Edit: Just because I can, I made an x86 ASM version. I didn't expect it to become small, and it's much bigger than anything mentioned here. :/ Oh well, it's not a suitable language for Code Golf. I'm not submitting it, so if you want to see the source, ask me.
 I use just the Unix sys_write and sys_exit calls, no trickery with the C standard library. It compiles to 838 bytes, and after treating it with strip, it's at 444. The source is 516 bytes long, but I could get rid of some formatting to get that down to 465, maybe even further.

Community Contests / Re: Code Golf Contest #4
« on: August 07, 2014, 07:55:28 am »
How the heck did you compress the Haskell code like that :crazy: ... nevermind, got 71 bytes now, assuming Unix-style line endings (with DOS-style 2-byte line endings it's 72). Take that!
Edit: Also cut down the SysRPL program size to 63.5. I don't expect to be able to compete with CJam and Golfscript, but at least SysRPL is useful for real problems. ;)
By the way, the compactness of that language comes from the fact that programs are usually stored in compiled form. Judging from the prime tester example in the post from the first round, TI-Basic does something similar, though (it seems commands take 1 byte each, instead of 1 byte per character in their names), so I don't feel bad for telling you the compiled size instead of the much larger source size. I know Casio-Basic does those 1-byte commands as well, but because string manipulation is not present in the Casio-Basic version on my calcs, I cannot submit a Casio-Basic entry. (String manipulation was introduced in OS 2.00 for the 9860 series.)

Community Contests / Re: Code Golf Contest #4
« on: August 04, 2014, 07:39:02 pm »
69.5 bytes in SysRPL. :blah: I'll try Java, XTend and Haskell soon, as usual.

Community Contests / Re: Code Golf Contest #3
« on: August 04, 2014, 05:58:30 am »
Now I want to see the competing entries in Java and Haskell. I especially want to know how I could have saved more space in Java. It's probably the number input - I parsed a command-line parameter using Integer.parseInt.
Quote from: JWinslow23
1329859.5 (don't ask me why; I'm going off of what he said)7/31/2014 5:18:48 PM
:evillaugh: That half-byte comes from the 4-bit processor SysRPL is designed for. Many things there have odd sizes, and when you have an odd number of nibbles, you get ... you guessed it, half bytes.

In case anyone wants to check it, you'll need to set up an emulator and install a development tool on it. The remaining part of the post is a tutorial for that.
A ready-to-use emulator comes with the free Windows-based IDE Debug4x (get it at The emulator is in the subdirectory "Emu" of the installation directory. Start it, and it will ask for a KML script. This defines the look of the emulator, the key positions, and a few other things. The pre-installed KML script "Eric's Real 50G" should do the trick. I don't know whether the emulator only shows the screen afterwards (haven't used it in a while), but if it does, search the menus at the top for the option to show the entire calculator. The first step with the calculator should be to switch it to RPN mode (answer the "Try to recover memory?" question with No (the F6 key), confirm the "Memory cleared" message with ENTER, press the MODE key, then the +/- key, and finally the ENTER key).
Next step: SysRPL development stuff. The compiler is already installed, you just have to unlock it. But you need something providing the names of commands, otherwise you can only use UserRPL commands or nameless pointers. A library providing the names is called "extable". I'm using the one from (there is a file called "extable2.lib" in that archive, that's the right one). Drag the file into the emulator's screen, and something should appear behind the "1:". You just put the library on the stack. Now push the 0 and press ENTER. The library shifts up to level 2 of the stack, and the 0 appears on level 1. Now press the STO key. The stack should be empty now. Press and hold (this is done by right-clicking on the button instead of left-clicking) the ON key, and push C. This reboots the calculator and finishes the library installation. Now, unlock the compiler. Enter this without the quotes: "256 ATTACH". Don't forget to press the ENTER key at the end to execute the command. (Edit: I forgot to mention that you need to know how to enter the space here. In the bottom row you find a key labeled SPC, that's the space key.)
Now everything is set up. For ease of use, start the text editor this way: Put an empty string on the stack (the double quotes you need for that are present as a shifted function of the multiplication key), then press the down arrow. Enter the source code I gave you (Alpha-lock can be done with two presses on the Alpha key, a third press disables Alpha mode again). If you are missing a few special characters, use the char browser (CHARS is a shifted function of a key in the fourth row; be sure to disable alpha-lock before). Due to some weird requirement from the compiler, the last two chars must be a newline and an @ char, so add these. ENTER exits the editor and replaces the empty string on the stack with the contents of the editor. If you need to edit it again, the down arrow key puts you back in the editor.
Now we compile the source. Simply issue the ASM command with the source on stack level 1. If there are no errors, the source will be replaced by the compiled code (which looks like "FlashPtr External External ..." - that's perfectly normal). With the compiled code on level 1, you can check its size with the BYTES command (takes any object on level 1, gives a checksum on level 2 and the size in bytes on level 1). Or you can give it a parameter (enter the number on the stack, followed by the SWAP command to put it above the program) and run the program with the EVAL key. If you want to do both, these commands are helpful: DUP pushes a duplicate of level 1 (use this to avoid having to enter the source twice), DROP drops level 1, and CLEAR drops everything.
Be extra careful when running the program, no parameters or parameters of the wrong type will crash the calculator because I omitted the necessary checks for that. The input number must be an infinite-precision integer in this case, which is printed and entered as simply a number. Real numbers have a period somewhere, and they are not accepted.

Community Contests / Re: Code Golf Contest #3
« on: July 30, 2014, 06:37:55 pm »
Any entries below 60 bytes yet? I just submitted a 59.5-byte solution in SysRPL. (SysRPL runs on the HP calculators featuring a Saturn processor, which is a 4-bit one. That explains why half bytes are possible as a size there.)
My code calls some OS code to get a sorted list of prime factors (6 bytes, because that call is a flashpointer), and then takes the last element of that list (2 commands for 2.5 bytes each). Thus the assumptions are the same as the OS code's, which should be any integer >=1. (I don't know if 0 is fine as well, but I don't feel like risking a calculator crash to find out.)

Community Contests / Re: Code Golf Contest #2
« on: July 28, 2014, 03:21:23 pm »
Okay, challenge accepted, I'm going to cut that one down.
Code: [Select]
String[] aDrop the space, 1 byte saved.
Code: [Select]
for(String t:a){...}Drop the curly braces, 2 more bytes down (I just saw that in my submission as well). Your other solution already has that.
Code: [Select]
s+=i;System.out.println(s);Two things here: Drop the ln (like in your submission), 2 bytes saved. The concatenation of string and number can be done inside the parentheses of the print, saving 3 more bytes.
Total improvement: 8 bytes, so the size is 161 now. :thumbsup:

Community Contests / Re: Code Golf Contest #2
« on: July 28, 2014, 02:51:23 pm »
Looking over the solutions, I noticed that the shortest Java version does not process one string, but instead assumes someone has split it already and put the parts into the command-line parameters array before the program starts. On the other hand, it shows how my solution could be shortened further (println ->print, and I could have omitted curly braces around the body of the for loop).
Edit: And that version apparently has a bug, it prints the entire array when it failed to parse one element to an integer. There are three characters missing (a+' ' should be a+' '). Due to the size being 171 instead of 174, they apparently got lost somewhere between size measurement and code posting.

I assume there are some languages with an advantage for the new challenge above. If you have a CAS-equipped calculator, the factorization is as simple as a function call, on most other languages you'll have to implement it yourself. Though such a discrimination is hard to avoid.
Luckily the 50G has a CAS, so I already have a 57-byte SysRPL solution. ;D The other languages I used will be a bit harder.

Community Contests / Re: Code Golf Contest #2
« on: July 27, 2014, 01:19:53 pm »
Thanks for the welcome messages! I have written a few posts on the UCF and the recently closed DCF in the last few years, and I saw some of DJ's old posts on the UCF. And before the CasioScene drama happened I was a registered user at CasioKingdom. The restore to an old backup over there removed all evidence of that, but I won't go back there because it's become a toyland for spambots.
The permissions seem a bit screwed up, because I tried the test message you suggested, and it actually worked. I understand why this limit is in place (look at CasioKingdom to see what happens without such protection), and I think someone should enforce what that post in the news section says. I can only assume this no-PM rule has been softened, because I had to solve a captcha like at my registration. (Not a problem for a human, though.)
So with the PM way apparently working, I'll use it.

Community Contests / Re: Code Golf Contest #2
« on: July 27, 2014, 09:40:43 am »
Hello there, I have been reading some sections of Omnimaga for several months now (mostly the Casio and HP sections), and I finally decided to register so I can participate in this contest. After registering I found out that I need 5 posts to be able to send PMs, and I'm not the type of user who then posts in 5 random topics, so ... shall I just put my programs in spoilers, or what should I do?
(Edited to add: That's at least what some thread in the news section said. Now I see a PM icon below your user text which wasn't there before, but trying to use that will probably fail.)
I have written solutions in Java (190 bytes including a single-letter class name), XTend (a language implemented on top of Java; 160 bytes, with the same single-letter class name), Haskell (156 bytes, again including a single-letter function name) and SysRPL (79 bytes without name in compiled form, but due to the on-calc decompiler that's a feasible format for storage, you only lose pretty formatting and comments).
Even though not required, I tried throwing strings with non-alphanumeric characters and duplicate / leading / trailing spaces at my programs to see what happens. Java and XTend handle other characters just fine, the spaces are retained (can be fixed with 17 more bytes for Java and 9 for XTend). Haskell removes those spaces, but it might treat newlines and tabs as spaces. SysRPL keeps the spaces, but with 5 more bytes that's fixed. It also treats at least newlines as spaces, maybe tabs as well.

Pages: 1 [2]