Quantcast
Channel: Tips for golfing in C - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 67

Answer by Abr001am for Tips for golfing in C

$
0
0

instead of the printf loop

for(i=1;i<12;i++){if(!i%3)printf("\n");printf("%d",i);}

just use

for(i=1;i<12;i++) printf("%c%d",!(i%3)*10,i);

it helps me so much .


@SamHocevar 's answer (shorter by 2bytes)

for(i=1;i<12;i++) printf("\n%d"+!!(i%3),i); 

Credits to @AbhayAravinda for ripping off three more bytes

for(i=1;i++<12;) printf("\n%d"+!!(i%3),i);

The incrementer here works as a part of the inspector.


Viewing all articles
Browse latest Browse all 67

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>