Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Search

Advanced Search Options

To further refine your search, you can use additional qualifiers such as score:>0.5. For example, the search score:>=0.5 created:<1y grammar would return only posts mentioning "grammar" that have a score >= 0.5 and were created less than a year ago.

Further help with searching is available in the help center.

Quick hints: tag:tagname, user:xxx, "exact phrase", post_type:xxx, created:<N{d,w,mo,y}, score:>=0.5

Filters
 
66%
+2 −0
Q&A Tips for golfing in Java

This is a list of golfing tips for the language known as Java. If you have a tip, add it in!

7 answers  ·  posted 3y ago by General Sebast1an‭  ·  last activity 3y ago by General Sebast1an‭

Question code-golf tips
66%
+2 −0
Q&A Tips for golfing in Java

Use for(;;) instead of while(true) The title's self-explanatory. A byte saver.

posted 3y ago by General Sebast1an‭

Answer
66%
+2 −0
Q&A Tips for golfing in Java

Abuse the C-like array syntax If you ever have to declare two variables, one of type X and the other of type X[], instead of two statements, you can declare them together using this atrocious synt...

posted 3y ago by user‭

Answer
66%
+2 −0
Q&A Tips for golfing in Java

Abuse anonymous classes Warning: This only works in very specific circumstances, and I've never actually needed it. Instead of defining a method outside of your method, you can make an instance o...

posted 3y ago by user‭

Answer
66%
+2 −0
Q&A Tips for golfing in Java

Use interface The special thing about this is that it lets you drop public when you originally call a class to run the main function. class F{public static void main(String[]a{}} interface M{sta...

posted 3y ago by General Sebast1an‭

Answer
66%
+2 −0
Challenges 99 Shortened Bottles of Beer

Java (JDK), 311 301 296 bytes interface A{static void main(String[]x){String a=" bottle",b=" of beer",c=" on the wall. ",e;for(int i=99;i>0;i--){e=i>1?"s":"";System.out.println(i+a+e+b+c+(...

posted 3y ago by General Sebast1an‭  ·  edited 3y ago by General Sebast1an‭

Answer
66%
+2 −0
Challenges "Hello, {name}!"

JavaScript, 28 bytes alert(`Hello, ${prompt()}!`) Try it online!

posted 3y ago by Shaggy‭

Answer
66%
+2 −0
Challenges 1, 2, Fizz, 4, Buzz!

AWK, 72 bytes BEGIN{for(i=1;i<101;i++){s="";i%3||s="Fizz";i%5||s=s"Buzz";print s?s:i}} Try it online!

posted 3y ago by smlckz‭

Answer
66%
+2 −0
Q&A Tips for golfing in C

Use pointer arithmetic and \0 with string literals In C, strings are just zero-terminated character arrays, which means you can play tricks with pointer arithmetic. For example, the line char*s=a...

posted 3y ago by celtschk‭

Answer
66%
+2 −0
Challenges Implement Rule 110

JavaScript (Node.js), 160 bytes (r,d,n,l=r.length,s=d.length,p=(n,i)=>n?"01110110"[4*p(--n,i-1)+2*p(n,i)+1*p(n,i+1)]:i>=0&i<s?d[i]:r[(i%l+l)%l])=>[...Array(4*l+s+2*n)].map((_,i)=...

posted 3y ago by Moshi‭  ·  edited 3y ago by Moshi‭

Answer
66%
+2 −0
Sandbox Create a finite projective plane of order $n$

posted 3y ago by user‭  ·  edited 3y ago by user‭

Article code-golf math
66%
+2 −0
Challenges Find the IP address class

C (gcc), 64 62 bytes Saved 2 bytes thanks to m90 in the comments. i;f(char*s){i=atoi(s)>>4;return'A'+(i&8?i&4?i&2?i%2+3:2:1:0);} Try it online!

posted 3y ago by celtschk‭  ·  edited 3y ago by celtschk‭

Answer
66%
+2 −0
Challenges Operation "Find The Operator"

Ruby, 58 bytes Simple eval solution. Using ** for exponentiation. ->a,b,c{%w[+ - * / % **].select{eval("#{a}#{_1}#{b}")==c}} Attempt This Online!

posted 3y ago by snail_‭

Answer
66%
+2 −0
Challenges Determine whether an integer is square-free

Ruby, 27 bytes ->n{(2..n).all?{n%_1**2>0}} Try it online

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
66%
+2 −0
Challenges Multiply complex numbers.

Ruby, 25 bytes ->e{e.to_c*e[/ .*/].to_c} Try this online!

posted 3y ago by radarek‭

Answer
66%
+2 −0
Challenges Given the preorder and the inorder of a tree, output the postorder

Ruby, 75 72 bytes f=->((e,*r),n){(i=n.index e)?f[r[0,i],n[...i]]+f[r[i..],n[i+1..]]+[e]:n} Attempt This Online!

posted 3y ago by radarek‭  ·  edited 3y ago by radarek‭

Answer
66%
+2 −0
Challenges Stairs? Stairs! Stairs.

Ruby, 50 bytes ->n{n.times{puts (' '*(n-_1)+'_/'+'##'*_1)[3..]}} Attempt This Online!

posted 3y ago by radarek‭

Answer
66%
+2 −0
Challenges Keyword golfing

Scala 3, 553 bytes package a import E.Z as Z import E.* sealed trait T open class Y{export E.Z as Q} enum E[+A]derives CanEqual: case Z end E private abstract final class X extends AnyRef...

posted 3y ago by user‭

Answer
66%
+2 −0
Challenges Can you give me half?

JS, 15 bytes !![]/(-~[]-~[]) Basically typed random characters into js console and it worked.

posted 3y ago by ChiefChippy2‭  ·  edited 3y ago by Razetime‭

Answer
66%
+2 −0
Challenges Can you give me half?

Javascript, 5 Distinct characters, 9 Bytes ~[]/~-~[]

posted 3y ago by AkshatJ‭  ·  edited 3y ago by AkshatJ‭

Answer
66%
+2 −0
Challenges Can you give me half?

Japt, 1 byte ½ Test it Jelly, Vyxal, 1 byte . Try it online! Yeah, golf langs still kind of kill this challenge.

posted 3y ago by Quintec‭

Answer
66%
+2 −0
Challenges Can you give me half?

Scala, 15 bytes '#'.toFloat/'F' Try it in Scastie! Characters in Scala kinda get casted to integers. This is usually annoying, but it's useful when golfing. # is 35 and F is 70, and the .toFlo...

posted 3y ago by user‭

Answer
66%
+2 −0
Challenges Can you give me half?

Raku (also Perl polyglot), 5 unique, 13 bytes !()/(!()+!()) () or empty list coerces to its length which is 0 in math operations and !0 is True which coerces to 1

posted 3y ago by Hydrazer‭  ·  edited 3y ago by Hydrazer‭

Answer
66%
+2 −0
Challenges Can you give me half?

Ruby, 10 distinct, 35 chars t=/%/=~%/=%/ o=/%/=~%/==%/ t/o.to_f

posted 3y ago by sampersand‭

Answer
66%
+2 −0
Challenges Can you give me half?

Julia 1.0, 16 bytes (o=one(Int))/-~o Try it online!

posted 3y ago by amz‭  ·  edited 3y ago by amz‭

Answer