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 ... 15 16 [17] 18 19 ... 40
241
Community Contests / Re: Code Golf Contest #2
« on: July 28, 2014, 03:31:27 pm »
New contest is underway!

Please move any and all discussion on code golfing here.

I already have a solution in TI-BASIC that is 122 bytes large. Who can do better?

242
Community Contests / [ENDED] Code Golf Contest #3
« on: July 28, 2014, 03:29:31 pm »
This is the same deal as the other two contests.

NEXT: Here
PREVIOUS: Here

Challenge 3

Problem
Make a program that, given an integer of reasonable size, outputs the greatest prime factor of that integer, in binary, but with all 0s replaced with underscores (_) and all 1s replaced with minus signs (-).

Deadline
August 4, 2014, 1:00 AM EST

Sample input 1
15
Sample output 1
-_-
Sample input 2
7
Sample output 2
---
Sample input 3
115
Sample output 3
-_---

If any further clarification is necessary, contact me or willrandship, and we will explain the best we can.

Ranking

TI-83+ BASIC
RankUserSizeDateCode
1Runer112758/3/2014 2:17:19 PM
Spoiler For Spoiler:
For(A,Ans,2,~1
If not(fPart(Ans/A
A->P
End
"B
For(A,0,log(P)/log(2
sub("_-",iPart(2fPart(P/2/2^A))+1,1)+Ans
End
sub(Ans,1,A
2JWinslow23907/29/2014 11:43:19 AM
Spoiler For Spoiler:
Ans->X
X=1->A
While X>1
2->A
While fPart(X/A
IS>(A,X
End
X/A->X
End
"_
If A
"
Ans->Str1
While A
"_
If fPart(.5A
"-
Ans+Str1->Str1
int(.5A->A
End
Str1

Python2
RankUserSizeDateCode
1willrandship1477/29/2014 12:51:41 AM
Spoiler For Spoiler:
def f(z):
 for y in range(2,z+1):
  if z%y:continue
  return z if y==z else f(z/y)
a=""
for c in bin(f(input()))[2:]:a+='-'if c=='1'else'_'
print a

Ruby
RankUserSizeDateCode
1Juju1157/29/2014 2:47:50 AM
Spoiler For Spoiler:
a=gets.to_f;b=2;while a>1;(c=a/b)==c.to_i&&(a=c)||b+=1 end;p b.to_s(2).gsub('0','_').gsub('1','-')

Nspire Lua
RankUserSizeDateCode
1Jens_K1328/1/2014 6:59:33 AM
Spoiler For Spoiler:
n=0+clipboard.getText()f=n
repeat f=(f>2 and f-1 or n)until n%f<1
b=""repeat b=(f%2>0 and"-"or"_")..b;f=(f-f%2)/2 until f<1
print(b)

SysRPL
RankUserSizeDateCode
1329859.57/31/2014 5:18:48 PM
Spoiler For Spoiler:
::
  FPTR2 ^NFactorSpc
  DUPLENCOMP  NTHCOMPDROP
  FPTR2 ^Z>#
  NULL$SWAP BEGIN
    DUP #2/ UNROT BINT1 #AND
    #1= ITE CHR_- CHR_UndScore >T$
  SWAP #0=UNTIL DROP
;

Perl
RankUserSizeDateCode
1willrandship987/31/2014 2:15:31 PM
Spoiler For Spoiler:
$z=<>;sub f{for(2..$z){$z/=$z%$_?next:$_;return$z>1?&f:$_;}}$_=sprintf"%b",f;s/1/-/g;s/0/_/g;print

Haskell
RankUserSizeDateCode
132981228/3/2014 6:16:11 PM
Spoiler For Spoiler:
import Numeric
g i=showIntAtBase 2c(f(i,2))""
f(1,j)=j
f(i,j)=if mod i j==0then f(quot i j,j)else f(i,j+1)
c 0='_'
c 1='-'
2bb010g2168/2/2014 7:11:01 PM
Spoiler For Spoiler:
import Numeric;import Data.Char;main=fmap(\n->concatMap(\case{'0'->"_";_->"-"})$showIntAtBase 2intToDigit(last[x|x<-[1..n-1],n`mod`x==0,elem x[n|n<-[2..x],not$elem n[j*k|j<-[2..n-1],k<-[2..n-1]]]])"")readLn>>=putStr

CJam
RankUserSizeDateCode
1Runer112168/3/2014 2:17:19 PM
Spoiler For Spoiler:
q~mfZ=2b{"_-"=}%

Golfscript
RankUserSizeDateCode
1Runer112338/3/2014 2:17:19 PM
Spoiler For Spoiler:
~.,2>-1%{].~%!=}/2base{"_-"=}%""+

Java
RankUserSizeDateCode
1Runer1121728/3/2014 2:17:19 PM
Spoiler For Spoiler:
class C{public static void main(String[]a){long x=Long.decode(a[0]),i=x;while(i-->2)x=(x%i)==0?i:x;System.out.print(Long.toString(x,2).replace('0','_').replace('1','-'));}}
232981858/3/2014 6:16:11 PM
Spoiler For Spoiler:
class G{public static void main(String[]c){int n=Integer.parseInt(c[0]),i=2;while(i<n)if(n%i==0)n/=i;else++i;System.out.print(Integer.toString(n,2).replace('0','_').replace('1','-'));}}

TI-83+ z80
RankUserSizeDateCode
1Runer112588/3/2014 2:17:19 PM
Spoiler For Spoiler:
;#SECTION "MAIN", CODE

   org   userMem - 2
   db   0BBh, 6Dh
Start:
   B_CALL   _RclAns
   B_CALL   _ConvOP1
   ld   h, d
   ld   l, e
TrialDivideLoop:
   push   de
   push   hl
   B_CALL   _DivHLByDE
   ld   a, h
   or   l
   pop   hl
   pop   de
   jq   nz, NotFactor
   ld   h, d
   ld   l, e
NotFactor:
   dec   de
   ld   a, e
   dec   a
   or   d
   jq   nz, TrialDivideLoop
   ld   b, h
   ld   c, l
   ld   hl, OP1 + 15
   ld   (hl), d
BitLoop:
   dec   hl
   srl   b
   rr   c
   ld   (hl), '_'
   jq   nc, BitUnset
   ld   (hl), '-'
   ld   d, h
   ld   e, l
BitUnset:
   jq   nz, BitLoop
   ex   de, hl
   B_CALL   _PutS
   B_CALL   _NewLine
   ret

XTend
RankUserSizeDateCode
132981798/3/2014 6:16:11 PM
Spoiler For Spoiler:
class G{def static void main(String[]c){var n=Integer.parseInt(c.get(0))var i=2while(i<n)if(n%i==0)n=n/i else i=i+1print(Integer.toString(n,2).replace('0','_').replace('1','-'))}}

Language Ranking

RankLangUserSizeDate
1CJamRuner112168/3/2014 2:17:19 PM
2GolfscriptRuner112338/3/2014 2:17:19 PM
3TI-83+ z80Runer112588/3/2014 2:17:19 PM
4SysRPL329859.5 (don't ask me why; I'm going off of what he said)7/31/2014 5:18:48 PM
5TI-83+ BASICRuner112758/3/2014 2:17:19 PM
6RubyJuju987/30/2014 12:01:58 AM
7Perlwillrandship987/31/2014 2:15:31 PM
8Haskell32981228/3/2014 6:16:11 PM
9Nspire LuaJens_K1328/1/2014 6:59:33 AM
10Python2willrandship1477/29/2014 12:51:41 AM
11JavaRuner1121728/3/2014 2:17:19 PM
12XTend32981798/3/2014 6:16:11 PM

243
Community Contests / Re: Code Golf Contest #2
« on: July 28, 2014, 01:07:22 pm »
Interesting. I like it! :thumbsup:

Now here's my TI-BASIC solution for contest #2 in 201 bytes:
Code: [Select]
:Input Str1
:DelVar CDelVar X" →Str2
:Repeat not(B
:X+1→X
:0→M
:For(N,1,X
:Ans+1→A
:inString(Str1," ",Ans→B
:End
:If not(Ans
:1+length(Str1
:sub(Str1,A,Ans-A
:For(L,1,length(Ans
:If inString("0123456789",sub(Ans,L,1
:IS>(M,M
:
:End
:If M=length(Ans
:Then
:C+expr(Ans→C
:Else
:Ans+" "+Str2→Str2
:End
:End
:ClrHome
:Output(1,1,Str2
:length(Str2)/16
:Output(int(Ans)+not(int(Ans)),16fPart(Ans)+16not(fPart(Ans)),C

244
Community Contests / Re: Code Golf Contest #2
« on: July 27, 2014, 10:12:24 pm »
Quickly quickly quickly! Submit your final entries by the end of the night! Also, any winners, think of challenges for our next contest!

245
Community Contests / Re: Code Golf Contest #2
« on: July 27, 2014, 04:42:44 pm »
That was the LONGEST update I've ever had to do. O.O But I did it! :thumbsup:

246
Community Contests / Re: Code Golf Contest #2
« on: July 27, 2014, 01:16:33 pm »
Welcome to the forums! You somehow remind me of the guy who registered and made a new topic just so he could get a solution to a level in Portal Prelude. XD

Anyways, so yeah, unless you post 4 more times AND PM me your solutions by the end of the day, I'll PM you with my email.

247
Community Contests / Re: Code Golf Contest #2
« on: July 26, 2014, 06:36:40 pm »
2 more days left for submissions! Oh, and all winners in categories, think of possible next challenges.

248
Community Contests / Re: Code Golf Contest #2
« on: July 23, 2014, 05:33:23 pm »
You know what? Let's just assume no trailing, leading, or repeating spaces, and all alphanumeric characters. That would bring my solution down from 465 bytes to about 280 bytes. :P

249
Community Contests / Re: Code Golf Contest #2
« on: July 23, 2014, 12:48:02 pm »
Can we get some official clarification on input format, JWinslow23/willrandship? The main questions that come to mind are:

  • Are words/clusters composed of alphanumeric characters, any printable characters, or something in between?
  • Are leading, trailing, or duplicated (successive) spaces valid?

A good way to solidify all of these rules at once could be to specify a regular expression for valid input.
Well, if you use regular expressions, now you got TWO problems. :P

Words are made up of any printable characters except for the space. Trailing, leading, and repeating spaces are valid, but shall be deleted so there is only one space between words upon output.

250
Community Contests / Re: Code Golf Contest #2
« on: July 23, 2014, 03:28:19 am »
Aha, down to 80 bytes! Try to beat me :P
60 in Golfscript. :P

Processing the new solution tomorrow.

251
Community Contests / Re: Code Golf Contest #2
« on: July 22, 2014, 03:07:16 pm »
Yup. And I finally figured out a Golfscript solution.

252
OK, so I have another challenge (the only submitted challenge).

See this thread for the challenge. Move all code golf discussion there, as well.

253
Community Contests / [ENDED] Code Golf Contest #2
« on: July 22, 2014, 11:32:51 am »
Here is the second code golf contest. Rules here.

NEXT: Here
PREVIOUS: Here

Challenge 2

Problem
Make a program with the following input and output:

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

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

Deadline
July 28, 2014, 1:00 AM EST

Sample input 1
"1 asdf 15 1fg Iamamazing 14"
Sample output 1
"Iamamazing 1fg asdf 30"
Sample input 2
"Hello W0rld 63 How 4r3 you 6"
Sample output 2
"you 4r3 How W0rld Hello 69"

If any further clarification is necessary, please contact me or willrandship. We will try to explain.

Ranking

Ruby 2
RankUserSizeDateCode
1Juju807/23/2014 12:39:40 PM
Spoiler For Spoiler:
a=0;print gets.split.reverse.reject{|b|a!=a+=Integer(b)rescue 0}.join(" ")," ",a

Golfscript
RankUserSizeDateCode
1Runer112327/27/2014 12:27:24 PM
Spoiler For Spoiler:
" "%-1%0\{.{|}*64<{~+}{" "@}if}/
2JWinslow23607/22/2014 1:02:09 PM
Spoiler For Spoiler:
" "%-1%0:a;{..{.47>\59<and},={~a+:a;}{}if}/]{.!{}{" "+}if}/a

Nspire Lua
RankUserSizeDateCode
1Jens_K113 (copy input to clipboard)7/23/2014 9:15:32 AM
Spoiler For Spoiler:
s,n="",0
for w in clipboard.getText():gmatch"%S+"do
if tonumber(w)then n=n+w else s=w.." "..s end
end
print(s..n)
2LDStudios1627/23/2014 3:30:25 PM
Spoiler For Spoiler:
i="" p={} function on.charIn(h) s="" i=i..h p=i:split(s) n=0 for i,v in ipairs(p) do if v:find("%a") then s=v.." "..s elseif v:find("%d") then n=n+v end end print(i) print(s..n) end

Python3
RankUserSizeDateCode
1willrandship837/22/2014 3:08:29 PM
Spoiler For Spoiler:
s=0;o=''
for w in input().split():
 try:s+=int(w)
 except:o=o+w+" "
print(o+str(s))

Java
RankUserSizeDateCode
1Runer1121747/27/2014 12:27:24 PM
Spoiler For Spoiler:
class B{public static void main(String[]a){int x=0,i=a.length;while(i>0)try{x+=Integer.parseInt(a[--i]);}catch(Exception e){System.out.print(a+' ');}System.out.print(x);}}
232981787/27/2014 1:58:00 PM
Spoiler For Spoiler:
class G{public static void main(String[]c){int n=0;String s="";for(String i:c[0].split(" ")){try{n+=Integer.parseInt(i);}catch(Exception e){s=i+" "+s;}}System.out.println(s+n);}}
3ben_g1987/22/2014 4:01:06 PM
Spoiler For Spoiler:
public class Main{public static void main(String[] args){String s="";int i=0;for(String t:args[0].split(" ")){try{i+=Integer.parseInt(t);}catch(Exception e){s=t+" "+s;}}s+=i;System.out.println(s);}}

CJam
RankUserSizeDateCode
1Runer112277/27/2014 12:27:24 PM
Spoiler For Spoiler:
qS%W%0\{_:i:|'A<{~+}{S@}?}/

XTend
RankUserSizeDateCode
132981597/27/2014 1:58:00 PM
Spoiler For Spoiler:
class G{static var n=0;def static void main(String[]c){println(c.get(0).split(" ").fold("")[s,i|try{n=n+Integer.parseInt(i);s}catch(Exception _){i+" "+s}]+n)}}

Haskell
RankUserSizeDateCode
132981387/27/2014 1:58:00 PM
Spoiler For Spoiler:
import Text.Read
g c=(fst f)++show(snd f)where f=foldr(\i(s,n)->case readMaybe i of Nothing->(s++i++" ",n);Just m->(s,n+m))("",0)(words c)

SysRPL
RankUserSizeDateCode
13298797/27/2014 1:58:00 PM
Spoiler For Spoiler:
::
  BINT0 FPTR2 ^StrCutNchr_
  Z0_ NULL$ ROT BEGIN
    SEP$NL FPTR2 ^S>Z? ITE
    :: 4ROLL FPTR2 ^QAdd UNROT ;
    :: APPEND_SPACE ROT &$SWAP ;
  DUPNULL$? UNTIL
  DROPSWAP FPTR2 ^Z>S &$
;

Language Ranking

RankLangUserSizeDate
1CJamRuner112277/27/2014 12:27:24 PM
2GolfscriptRuner112327/27/2014 12:27:24 PM
3SysRPL3298797/27/2014 1:58:00 PM
4Ruby 2Juju807/23/2014 12:39:40 PM
5Python3willrandship837/22/2014 3:08:29 PM
6Nspire LuaJens_K113 (copy input to clipboard)7/23/2014 9:15:32 AM
7Haskell32981387/27/2014 1:58:00 PM
8XTend32981597/27/2014 1:58:00 PM
9JavaRuner1121747/27/2014 1:58:00 PM

254
Too bad, Prince. :(

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

255
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.

Pages: 1 ... 15 16 [17] 18 19 ... 40