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 - JWinslow23

Pages: 1 ... 8 9 [10] 11 12 ... 40
136
Community Contests / Re: Code Golf Contest #11
« on: September 26, 2014, 09:50:23 pm »
Message received!

137
Community Contests / Re: Code Golf Contest #11
« on: September 26, 2014, 05:16:43 pm »
You PM your code to JWinslow23.
What he said ^^

138
Community Contests / Re: Code Golf Contest #11
« on: September 25, 2014, 07:19:49 pm »
Bump.

Woo, score of 111 in GS! :D

139
Community Contests / Re: Code Golf Contest #11
« on: September 23, 2014, 09:12:59 pm »
It works, and well at that! :thumbsup:

140
Community Contests / Re: Code Golf Contest #11
« on: September 23, 2014, 05:24:53 pm »
Yay, got it to 562-70%=168.6 characters in Ruby.

EDIT: 559-70%=167.7 now. Also I have a few questions:
- Do I have to print "4 is 4" with an input of 4? (No would save a few bytes)
- "Ninety-nine" or "ninety nine"? Does it matter? (No would save one byte)
- Capital letter at the beginning? (No would save a few bytes)
1. No, input of 4 means instant input of "4 is magic".
2. It shouldn't matter, but that's how I write numbers, usually. Do it if you want.
3. Whatever you want, but it's common courtesy to.

141
Community Contests / [ENDED] Code Golf Contest #11
« on: September 22, 2014, 08:52:42 pm »
#MakeEleventyAThing :P

NEXT: Here
PREVIOUS: Here

Challenge 11

Problem

Create a program that, given an integer 0 through 999,999, does the "4 is magic" transformation. If you don't know what that is, this is it:
  • Take the number written out in English and count the number of letters (i.e. 21 is "twenty-one" is 9 letters, 102 is "one hundred two" is 13 letters, 9999 is "nine thousand nine hundred ninety-nine" is 33 letters).
  • If the result is 4, output "4 is magic." and exit.
  • Else, output "(original number) is (result)." and repeat step 1 with the result.
Example:
Code: [Select]
31 is 9.
9 is 4.
4 is magic.

-70% bonus if you actually display the number-words instead of the numbers.

Deadline
October 5, 2014, 1:00 AM EST

If any further clarification is needed, contact me. I'll try to make your troubles disappear. :P

Ruby
RankUserSizeDateCode
1Juju548-70%=164.49/23/2014 6:25:12 PM
Spoiler For Spoiler:
def w(n)
case n
when 0..19
["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"][n]
when 20..99
["twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"][n/10-2]+(n%10==0?"":" "+w(n%10))
when 100..999
w(n/100)+" hundred"+(n%100==0?"":" "+w(n%100))
when 1000..999999
w(n/1000)+" thousand"+(n%1000==0?"":" "+w(n%1000))
end
end
a=gets.to_i
while a!=4
p w(a)+" is "+w(a=w(a).delete(" ").length)+"."
end
p"four is magic."

Golfscript
RankUserSizeDateCode
1JWinslow23360-70%=10810/4/2014 9:37:27 AM
Spoiler For Spoiler:
~{.20<{.12>["zero""one""two""three""four""five""six""seven""eight""nine""ten""eleven""twelve""thir""four""fif""six""seven""eigh""nine"]@="teen"@*+}{.100<{.10/2-["twen""thir""for""fif""six""seven""eigh""nine"]{"ty"+}%\=\10%a" "\++}{.1000<{.100/a" hundred "+\100%a+}{.1000/a" thousand "+\1000%a+}if}if}if" zero"%""+}:a;{.4=}{a." "/""+," is "\.n\}until" is magic"

Python
RankUserSizeDateCode
1Ivoah962-70%=288.69/26/2014 6:32:23 PM
Spoiler For Spoiler:
import sys
a = {1:' one',2:' two',3:' three',4:' four',5:' five',6:' six',7:' seven',8:' eight',9:' nine',10:' ten',11:' eleven',12:' twelve',13:' thirteen',14:' fourteen',15:' fifteen',16:' sixteen',17:' seventeen',18:' eighteen',19:' nineteen',20:' twenty',30:' thirty',40:' forty',50:' fifty',60:' sixty',70:' seventy',80:' eighty',90:' ninety',100:' hundred',1000:' thousand'}
def b(n):
 if n<=20:
  if n==0:return 'zero'
  else:return a[n].strip()
 else:
  c=''
  for d,e in enumerate(str(n)):
   i=10**(len(str(n))-d-1)
   j=int(e)
   if i==1e5:c+=a[j]+a[100]
   elif i==1e4:c+=a[j*10]
   elif i==1e3:
    if c[-3:]=='ten'and j!=0:c=c[:-4]+a[j+10]
    else:c+=a[j]
    c+=a[1e3]
   elif i==100:c+=a[j]+a[100]
   elif i==10:c+=a[j*10]
   elif i==1:
    if c[-3:]=='ten'and j!=0:c=c[:-4]+a[j+10]
    else:c+=a[j]
  c=c.strip()
  return c
n=sys.argv[1]
while True:
 f=len(''.join(b(n).split()))
 print b(n),'is',b(f)
 n=f
 if f==4:print b(4),'is magic!';break

Java
RankUserSizeDateCode
13298611-70%=183.310/4/2014 2:54:53 PM
Spoiler For Spoiler:
class G{static String[]x={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"},y={"twen","thir","four","fif","six","seven","eigh","nine"};static String t(int n){String s="";if(n>99){s=x[n/100]+" hundred ";n%=100;if(n==0)return s;}return s+(n<13?x[n]+" ":n<20?y[n-12]+"teen ":y[n/10-2]+"ty "+(n%10==0?"":x[n%10]+" "));}public static void main(String[]i){for(int n=Integer.parseInt(i[0]);{String s=n>999?t(n/1000)+"thousand "+(n%1000==0?"":t(n%1000)):t(n);int m=0;for(char c:s.toCharArray())if(c>64)++m;System.out.println(s+"is "+(n==4?"magic":m));if(n==4)break;n=m;}}}
2ben_g676-70%=202.89/28/2014 2:52:53 PM
Spoiler For Spoiler:
class e{public static void main(String[] a){int i=Integer.parseInt(a[0]);while(i!=4){a[0]=b(i).trim();if(a[0].length()==0)a[0]="zero";System.out.println(a[0]+" is "+(i=a[0].replace(" ","").length()));}System.out.println("four is magic");}static String b(int i){String[]n={"","one","two","three","four","five","six","seven","eight","nine","then","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"},m={"","","twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety","hundred"};if(i<20)return n;if(i<100)return m[i/10]+" "+n[i%10];if(i<1000)return b(i/100)+" hundred "+b(i%100);return b(i/1000)+" thousand "+b(i%1000);}}

C
RankUserSizeDateCode
13298630-70%=18910/4/2014 2:54:53 PM
Spoiler For Spoiler:
#include<stdio.h>
char*x[]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"},*y[]={"twen","thir","four","fif","six","seven","eigh","nine"};int l;p(char*s){printf("%s",s);l+=strlen(s);}t(int n){if(n>99){p(x[n/100]);p(" hundred");--l;if(!(n%=100))return;p(" ");--l;}if(n<13)p(x[n]);else if(n<20){p(y[n-12]);p("teen");}else{p(y[n/10-2]);p("ty");if(n%=10){p(" ");--l;p(x[n]);}}}main(int c,char**v){int n=0;while(*(v[1]))n=10*n+*(v[1]++)-48;r:l=0;if(n>999){t(n/1000);p(" thousand");--l;if(n%1000){p(" ");--l;t(n%1000);}}else t(n);if(n-4){n=l;printf(" is %i\n",n);goto r;}p(" is magic\n");}
2ben_g861-70%=258.310/3/2014 3:52:36 AM
Spoiler For Spoiler:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static const char *m[]={"","one","two","three","four","five","six","seven","eight","nine","then","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};static const char *n[]={"","","twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety","hundred"};const char * w(int l, char* u){if(l==0){sprintf(u,"zero");return;}if(l<20){sprintf(u,"%s",m[l]);return;}if(l<100){sprintf(u,"%s %s",n[l/10],m[l%10]);return;}if(l<1000) {sprintf(u,"%s hundred ",m[l/100]);w(l%100,u+strlen(u));return;}w(l/1000,u);sprintf(u+strlen(u)," thousand ");w(l%1000,u+strlen(u));return;}int main(int argc,char *argv[]){int a=atoi(argv[1]);while(a!=4){char b[70]={0};int i=0;w(a,b);a=0;while(b!='\0'){if(b!=' ')a++;i++;}printf("%s is %i,\n",b,a);}printf("4 is magic.\n");}

SysRPL
RankUserSizeDateCode
13298493.5-70%=148.0510/4/2014 2:54:53 PM
Spoiler For Spoiler:
::
  { "twen" "thir" "four" "fif" "six" "seven" "eigh" "nine" }
  ' ::
    BINT100 #/ DUP#0=ITE DROPNULL$
    ::
      1GETLAMSWAP_ NTHCOMPDROP
      " hundred " &$
    ;
    SWAP DUP#0=csDROP
    BINT13 OVER#> case
    ::
      1GETLAMSWAP_ NTHCOMPDROP
      APPEND_SPACE &$
    ;
    BINT20 OVER#> case
    ::
      BINT11 #-
      3GETLAM SWAP NTHCOMPDROP
      "teen " &$ &$
    ;
    BINT10 #/ 3GETLAM SWAP#1-
    NTHCOMPDROP "ty " &$SWAP
    DUP#0=csedrp &$
    1GETLAMSWAP_ NTHCOMPDROP
    APPEND_SPACE &$ &$
  ;
  { "one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" "eleven" "twelve" }
  3NULLLAM{}_ BIND
  COERCE BEGIN
    DUP#0=ITE "zero "
    ::
      DUP # 3E8 #/
      DUP#0=csedrp 2GETEVAL
      2GETEVAL "thousand " &$SWAP
      2GETEVAL &$
    ;
    BINT0 OVERLEN$ #1+_ONE_DO
      OVERINDEX@ SUB$1#
      BINT64 #> IT #1+
    LOOP
    UNROT "is " &$SWAP
    BINT4 #=case
    ::
      RDROP SWAPDROP ABND
      "magic" &$
    ;
    OVER #>$ &$SWAP
  AGAIN
;

Language Ranking
RankLangUserSizeDate
1GolfscriptJWinslow2310810/4/2014 9:37:27 AM
2SysRPL3298148.0510/4/2014 2:54:53 PM
3RubyJuju164.49/23/2014 6:25:12 PM
4Java3298183.310/4/2014 2:54:53 PM
5C329818910/4/2014 2:54:53 PM
6PythonIvoah288.69/26/2014 6:32:23 PM

142
Community Contests / Re: Code Golf Contest #10
« on: September 22, 2014, 02:52:29 pm »
Hey JWinslow, why no pun? :/
The end of this challenge is drawing near. I'm interested to see what solutions this brings. This challenge is well-rounded, colorful, and bound to be interesting.

There, happy? :P

Never forget about Code Golf. Go finish your entry: Give everything you got. You will be rewarded: Up your score will go!


Better? :P

Never go give you up?... Going there, aren't we? To drop so low as that, and you don't even get it right? Give a little more effort this time. You will never make it in the pun industry. Up and away with you! :P

143
Community Contests / Re: Code Golf Contest #10
« on: September 19, 2014, 07:51:50 pm »
Hey JWinslow, why no pun? :/
The end of this challenge is drawing near. I'm interested to see what solutions this brings. This challenge is well-rounded, colorful, and bound to be interesting.

There, happy? :P

144
Community Contests / Re: Code Golf Contest #10
« on: September 17, 2014, 06:21:44 pm »
Jens_K has tied with Golfscript and CJam! He is now among the ranks of the ASCII artists without being one himself. Nice job, Jens_K. :)

145
Community Contests / Re: Code Golf Contest #10
« on: September 16, 2014, 11:32:22 pm »
I'm replying to JW23 (his PM) publicly so maybe it can help others :

Oh, and do the rings interlock properly?
For me, the rings are drawn from left to right. I don't know how much of an interlocking that counts. Probably none :P But they overlap etc.

Talking about that :

Oops, meant to message Jens_K, sorry.
And prince, 50 percent off of 40 percent off of X is 70 percent off, if I'm not mistaken.

146
Community Contests / Re: Code Golf Contest #10
« on: September 16, 2014, 08:32:18 pm »
For ASCII art, does this also include just using 1 lowercase circle for an entire ring or is that against the rules? :P
The rings must overlap. You can't do that with Os.

147
Community Contests / Re: Code Golf Contest #10
« on: September 16, 2014, 09:16:47 am »
I'll send you the color version soon.


I have the color version, don't I? ???

But thanks.

148
Community Contests / Re: Code Golf Contest #10
« on: September 16, 2014, 01:17:07 am »
Bump.

I have now implemented the bonuses. You get 40% of your score deducted if the rings are interlocked properly, 50% off if the colors are present and distinct (for ASCII art entries, text must actually be colored), and 70% off (correct me if I'm wrong) for both. Juju, please show me a picture of your Ruby code output; I have no idea if the first criterion is met by yours.

149
Community Contests / Re: Code Golf Contest #10
« on: September 15, 2014, 11:54:39 pm »
Nspire-Lua :

66 bytes for this (black and white) :


82 with varying shades of blue (we can't really see but yes, it's different) :


83 for a little bit visually distinct :


84 for visually ""very"" distinct colours :


What's submittable among that ?
The 84-byte one. If at all possible for graphical entries, colors must be present and distinct.

Also, for ASCII art entries, I am allowing (for example) an output of
  bbbb  ####  rrrr
 b    b#    #r    r
 b   ybyy  g#gg   r
  bbyb  ##g#  rrrr
    y    yg    g
     yyyy  gggg

counting towards only proper interlocking (unless the text is colored in the correct way, in which case it counts for both).

(BTW, what do you think the point reduction values should be for color and/or proper interlocking? I'm thinking along the lines of -40 or -50.)

EDIT:
54 bytes of CJam and 101 bytes of GNU C

TAKE THAT!!!
47 bytes of both CJam and Golfscript.

TAKE THAT!!! :P

150
Community Contests / Re: Code Golf Contest #10
« on: September 15, 2014, 10:37:23 pm »
  • The program must not access an external source, Juju :P
I didn't do that? o.o
Code Golf 9, Bash. :P perl isn't on every PC.

Also please don't take solutions from here : http://codegolf.stackexchange.com/questions/18986/draw-the-olympic-games-logo
Yes, golf them. :P

Pages: 1 ... 8 9 [10] 11 12 ... 40