# Omnimaga

## Calculator Community => Contests => Community Contests => Topic started by: JWinslow23 on July 14, 2014, 01:52:12 pm

Title: [ENDED] Code Golf Contest #1 (thanks for the many submissions!)
Post by: JWinslow23 on July 14, 2014, 01:52:12 pm
This is the first of what I hope to be many contests I will hold here on Omnimaga: Code Golf.

Code golf is a competition where you have to solve a coding challenge in the fewest bytes possible. For example, a TI-BASIC entry for a prime tester could be:
Code: [Select]
`Input N:0:If N and not(fPart(N:2=sum(seq(not(fPart(abs(N)/I)),I,1,abs(N:Ans`(note that this is not the speediest it could be, but speed is not factored in your score, only size)
The score would be 34 bytes (for TI-BASIC programs, score=size - 9 - length of name). The lowest score out of the entries will be the winner.

How this tournament will work:
First off, you need to code an actual program that will solve the given problem (or at least give the right result for all the test cases :P ). All languages are allowed, including calc languages and computer languages. When you have an entry, PM it to me, and I will test it if possible (but just in case I don't have an Nspire or I can't download the latest version of Perl or some such problem, try if you can to give back the results of any and all given test cases). I will then save your entry and update the scores accordingly.
After one week, a winner shall be determined in each language category, as well as the smallest overall. In each language category, the winners shall all suggest possible problems for the next competition. I shall pick the next challenge out of these, and present test cases for any possible input or output. Also, you will get to see everyone else's solutions for the previous challenge.

NEXT: Here (http://www.omnimaga.org/other-calculator-discussion-and-news/code-golf-contest-2)

Challenge 1

Problem
Determine if an inputted number is happy. Happy numbers are defined like this: Take any positive integer, replace it with the sum of the squares of its digits, and repeat the process until it equals 1 or it loops indefinitely in a loop that does not include 1. If it ends up with 1, the number is happy, otherwise it's sad.
July 21, 2014, 1:00 AM EST
Sample input 1:
1
Sample output 1:
Code: [Select]
`HAPPY`Sample input 2:
1337
Sample output 2:
Code: [Select]
`HAPPY`Sample input 3:
385
Sample output 3:
Either one of
Code: [Select]
`SAD`or
Code: [Select]
`UNHAPPY`
Ranking

Python
 Rank User Size Date Code 1 willrandship 94 7/19/2014 11:16:56 PM Spoiler For Spoiler: x=input();b="UNHAPPY"for a in b: z=0 for y in str(x):z+=eval(y)**2;x=zprint(b[(z==1)*2:7]) 2 Juju 148 7/15/2014 4:22:50 PM Spoiler For Spoiler: def h(n): while n>1 and n!=4:  n=sum(dict([(c,int(c)**2)for c in"0123456789"])[d] for d in str(n)) return n==1print(("SAD","HAPPY")[h(input())])

Golfscript
 Rank User Size Date Code 1 Runer112 32 7/15/2014 5:17:50 PM Spoiler For Spoiler: ~{`0\{48-.*+}/}9*("SAD""HAPPY"if

CJam
 Rank User Size Date Code 1 Runer112 30 7/15/2014 5:17:50 PM Spoiler For Spoiler: q~{Ab0\{_*+}/}9*("SAD""HAPPY"?

TI-83+ BASIC
 Rank User Size Date Code 1 calc84maniac 46 7/16/2014 5:03:49 PM Spoiler For Spoiler: Repeat Ans<5sum(.5×√int(10fPart(Ans/10^(cumSum(binomcdf(98,0→AEnd"HAPPYIf log(A"SADAns 2 Runer112 46 7/16/2014 5:09:28 PM Spoiler For Spoiler: Repeat A≤4iPart(10fPart(Ans10^(~cumSum(binomcdf(14,0sum(Ans²→AEnd"HAPPYIf log(A"SADAns 3 Hayleia 71 7/16/2014 2:18:36 AM Spoiler For Spoiler: Prompt NRepeat N=1 or N=4sum(seq((10fPart(iPart(N10^(~I))/10))²,I,0,14→NEnd"HAPPYIf N=4"SADDisp Ans

TI-83+ z80
 Rank User Size Date Code 1 Runer112 58 7/20/2014 9:32:08 PM Spoiler For Spoiler: ;#SECTION "MAIN", CODE   org   userMem - 2   db   0BBh, 6DhStart:   B_CALL   _RclAnsStepLoop:   push   bc   sbc   hl, hl   ld   b, hDigitPairLoop:   dec   eDigitLoop:   ex   de, hl   xor   a   rrd   ex   de, hl   ld   c, aSquareLoop:   add   hl, bc   dec   a   jq   nz, SquareLoop   ld   a, (de)   or   a   jq   nz, DigitLoop   ld   a, e   cp   (OP1 + 2) & 0FFh   jq   nz, DigitPairLoop   push   hl   B_CALL   _SetXXXXOP2   rst   30h   pop   hl   pop   bc   djnz   StepLoop   dec   l   ld   hl, UnhappyStr   jq   nz, Unhappy   inc   hl   inc   hlUnhappy:   B_CALL   _PutS   ret;#SECTION "StrData", DATAUnhappyStr:   db   "UNHAPPY", 0 2 calc84maniac 60 7/16/2014 12:12:44 PM Spoiler For Spoiler: #define bcall(xxxx) rst 28h \\ .dw xxxx#define _RclAns \$4AD7#define _PutS \$450A#define OP1 \$8478        .org \$9D93    .db \$BB,\$6D    bcall(_RclAns)    ex de,hlHappyCalcLoop:    xor a    ld c,a    ld d,a    ld e,aHappyByteLoop:    ;Carry is reset, upper nibble of A is 0    dec lHappyNibbleLoop:    rrd    ld b,aHappyMulLoop:    push af     add a,e     daa     ld e,a     ld a,c     adc a,d     daa     ld d,a    pop af    djnz HappyMulLoop    ccf    jr c,HappyNibbleLoop    ld a,l    sub (OP1+2)&\$FF    jr nz,HappyByteLoop    ld (hl),d    inc l    ld (hl),e    inc l    inc (hl)    jr nz,HappyCalcLoop    ld hl,HappyString    dec e    jr z,\$+4    dec hl    dec hl    bcall(_PutS)    ret    UnhappyString:    .db "UN"HappyString:    .db "HAPPY",0

Batch
 Rank User Size Date Code 1 JWinslow23 182 7/19/2014 7:26:37 PM Spoiler For Spoiler: @set/p#=:@@set \$=0&@for /f "delims=" %%a in ('cmd /U /C echo %#%^|find /V ""')do @set/a\$+=%%a*%%a@set #=%\$%&@if %\$% neq 1 if %\$% neq 4 goto @@if %\$%==1 (echo happy) else echo sad

Language Ranking
 Rank Lang User Size Date 1 CJam Runer112 30 7/15/2014 5:17:50 PM 2 Golfscript Runer112 32 7/15/2014 5:17:50 PM 3 TI-83+ BASIC calc84maniac 46 7/16/2014 5:03:49 PM 4 TI-83+ z80 Runer112 58 7/20/2014 9:32:08 PM 5 Python willrandship 94 7/19/2014 11:16:56 PM 6 Batch JWinslow23 182 7/19/2014 7:26:37 PM
Title: Re: Code Golf Contest #1
Post by: Deep Toaster on July 14, 2014, 08:50:54 pm
Can I assume that since the problem states that the input is a positive integer, that the program does not have to check for these properties?
Title: Re: Code Golf Contest #1
Post by: Runer112 on July 14, 2014, 09:13:06 pm
Do you/others think it's better for entries to be messaged to you privately, rather than just posted here in a spoiler?
Title: Re: Code Golf Contest #1
Post by: calc84maniac on July 14, 2014, 09:51:30 pm
For z80 assembly, will it be judged on the size of the executable? I guess that's the only thing that makes sense...

Also, I guess we can probably take floating-point input from Ans, and work with the precision available? That is, 14 digits of precision in TI-OS floats.

One last thing, can we make it print HAPPY/UNHAPPY rather than HAPPY/SAD? This would actually be slightly more size-optimized :P
Title: Re: Code Golf Contest #1
Post by: Deep Toaster on July 15, 2014, 12:54:34 am

Do you/others think it's better for entries to be messaged to you privately, rather than just posted here in a spoiler?
OP does say to PM entries to him, so I'd assume so. I think it makes sense to PM them anyway. We could share the code in the topic after the deadline, maybe
Title: Re: Code Golf Contest #1
Post by: JWinslow23 on July 15, 2014, 11:01:42 am
No, do not check for positive-integer-ness unless you really want to. It at least has to give the right result for the test cases.
Yes, Xeda, whatever you want. Just make it work at least with the test cases.
Yes, PM me any solutions.
Yes, z80 is judged by its final size. So would Axe.
Yes, printing HAPPY/UNHAPPY would also be acceptable.

EDIT: Oh, and I will reveal all solutions in spoilers in the OP.
My own solution in TI-BASIC is 71 bytes (minus the name). Let's see who can do better...
Title: Re: Code Golf Contest #1
Post by: Juju on July 15, 2014, 01:19:21 pm
In some cases, printing HAPPY/SAD would be less characters.

Also can I send you more than one solution? As in, I can send you a PM as I improve?

Also my current solution is 159 bytes of Python. ._.
Title: Re: Code Golf Contest #1
Post by: Hayleia on July 15, 2014, 01:38:08 pm
Lol, I have 71 bytes too in TI Basic :P
Not bad for someone whose main language is Axe :P

edit just noticed how similar it is with Opti-Défis on TI Planet o.o
Title: Re: Code Golf Contest #1
Post by: JWinslow23 on July 15, 2014, 02:15:15 pm
Juju, you then shall be the winner in Python...if nobody else does it smaller. :P But you will still get credit.
And yes, you can send me multiple PMs.

Hayleia, PM it to me so I can test it, and if it works for my test cases, you will be one of the first people to participate.
Title: Re: Code Golf Contest #1
Post by: JWinslow23 on July 15, 2014, 03:34:22 pm
First entry!

Thanks to Juju with his 159 byte solution in Python! (counting newline as CRLF, as my OS does)
Title: Re: Code Golf Contest #1
Post by: willrandship on July 15, 2014, 04:21:45 pm
I've beaten Juju's score with python. Will PM shortly.

On my system it comes to 128 bytes, but that's with Unix line endings, so add another 10 bytes or so to that.

Edit: Sent another version saving another 5 bytes worth of spaces.
Title: Re: Code Golf Contest #1
Post by: Juju on July 15, 2014, 04:29:15 pm
Oh, right, the line endings. So we're gonna count with UNIX or Windows line endings? Converted to UNIX line endings my entry only weight 155 bytes.
Title: Re: Code Golf Contest #1
Post by: willrandship on July 15, 2014, 04:33:09 pm
Looks like he's counting in windows line endings, which is why I added the disclaimer.
Title: Re: Code Golf Contest #1
Post by: JWinslow23 on July 15, 2014, 05:02:37 pm
I am counting Windows (CRLF=2 bytes). willrandship, your score is 116 bytes. It does work, and I am now adding yours as we speak.

EDIT: Miscount. Redone!
Title: Re: Code Golf Contest #1
Post by: Runer112 on July 15, 2014, 05:10:25 pm
Why count newlines as two characters? I believe that basically any modern interpreter/compiler accepts either Unix-style or Windows-style newlines, so surely in the spirit of golfing you'd want to use the one-byte option?
Title: Re: Code Golf Contest #1
Post by: JWinslow23 on July 15, 2014, 05:13:15 pm
It's easier for me to count it as two, as that's how my OS counts it. If anyone knows a way for a Windows 7 user to use the other option, be my guest.
Title: Re: Code Golf Contest #1
Post by: Juju on July 15, 2014, 05:14:47 pm
Notepad++ supports UNIX line endings (Edit > Convert newlines > Convert to UNIX format (LF)).
Title: Re: Code Golf Contest #1
Post by: JWinslow23 on July 15, 2014, 05:22:14 pm
Thanks for the information. I'll switch.

EDIT: All code now counts newlines as one byte. Scores updated accordingly.
Title: Re: Code Golf Contest #1
Post by: TIfanx1999 on July 15, 2014, 06:21:45 pm
My first attempt at a TI-BASIC solution is sitting at a hefty 178 bytes. Annnnddd it's not working yet. :P I'm gonna have to play with it some more. :D
Title: Re: Code Golf Contest #1
Post by: JWinslow23 on July 15, 2014, 06:52:30 pm
willrandship got a sub-100 solution in Python! Congrats!

By now, I don't know whether or not code should be revealed.
Title: Re: Code Golf Contest #1
Post by: Juju on July 15, 2014, 07:01:03 pm
I'd say not. Probably.
Title: Re: Code Golf Contest #1
Post by: Hayleia on July 16, 2014, 03:04:54 am
How is one supposed to send an entry by PM ? PMs don't support attachements do they ?
Or i should upload it somewhere and share the link by PM ?
Title: Re: Code Golf Contest #1
Post by: JWinslow23 on July 16, 2014, 03:10:03 am
Depends on the language. If you can copy-paste the code in the message, be my guest. If not, maybe upload it somewhere like Runer did.
Title: Re: Code Golf Contest #1
Post by: Hayleia on July 16, 2014, 03:18:59 am
Ok, uploaded it on dropbox and sent you the link to my Basic entry :)
Title: Re: Code Golf Contest #1
Post by: JWinslow23 on July 16, 2014, 11:28:57 am

I also added something of my own...let's see Runer112 try to golf this TI-BASIC entry... >:D

If he asks, though, I'll show it in a spoiler. ;)
Title: Re: Code Golf Contest #1
Post by: Runer112 on July 16, 2014, 12:49:56 pm

I also added something of my own...let's see Runer112 try to golf this TI-BASIC entry... >:D

If he asks, though, I'll show it in a spoiler. ;)

Why would I want to see it? If I want to beat it fairly, I shouldn't get to peek at it.

EDIT: Only about 5 minutes later, I've figured out how to get it down to 49 as well. :P Did you use my initial entry and see the same optimization? Or did you develop yours completely independently?

EDIT a while later: Down to 48!
Title: Re: Code Golf Contest #1
Post by: calc84maniac on July 16, 2014, 02:37:50 pm
For TI-BASIC, does it matter if Done is displayed in one case and not the other? If not, then I have a 47-byte program. If so, then it's 48.
Title: Re: Code Golf Contest #1
Post by: JWinslow23 on July 16, 2014, 08:02:23 pm
For TI-BASIC, it does not matter.
Title: Re: Code Golf Contest #1
Post by: Deep Toaster on July 17, 2014, 01:07:43 am
Dammit, 71 bytes in TI-BASIC too :P
Title: Re: Code Golf Contest #1
Post by: JWinslow23 on July 17, 2014, 01:20:00 am
Is that AFTER subtracting the mem management size by 9 and then by the name length? If so, you're beaten. If not, you're beaten. :P

calc84maniac, Runer, and myself have figured out a 46-byte solution (howevef, as calc84 was first, he is the one getting credit). I'll give you a hint  on how we did it: binomial probability and logarithms.
Title: Code Golf Contest #1
Post by: Deep Toaster on July 17, 2014, 01:34:31 am
Yes; that is after subtracting the VAT entry size.

I was actually using both the hints you gave. Looks like there's something else I could optimize... I won't discuss it too much until I submit it though.

EDIT: 54 bytes, still working...
Title: Re: Code Golf Contest #1
Post by: Princetonlion.tibd on July 17, 2014, 11:14:24 am
Title: Re: Code Golf Contest #1
Post by: Hayleia on July 17, 2014, 11:22:32 am
ASMists said they prefer "unhappy" because it saves space and JWinslow23 allowed "unhappy" as a valid answer for "sad".
Title: Re: Code Golf Contest #1
Post by: Princetonlion.tibd on July 17, 2014, 11:24:51 am
Ah, thanks for informing me
Title: Re: Code Golf Contest #1
Post by: DJ Omnimaga on July 18, 2014, 12:10:43 pm
For TI-BASIC, does it matter if Done is displayed in one case and not the other? If not, then I have a 47-byte program. If so, then it's 48.
It depends which OS I think, because on OS 2.53MP and higher, it's impossible to hide the "Done" message. Even if you end your program with Output(1,1," it will still show up regardless.
Title: Re: Code Golf Contest #1
Post by: Princetonlion.tibd on July 18, 2014, 05:34:44 pm
ASMists said they prefer "unhappy" because it saves space and JWinslow23 allowed "unhappy" as a valid answer for "sad".

Now that I think about it: in every language?I 'm not sure about TIBASIC
Title: Re: Code Golf Contest #1
Post by: JWinslow23 on July 18, 2014, 05:36:21 pm
3 days left! Submit your programs fast!

Princetonlion.tibd, either of SAD or UNHAPPY are allowed. Whatever is more golfed.

Also, I want clarification on who should choose problems for subsequent competitions. Should I choose, or should the winner choose?
Title: Re: Code Golf Contest #1
Post by: Princetonlion.tibd on July 18, 2014, 05:37:26 pm
Princetonlion.tibd, either of SAD or UNHAPPY are allowed. Whatever is more golfed.

I'll join the next one then. seems good.

Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: willrandship on July 18, 2014, 09:28:08 pm
Unfortunately I doubt such a solution would be smaller in python, since getting logarithms takes:

import math
OR
from math import *

for the first, log is math.log(), but for the second it is just log(). either way, it takes either 22 or 24 bytes for ONE log call.

Also, for python I can't think of a way to save with "UN" and "HAPPY" since that would require a variable.

I'm working on a new python version that might save a few bytes, and changes to "UNHAPPY" :P
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: DJ Omnimaga on July 19, 2014, 12:09:32 am
Glad this mini contest was successful by the way :D (well from what I see so far from the many participants)
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: willrandship on July 19, 2014, 12:16:10 am
Having the winner choose would be more interesting in my opinion, since that leads to more of a variety, and provides a prize.
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: Hayleia on July 19, 2014, 03:40:06 am
I'd say that the winner chooses who chooses :P
That means a prize for the winner as willrandship said, but that also means that if the winner has no idea but someone has, that person can provide an idea too.
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: Princetonlion.tibd on July 19, 2014, 11:44:38 am
After watching this contest, I have decided to do the next one.
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: JWinslow23 on July 19, 2014, 01:05:55 pm
Thanks, everyone, for participating in this contest! You guys are the best! :thumbsup:

Oh, and the winner shall decide the next challenge (unless he can't think of one and post it by the end of Monday, for which case I will submit a challenge. Remember, a week goes by too fast to delay!). Try to think of one tomorrow, everyone.
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: Streetwalrus on July 19, 2014, 02:03:04 pm
Sorry I didn't really read all, but are people compared by language or in a single batch (yeah I know this sounds stupid) ?
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: JWinslow23 on July 19, 2014, 02:04:35 pm
Sorry I didn't really read all, but are people compared by language or in a single batch (yeah I know this sounds stupid) ?
Both. There are winners for each language AND a winner out of every other winner. The overall winner decides the next challenge.
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: Streetwalrus on July 19, 2014, 02:05:17 pm
OK thank you. :) Might enter next one, we'll see.
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: Princetonlion.tibd on July 19, 2014, 02:16:06 pm
Oh, and can there be 68k BASIC? Although you can't really optimize (:P) I think it's good. That could also revive some the 68k community
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: JWinslow23 on July 19, 2014, 02:26:32 pm
Princetonlion.tibd, literally EVERY computer AND calculator language is allowed.
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: Princetonlion.tibd on July 19, 2014, 03:38:31 pm
Princetonlion.tibd, literally EVERY computer AND calculator language is allowed.
*.*
Awesome!
I am joining the next one.
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: DJ Omnimaga on July 20, 2014, 10:57:28 am
But if only 1 person enters in a specific language, does he win by default or is he matched against people who used other languages?
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: Princetonlion.tibd on July 20, 2014, 12:00:52 pm
But if only 1 person enters in a specific language, does he win by default or is he matched against people who used other languages?
I hope someone else does 68k BASIC... So I don't win be default
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: willrandship on July 20, 2014, 03:29:59 pm
Well, the per-language win doesn't actually net you anything, so I don't think it's important to make a distinction.
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: Princetonlion.tibd on July 20, 2014, 08:08:28 pm
I don't want to win the whole thing anyways, I can't choose topics.
Just some programming motivation
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: JWinslow23 on July 20, 2014, 09:47:56 pm
OK, I have now made a rule change. Check the OP for the new rule. It will hopefully accommodate every winner.

Think of new puzzles now, all winners. I will be compiling them and choosing among them on Monday.
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: willrandship on July 20, 2014, 09:58:26 pm
Here's my challenge for the pick:

Input: A string of any length, made up of clusters of characters and numbers separated by spaces.

Output: All non-numeric clusters, concatenated together in reverse order, with the sum of all numeric clusters following, all separated by spaces.

Example:
Input:"1 asdf 15 1fg Iamamazing 14"
Output:"Iamamazing 1fg asdf 30"
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: JWinslow23 on July 20, 2014, 10:42:02 pm
Interesting challenge...it might take some explaining for some of the other participants, but interesting...

And all current winners in each language category, start submitting challenge suggestions. The real challenge will start on Tuesday.
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: Princetonlion.tibd on July 21, 2014, 08:44:43 am
Perfect timing :P
I think I'll pass, I lost both of my calcs and still can't find them :P

Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: JWinslow23 on July 21, 2014, 11:11:51 am

OK, I have now added the code that everyone has submitted. All code submitted is now in a spoiler in the OP.

Now is the time for everyone to think up a problem for the next competition! Well, all the category winners anyways. :P
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: Princetonlion.tibd on July 21, 2014, 09:35:50 pm
Just looked at the sources.
I am not that good a coder, so I think I'll make some more programs :P
Title: Re: Code Golf Contest #1 (thanks for the many submissions!)
Post by: JWinslow23 on July 22, 2014, 11:33:51 am
OK, so I have another challenge (the only submitted challenge).

See this thread (http://www.omnimaga.org/other-calculator-discussion-and-news/code-golf-contest-2/) for the challenge. Move all code golf discussion there, as well.
Title: Re: [ENDED] Code Golf Contest #1 (thanks for the many submissions!)
Post by: lirtosiast on June 11, 2015, 06:07:38 pm
It looks like we've reached a consensus that, with the [ENDED] tag to clear things up, on-topic necroposting is allowed for after-the-fact optimizations or programming/golf tips. Therefore:

The only optimization I see in the top two TI-BASIC solutions is that on a MathPrint calculator, cumSum(binomcdf(14,0 can be randIntNoRep(1,14, saving two bytes at the cost of speed, since order does not matter. Either calc84maniac or Runer112 could have won the contest outright at 44 bytes if they had done this. Both of them noticed that If A≠1 could be optimized to If log(A, which is small but hard to notice.
Title: Re: [ENDED] Code Golf Contest #1 (thanks for the many submissions!)
Post by: JWinslow23 on June 12, 2015, 02:26:23 pm
It looks like we've reached a consensus that, with the [ENDED] tag to clear things up, on-topic necroposting is allowed for after-the-fact optimizations or programming/golf tips. Therefore:

The only optimization I see in the top two TI-BASIC solutions is that on a MathPrint calculator, cumSum(binomcdf(14,0 can be randIntNoRep(1,14, saving two bytes at the cost of speed, since order does not matter. Either calc84maniac or Runer112 could have won the contest outright at 44 bytes if they had done this. Both of them noticed that If A≠1 could be optimized to If log(A, which is small but hard to notice.
Well, I didn't have a MATHPRINT calculator (and others here don't either...take Zeda/Xeda, for example), and I had to be able to test the solutions myself. If anybody makes a solution that requires any TI-84+ OS 2.53 or over, we should make that a separate category. In my opinion.
Title: Re: [ENDED] Code Golf Contest #1 (thanks for the many submissions!)
Post by: Sorunome on June 12, 2015, 04:55:20 pm
I don't think that it should be a separate category, as else for languages like php you'd have to make a separate category for every module you use because it might be disabled in the php.ini .
Title: Re: [ENDED] Code Golf Contest #1 (thanks for the many submissions!)
Post by: JWinslow23 on June 13, 2015, 10:08:13 am
I don't think that it should be a separate category, as else for languages like php you'd have to make a separate category for every module you use because it might be disabled in the php.ini .
...OK, then I guess MATHPRINT-only commands are disallowed.