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.


Topics - JWinslow23

Pages: [1] 2 3 4
1
TI Z80 / This is the Only Level
« on: March 21, 2016, 10:39:09 pm »
Elephants sometimes do forget...the rest of the levels.


2
TI Z80 / Spot: The Video Game! TI-84+ development thread
« on: September 07, 2015, 03:45:44 am »
That's right, I'm making another calc game. It will be a port of none other than:


(title screen above just a mockup at this point, is not in this version of the game)

As of now, this is an extremely early pre-pre-alpha v0.0.0.0.1.0 version of the game, so do not expect anything more out of it than what it gives as of now.

For those who don't know what that is, it is an NES game featuring the mascot of 7-Up, Cool Spot, which takes on a style similar to that of Othello (Reversi for some people). You can duplicate spots on the board by placing them 1 square away, or move spots on the board by placing them 2 squares away. If there are spots of the opponent's color directly around the ending square, it flips them to your color. Fun concept, and interesting to play.

What I hope to do is to make the magic of that game (yes, even the animations Spot does during moves) appear on my TI-84+ calculator. Sure, this would be simple to program in TI-BASIC, and I may do that at one point as well, but I don't simply want it for the gameplay. I want to test myself to see if I can recreate the stunning visuals in 3-level grayscale on a 96x64 pixel screen. So far, I think I did a good job with the "spot selected" animation.


(I swear, grayscale looks fine on-calc. I don't know how to Wabbitemu settings :P )

ARROW KEYS - Move your cursor
2ND - Select spot and destination spot
CLEAR - Exit at any time

I have implemented a semi-playable 2 player version (one player takes a turn, then the other, etc). There is no spot flipping yet. Game over and "winning" is also not handled at all, so you must quit out if the board gets full or you cannot move any pieces.

Source code is in ASPOT.8xp. Compiled program is in SPOT.8xp.

With that, it's back to sprite editing and coding. Give me feedback, tell me what you think!

3
Community Contests / Code Golf - The Reboot #9
« on: July 27, 2015, 03:34:37 am »
I can't believe I've gone about a month without posting another challenge. Time to set things right :P

Hello Omnimaga/CodeWalrus/Cemetech/friends/Romans/countrymen/lend/me/your/ears, and welcome to the ninth installment of...
Code Golf: The Reboot

As you can see, I am @JWinslow23 , the guy who started this idea in the first place. You may recall my weird fifth challenge I devised, and if you do, I'm doing something just as sinister.

Don't know what code golf is? Check out this contest thread OR this really old contest thread for an explanation. Don't know what code is? Then you will not understand this website in general :P

Without further ado...

Challenge 9

Problem

Family Feud is a game show where you try to guess the most popular responses to survey questions, such as "Name something people often steal from the office to use at home", "Name something that gets hard when it gets cold", or "Tell me a famous Dennis". This, of course, has been adapted into many video game ports, including one in 1993 on the Super Nintendo Entertainment System (SNES).

Now, the SNES version has one glitch that makes the game that much more funny: as long as there are the right letters in the right order, the game counts it as correct. This can lead to some rather interesting answers being counted, as seen in this video.

Based on this, here is your challenge: Create a program that, given a string containing a typed-in answer, and another string containing all the accepted answers (encoded in a format explained below), tells the user the answer they matched, and if no answer was matched, tells the user they got a strike.

Let me explain:

The string with the possible answers the game will accept will be encoded and interpreted as follows:
  • Answers will be written in uppercase letters.
  • Backslashes "\" separate multiple valid answers for a given entry.
  • Optional parts of answers are enclosed by a pair of underscores "_", i.e. "_RED_ MEAT" means that "RED MEAT" and "MEAT" are both valid.
  • A caret "^" indicates that the following character is optional, i.e. "PICKLE^S" means that "PICKLES" and "PICKLE" are both valid.
  • Spaces are usually optional (except in special cases). For the purposes of the contest, they are always optional.
  • Any double letters are always optional, e.g. "RACCOON" means that "RACCOON" and "RACON" are both valid.
Input for your program will be in the form of "ANSWER YOU TYPED IN:POSSIBLE ANSWER 1:POSSIBLE ANSWER 2:ETC". Output for your program will be in the form of either the lowest answer on the board that it matches, or "STRIKE!" if it matches no answers. To clarify, here are examples:

Code: [Select]
Input: "CLEANER FLUID:CAR\AUTO:CLOTH_ES_:_KITCHEN_ FLOOR:BODY:TOWEL^S:BATHROOM:DISH_ES_"
Output: "CAR\AUTO"

Input: "FABULOUS DIET WATER:CLOTH_ES_\SHOES:FAT\WEIGHT:BILLS:FOOD:TIME"
Output: "FOOD"

Input: "CODE GOLF CONTEST EIGHT:SOCK^S\HOSE\STOCKINGS\NYLONS:PURSE^S\POCKETBOOK\BAG:POLISH:LACES"
Output: "STRIKE!"

If any more clarification is needed, contact me. I'll try not to give you COMMANDS FOR US INVASION... (whoops, I mean CONFUSION :P )

Scoring

All non-calc languages will be scored with this counter.
Assembly programs will be scored on binary size (minus the header), and TI-BASIC and Axe will be scored on on-calc source size (again, minus the header). For Axe, the entire first line (for example, ".PROGNAME") does not count.

Submission

PM me over on Omnimaga, Cemetech, or CodeWalrus with the code, or make an unlisted YouTube video and PM me the link. (If you take the latter option, then congrats for you :P )

Good luck! I wanna see if Feud come up with clever answers!

SysRPL
RankUserSizeDate
13298220.5 (I swear)Jul 29 2015 05:44:37 pm

Java
RankUserSizeDate
13298371Jul 30 2015 04:47:10 pm

C
RankUserSizeDate
13298334Jul 30 2015 04:47:10 pm

Language Ranking
RankLangUserSizeDate
1SysRPL3298220.5 (I swear)Jul 29 2015 05:44:37 pm
2C3298334Jul 30 2015 04:47:10 pm
3Java3298371Jul 30 2015 04:47:10 pm

Here is the code for the SysRPL, C, and Java entries, respectively. I guess the contest died, even I didn't notice it was already over. But hey, it was fun. :)

Code: [Select]
::
  ' :: OVERSWAP BINT1 POSCHR
    DUP#0=csedrp NULL$SWAP
    2DUP #!+LAST$ UNROT
    1_#1+SUB$ ;
  'NOP 2NULLLAM{}_ BIND
  CHR_: 2GETEVAL 1PUTLAM BEGIN
    CHR_: 2GETEVAL DUP BEGIN
      CHR \5C 2GETEVAL
      ONEONE BEGIN
        3PICKOVER
        OVERLEN$ OVER#< case
        :: 3RDROP 6DROP
          SWAPDROP ABND ;
        SUB$1#
        BINT32 OVER#=case
        :: DROP #1+ AGAIN ;
        BINT94 OVER#=case
        :: DROP #2+ AGAIN ;
        BINT95 OVER#=case
        :: DROP3PICK tokuscore_
          ROT#1+ POS$ #1+ AGAIN ;
        1GETLAM $PICK SUB$1#
        #=ITE #1+ SWAP#1+SWAP
      1GETLAM LEN$ 3PICK #< UNTIL
    3DROP DUPNULL$? UNTIL
  2DROP DUPNULL$? UNTIL
  DROP ABND "STRIKE!"
;

Code: [Select]
#include<stdio.h>
main(int c,char**v){char*i,*a,*s=v[1];while(1){while(*s&&*s!=58&&*s!=92)++s;if(!*s)break;if(*s++==58)a=s;i=v[1];while(*i!=58)switch(*s){case 0:case 58:case 92:while(*a&&*a!=58)printf("%c",*a++);return;case 94:++s;case 32:++s;break;case 95:++s;while(*s++!=95);break;default:if(*i==*s)++s;else++i;}}printf("STRIKE!");}

Code: [Select]
class G{public static void main(String[]c){c=c[0].split(":");for(int n=0;++n<c.length;)for(String s:c[n].split("\\\\"))for(int x=0,y=0;x<c[0].length(){if(y>=s.length()){System.out.print(c[n]);return;}switch(s.charAt(y)){case 94:++y;case 32:++y;break;case 95:y=s.indexOf(95,y+1)+1;break;default:if(c[0].charAt(x)==s.charAt(y))++y;else++x;}}System.out.print("STRIKE!");}}

4
TI Z80 / Bejeweled 84+ progress thread
« on: July 16, 2015, 02:43:17 pm »
Introducing, a first look at what I want to make into a full game: Bejeweled 84+!

Click on the image to jump to the latest version!



As of now, it just loads the graphics, creates a random board with no match checking (yet), and displays that board.

If anyone's wondering how I did all that, one word: textsprites.

Download attached. Tell me what you think!

EDIT: Source code for the curious (processed with TokenIDE):
Code: [Select]
ClrDraw
AxesOff
ZStandard
104→Xmax
⁻72→Ymin
ZInteger
For(A,0,74
If A<11
Text(57,A+15,sub("?Y°﹢.﹢°Y?  ",A+1,1
If A<21
Text(52,A+10,sub("?Y'([i]ÎQJ'['JQÎ[i]('Y?  ",A+1,1
If A<25
Text(47,A+8,sub("﹢[s]!!]:XX.χ[i][i][i]χ.XX:]!![s]﹢  ",A+1,1
If A<28
Text(42,A+8,sub("  .Jẋûí[e]|u([s]:[s](|u[e]í[e]íJ.   ??  ",A+1,1
If A<41
Then
Text(37,A,sub("''?    Y'°°Y]|uQYYY? Y'°°°^Y'°°'Y1|uQYYY?  ",A+1,1
Text(32,A,sub(" plotsquare[[2JQ!Jplotsquare[e]plotsquareJ[e]plotsquareplotsquare[e]plotsquareJ plotsquare['??YÎJplotsquare[e]plotsquareplotsquare [e]plotsquareplotsquareûplotsquare2  ",A+1,1
Text(27,A,sub("JJJJJJJ.              ….          plotsquareí﹢  ",A+1,1
End
Text(5,A+11,sub("[[JJ[i]Q' 'QplotsquareJJJJ JJJplotsquareQ' 'QplotsquareJJJJ  YQplotsquare('(plotsquareQY  'QplotsquareJJJJ 'QplotsquareJJJ 'QplotsquareJJJJ [[JJplotsquareQ'  ",A+1,1
Text(0,A+11,sub("[[]]X[( |u[Î]]]?     [[ |u[Î]]]? [[.     .[[ |u[Î]]]? [[     |u[Î]]]? [[??Y[|u  ",A+1,1
End
{11,21,36,56,71,77
For(A,1,6
Line(Ans(A),0,Ans(A)+4,0
End
{31,42,51,62
For(A,1,4
Line(Ans(A),0,Ans(A)+1,0
End
⁻14
Line(2,Ans,36,Ans
Line(⁻Ans,2Ans,24,2Ans
{2,⁻Ans,26
For(A,1,3
Line(Ans(A),⁻22,Ans(A)+10,⁻22
End
26
Line(12,⁻24,12,⁻Ans
Line(Ans,⁻24,Ans,⁻Ans
⁻16
Line(0,Ans,0,⁻20
Line(38,Ans,38,⁻20
Line(⁻Ans,⁻12,19,⁻13
13
Line(22,⁻12,19,⁻Ans
Line(40,⁻Ans,40,⁻61
{1,15,37,15,1,21,37,21,Ans,23,25,23,Ans,27,25,27,15,Ans,23,Ans
For(A,1,10
Pt-On(Ans(2A-1),⁻Ans(2A
End
⁻12
Line(41,Ans,92,Ans
Line(41,Ymin,92,Ymin
Line(42,Ans,42,Ymin
Line(92,Ans,92,Ymin
DelVar [A]{8,8→dim([A]
For(A,1,8
For(B,1,8
randInt(1,7→[A](A,B
StorePic 1
For(C,0,7
Text(7+6A,38+6B+C,sub(sub("[[i][[[(ẋXẋ(+([(+(X]X(°û[Q°J|u[|uJ(X[i][(",5[A](A,B)-4,5)+"   ",C+1,1
End
RecallPic 1
End
End
Pause

5
Community Contests / [ENDED] Code Golf - The Reboot #5
« on: June 29, 2015, 03:47:53 pm »
Everybody back off, I'm taking back this contest :P

Hello, Omnimaga/CodeWalrus/Cemetech/my girlfriend/whoever is seeing this right now, and welcome to the fifth installment of...
Code Golf: The Reboot

As you can see, I'm neither @pimathbrainiac NOR @c4ooo , NOT EVEN @Juju , but I am the original @JWinslow23, the one who came up with this silly idea in the first place almost a year ago. However, don't expect me to host next time, or basically for the next few competitions. How it works is, there's this cycle of hosts that will successively host this competition, starting with pimath. Somewhere in that loop, there's yours-truly, with a challenge on deck to give you. This is that.

Don't know what code golf is? Check out this contest thread OR this really old contest thread for an explanation. Don't know what code is? Then you will not understand this website in general :P

Without further ado...

Challenge 5

Problem

You, a person with a lisp, go to your car, and unlock it with the keys...but there's one problem...you don't have your keys with you.

"Oh no...I lotht my keith! Where'th my car keith?" you exclaim in nervousness. You know that you have more than one pair, but you can't for the life of you find any of them.

Suddenly, you remember...each of your keys had a number on it 10 or above, each of which you call a Keys Number, or "Keith Number". Now, these numbers have a special property:

For a number N with D digits, if you arranged the digits to make a Fibonacci-like sequence where the digits of N are the first few terms, and each number is the sum of the D preceding digits, it would have N somewhere in the sequence.

Examples:

14 is a Keith Number:
Code: [Select]
N = 14
D = 2

1 + 4 = 5
4 + 5 = 9
5 + 9 = 14
197 is a Keith Number:
Code: [Select]
N = 197
D = 3

1 + 9 + 7 = 17
9 + 7 + 17 = 33
7 + 17 + 33 = 57
17 + 33 + 57 = 107
33 + 57 + 107 = 197
1337 is NOT a Keith Number:
Code: [Select]
N = 1337
D = 4
1 + 3 + 3 + 7 = 14
3 + 3 + 7 + 14 = 27
3 + 7 + 14 + 27 = 51
7 + 14 + 27 + 51 = 99
14 + 27 + 51 + 99 = 191
27 + 51 + 99 + 191 = 368
51 + 99 + 191 + 368 = 709
99 + 191 + 368 + 709 = 1367
Your mission: Help yourthelf find your keith!

Make a program that, given an integer input 10 or above, will tell you whether or not it is a Keith number.

Any output is permitted, but the output must be different for a truthy and falsy result, and the two different outputs must be specified to me so I know the difference. Finally, if the size of the program is exactly 1337 bytes...then that'd be kinda cool... :P

Scoring

All non-calc languages will be scored with this counter.
Assembly and compiled Axe programs will be scored on binary size (minus the header), and TI-BASIC will be scored on on-calc source size (again, minus the header).

Submission

PM me over on Omnimaga, Cemetech, or CodeWalrus, or tell my girlfriend and have her dictate the code to me. (If you take the latter option, I will give your code a -90% point bonus. I'm serious.)

Good luck! Remember, don't steal code from others; I want everyone to not fib and not cheat.

TI-BASIC
RankUserSizeDate
1@lirtosiast43Jul 01 2015 02:25:25 pm
2@PT_43Jul 02 2015 01:24:20 pm
3@mr womp womp97Jun 30 2015 09:13:00 pm

Lua
RankUserSizeDate
1@Adriweb152Jun 30 2015 02:06:20 am

Javascript
RankUserSizeDate
1@Adriweb112Jun 30 2015 02:06:20 am

Java
RankUserSizeDate
1@c4ooo190Jul 01 2015 12:32:49 pm

Ruby
RankUserSizeDate
1@Juju150Jun 30 2015 04:57:53 pm

Python
RankUserSizeDate
1@Cumred_Snektron83Jul 01 2015 10:37:07 am

Language Ranking
RankLangUserSizeDate
1TI-BASIC@lirtosiast43Jul 01 2015 02:25:25 pm
2Python@Cumred_Snektron83Jul 01 2015 10:37:07 am
3Javascript@Adriweb112Jun 30 2015 02:06:20 am
4Ruby@Juju150Jun 30 2015 04:57:53 pm
5Lua@Adriweb152Jun 30 2015 02:06:20 am
6Java@c4ooo190Jul 01 2015 12:32:49 pm

As I am having trouble with formatting, everyone's code has been put in a Pastebin paste here.

6
TI Z80 / Bitty Bird! (made for CodeWalrus Mini-Contest #1: 4x3)
« on: May 12, 2015, 10:59:01 am »
Have you ever thought Flappy Bird was too easy? Are you easily able to get a score of at least 5 every time you play? Have you been playing so much that you sold all your possessions for some reason in order to keep playing it?

Well, now there's hope :P

Introducing: Bitty Bird!


Bitty Bird packs all the fun and frustration of Flappy Bird into the barest resemblance of a game you can make it into :P . It's also written entirely in TI-BASIC, so the minimalist aspect really shines there ;) .

Press UP to flap your less-than-a-subpixel-long wings, and get through as many of  the definitely-metallic-and-green pipes as you can before you crash! At the end, it shows you your score as individual letters and digits (i.e. a score of 14 would be S C O R E 1 4 flashing on the screen). You can press CLEAR to quit at any time.

It has two programs, BTTYBIRD and BTTYDRAW. Both are needed, and you run the game by running BTTYBIRD. You can download them right below, as attachments to this post after the contest, otherwise I'm disqualified :P .

Planned features:
  • Cramming the game in 2x2 pixels
  • Coloration of the bird, sky, and pipes
  • Physics so realistic your eyes hurt
  • insert funny joke here
  • Difficulty settings
Please give me feedback! Thanks in advance! :lobstah:

P.S. In case you were wondering, my high score is 22. I wonder if the judge can do better... ;)

7
TI Z80 / How I wish I could calculate pi...
« on: May 04, 2015, 01:27:55 pm »
...in vanilla TI-BASIC. To a precision of more than 15 places.

Well, with the help of Jeremy Gibbons and myself, now there's hope!

EDIT: Now there's MORE hope...click here

This program is as fast as I could make it (though not too fast...this ain't Asm), and I welcome any improvements on size and speed. It uses simulated arbitrary precision arithmetic with lists. I have verified it for 100 digits, and the algorithm itself has been verified for 1,000 digits in Haskell.

Download link coming soon attached.

Code is as follows:

PICALC.8xp
Code: [Select]
{1→ʟQ
{180→ʟR
{60→ʟT
2→I
ClrHome
501→D
"CHANGE THE ABOVE NUMBER TO CALCULATE MORE OR LESS DIGITS
"?→Str1
For(J,1,D
Output(1,1,Str1
Output(8,1,J
"ABOVE FOR TESTING
3(3I+1)(3I+2→U
5ʟT→L1
prgmAADJUST
L1→L3
5ʟR→L1
prgmAADJUST
L1→L2
(27I-12)ʟQ→L1
prgmAADJUST
L1+L2→L1
prgmAADJUST
L3→L2
prgmADIVIDE
θ→Y
Str1+sub("0123456789",Y+1,1→Str1
(5I-2)ʟQ→L1
prgmAADJUST
L1→L2
YʟT→L1
prgmAADJUST
L2-L1+ʟR→L1
prgmAADJUST
10UL1→L1
prgmAADJUST
L1→ʟR
10I(2I-1)ʟQ→L1
prgmAADJUST
L1→ʟQ
UʟT→L1
prgmAADJUST
L1→ʟT
I+1→I
End
AADJUST.8xp
Code: [Select]
DelVar BDelVar C1→A
Repeat B or A>dim(L1
C+L1(A→L1(A
If not(Ans
A=dim(L1)+1-sum(int(1/(1+cumSum(abs(seq(L1(Z),Z,dim(L1),1,-1→B
int(10^(7)⁻¹Ans→C
If 0>L1(A
-10^(7)Ans+L1(A→L1(A
10^(7)fPart(10^(7)⁻¹L1(A→L1(A
A+1→A
If C and Ans>dim(L1
Then
0→L1(A
1+dim(ʟQ→dim(ʟQ
Ans→dim(ʟR
Ans→dim(ʟT
Ans→dim(L2
Ans→dim(L3
End
End
ACOMPARE.8xp
Code: [Select]
DelVar Gdim(L1→A
Repeat G or A<1
(L1(A)>L2(A))-(L1(A)<L2(A→G
A-1→A
End
ADIVIDE.8xp
Code: [Select]
DelVar θprgmACOMPARE
While G≥0
Output(6,1,"
Output(6,1,θ
"ABOVE FOR TESTING
L1-L2→L1
prgmAADJUST
θ+1→θ
prgmACOMPARE
End

8
TI Z80 / Some Canabalt-type thingy in development
« on: April 01, 2015, 07:27:58 pm »
@Digital asked me to make a thread about this...so here you go.



ENTER to jump, CLEAR to exit. The number up there is for testing, it shows how far along in pixels the current building has moved.

Download attached. Tell me what you think!

9
Other / Gamebuino 2048
« on: March 09, 2015, 02:28:00 pm »
Guess I'm making a Gamebuino game now ::)

My first project is 2048 (took me a while to design the graphics; if it were as big as a TI-84+ screen, I'd have had my graphics already XD )

Screenie (shows some gimmicky popup messages):


Use the arrow keys to move the tiles. Use A to save your current game, B to reset your game, and C to quit to the title screen. B+A (holding B and tapping A) gives you an option to delete your save (non-functional for some reason in the screenie, but works fine in real life :thumbsup: )

Todo:

* Add way to win
* Add way to lose
* What else do you think I should do, guys?

.zip attached. Includes .ino file (source), .hex file (compiled game), and .gif of gameplay. Tell me what you think!

10
TI Z80 / Cookie Clicker Axe development thread
« on: December 14, 2014, 08:13:27 pm »
Everyone, good news...I'm making another project! :D

As of now, this is only a demo. This is BY NO MEANS a complete game. This is simply meant to prove to myself something I couldn't program on a calc a year ago is indeed possible to program. I shall continue this in the coming weeks

As of now, you use the arrow keys to move the cursor, and ENTER to click. Only clicking on the cookie does anything for now. Once you click on the cookie, you get another cookie. Cookies per second are implemented, but until buying and selling buildings is complete, are disabled.

Screenie for your viewing pleasure:


Source files and program file attached. Uses an axiom (the .8xv file). Tell me what you think so far!

11
TI Z80 / Sudoku 8X+
« on: November 29, 2014, 09:01:27 pm »
Hey guys, I'm back! :D

I made a new game demo, this time of Sudoku!


Use the arrow keys to move the selection cursor. Press a number key (0-9) to enter a number in a square (0 means erase). In each empty square, pencilmarks have been added to show the possible candidates for the square. If there are no candidates, you made a wrong step in filling a square and have to try again. The program quits if all squares are filled in correctly or you press CLEAR.

There is a sample puzzle coded in, but if you want to change the puzzle, change GDB1 in the source file and recompile. The setup should be obvious for a puzzle, but please let me know if you have any questions.

Source file (ASUDOKU.8xp) and program file (SUDOKU.8xp) attached. Tell me your opinions so far.

12
May luck be with us.

NEXT: Here
PREVIOUS: Here

Challenge 13: A Picture's Worth 140 Characters

Problem

Twitter has just disabled their picture upload system! You accept the change, but still want to tweet pictures to everyone. But how are you going to do that? By image compression, of course!

Your mission, if you choose to accept it, is to write two programs (both counting towards your size): one that takes a .png file as input and outputs a compressed version in a string that is 140 characters or less, and one that takes that string and converts it back to a .png file. The converted image must at least be recognizable. You may use any character set, so long as it can be tweeted. Test images will be uploaded later.

Deadline
October 26, 2014, 1:00 AM EST

If any further clarification is needed, contact me. I will try to make you get the picture. :P

N/A
RankUserSizeDateCode
1N/AN/AN/A

Language Ranking
RankLangUserSizeDateCode
1N/AN/AN/AN/A

13
TI Z80 / Swing Copters 84+
« on: October 08, 2014, 07:26:03 pm »
I am starting a Swing Copters clone in Axe! So far, the game is going along smoothly.

I hope to add a bunch of graphical goodies, and some highscore saving (what is a game without it? :P )

This is the smallest that I consider a playable demo as of late. The download link is attached. ASWNGCPT is the source, and SWNGCPTR is the game.

14
Art / Swing Copters sprites?
« on: October 07, 2014, 08:40:21 am »
As you know Flappy Bird has died down. But the creator hasn't, as evident by Swing Copters' recent release. I want to make a port to the calculator, but don't know how to make the swinging hammer-like things. I'm going to try bitmaps of each swing frame and displaying them. Problem is, I have no idea how the swinging should look. Can anyone make some (at least) 16*16 sprites of the swinging hammers? (If you wanna know what they look like in-game, a simple Google search is enough.)

15
Community Contests / [ENDED] Code Golf Contest #12: Befunge Numbers
« on: October 05, 2014, 02:04:29 pm »
Time to completely redesign everything.

NEXT: Here
PREVIOUS: Here

Challenge 12: Befunge Numbers

Problem

Say someone (I'm looking at you, harold :P ) wanted to make a Befunge program for a Code Golf competition that printed a number. In Befunge, arithmetic works in a form of RPN. For example, 34+ pushes a 3, pushes a 4, then adds (in essence, push 7). But to push numbers greater than 9, calculations must be done on numbers less than or equal to 9. For example, 99*76*+ pushes 123.

Your mission, should you choose to accept it, is to make a program that displays an optimal expression for pushing a number (minimum 0, maximum 999,999) onto the Befunge stack using only the numbers, addition (+), and multiplication (*). I shall give test cases when available, but keep in mind, there is more than one solution for any number above 9.

Deadline
October 12, 2014, 1:00 AM EST

If any further clarification is needed, contact me. I'll try to push you to figure it out. :P

C#
RankUserSizeDateCode
1harold37510/7/2014 7:53:28 AM
Spoiler For Spoiler:
using System;namespace B{class P{static void Main(string[]args){int l=int.Parse(args[0])+1,i=0,j,k,x;string[]n=new string[l];for (;i<10;i++)n=""+i;for(;i<l;i++){x=99;for(j=2;j<i;j++){if(i%j==0){k=n[j].Length+n[i/j].Length+1;if(k<x){x=k;n=n[j]+n[i/j]+"*";}}}for(j=1;j<i;j++){k=n[j].Length+n[i-j].Length+1;if(k<x){x=k;n=n[j]+n[i-j]+"+";}}}Console.WriteLine(n[l-1]);}}}

C++
RankUserSizeDateCode
1harold36110/7/2014 8:21:25 AM
Spoiler For Spoiler:
#include <string>
using namespace std;
#define Z(p,q){k=n[j].length()+n.length()+1;if(k<x){x=k;n=n[j]+n+#q;}}
#define X(f);for(j=f;j<i;j++)
int main(int c,char**v){int l=atoi(v[1])+1,i=0,j,k,x;string *n=new string[1<<20];for(;i<10;i++)n=to_string((_Longlong)i);for(;i<l;i++){x=99;n=""X(2)if(i%j==0)Z(/,*)X(1)Z(-,+);}puts(n[l-1].c_str());}

Golfscript
Rank
User
Size
Date
Code1
harold
140
10/7/2014 7:49:12 AM
Spoiler For Spoiler:
~:l;9,{1+`}%10:x;{x l>}{.[.,,{1+}%]zip.[{~\;.x\%!\1=!*},.{~\;-1*}$]zip{~~;\~;+"*"+}%\[.{~\;-1*}$]zip{~~;\~;+"+"+}%+{,}$[(\;]+1x+:x;}until)\;

SysRPL
Rank
User
Size
Date
Code1
3298
147.5
10/8/2014 11:09:47 AM
Spoiler For Spoiler:
::
  COERCE BINT10 OVER#> case #>$
  NULL$SWAP NDUPN
  BINT10 ONE_DO
    INDEX@ #>$ INDEX@ #1+UNPICK_
  LOOP
  #1+' ::
    JINDEX@ INDEX@ 'REVAL
    'R SWAPROT #0<> case2DROP
    #3+PICK INDEX@ #4+PICK
    &$SWAP >T$ DUPLEN$
    JINDEX@ #1+DUP #4+PICK
    DUPNULL$? 4ROLLROT LEN$ #<
    ORNOT case2DROP #1+UNPICK_
  ;
  OVER BINT10 DO
    INDEX@ ONE_DO
      ZEROOVER EVAL #- CHR_+
      DUP EVAL #/ CHR_*
    LOOP
  LOOP SWAP#1- NDROP
;

Java
Rank
User
Size
Date
Code1
3298
334
10/8/2014 11:09:47 AM
Spoiler For Spoiler:
class G{static String[]a;static void r(String s,int n){if(a[n]==""||s.length()<a[n].length())a[n]=s;}public static void main(String[]c){int n=Integer.parseInt(c[0]),i=n,j=10;a=new String[n+1];for(;i>=0;--i)a=i>9?"":""+i;for(;j<=n;++j)for(i=1;i<j;++i){r(a[j-i]+a+"+",j);if(j%i==0)r(a[j/i]+a+"*",j);}System.out.println(a[n]);}}

C
Rank
User
Size
Date
Code1
3298
433
10/8/2014 11:09:47 AM
Spoiler For Spoiler:
#include<stdio.h>
#include<malloc.h>
int n,j=10,i,*a;p(int n){if(n<10)printf("%i",n);else{p(a[n=4*n-39]);p(a[n+1]);printf("%c",a[n+2]);}}r(int m,int o){int s=(m>9?a[4*m-40]:0)+(i>9?a[4*i-40]:0)+1,k=4*j-40;if(a[k]==0||a[k]>s){a[k]=s;a[k+1]=m;a[k+2]=i;a[k+3]=o;}}main(int c,char**v){n=strtol(v[1],0,0);i=4*n-36;if(n<10)p(n);else{a=calloc(i,sizeof(int));for(;j<=n;++j)for(i=1;i<j;++i){r(j-i,43);if(j%i==0)r(j/i,42);}p(n);}printf("\n");}

Language Ranking
Rank
Lang
User
Size
Date1
Golfscript
harold
140
10/7/2014 7:49:12 AM2
SysRPL
3298
147.5
10/8/2014 11:09:47 AM3
Java
3298
334
10/8/2014 11:09:47 AM4
C++
harold
361
10/7/2014 8:21:25 AM5
C#
harold
375
10/7/2014 7:53:28 AM
C
3298
433
10/8/2014 11:09:47 AM

Pages: [1] 2 3 4