Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
1
vote
Ratio of Uppercase Letters to Lowercase
Javascript 80 characters
I'm bad at this but here was my go at Javascript:
a=(s)=>{let a=0,b=0;for(c in s)s[c]==s[c].toUpperCase()?a++:b++;return a/(a+b);}
Readable version:
a=(s)=>{
let a=0, …
0
votes
AlTeRnAtE tHe CaSe
Javascript, 104 bytes
I'm kind of new to this but wanted to submit anyway.
x=>x.split('').forEach((s,i)=>x+=i%2?s.toUpperCase():s.toLowerCase())||x.substring(x.length/2,x.length);
It takes in a str …
4
votes
18
answers
1k
views
Convert RGB color to websafe
Web safe colors are in intervals of 51, they include 0, 3, 6, 9, c, and, f as digits in hex (such as #993333), or 0, 51, 102, 153, 204, 255 in decimal. Your task today is convert a given color to a we …
1
vote
Build a checkerboard
Javascript (89 bytes):
for(x=y=0,r="r";x<7|y<8;console.log(x+","+y+r),y+=2){if(y>7)y=++x%2;if(x==3){x+=2;r="b"}}
Readable:
for(var x = y = 0, red = true; x < 7 || y < 8; y += 2) {
if(y > 7) { //n …
20
votes
22
answers
2k
views
Build a checkerboard
For this challenge you will print the coordinates and color of each piece at the start of a game of checkers.
Enter the x and y (comma seperated) for every square (indexed 0-7) on a checkerboard, fo …
2
votes
Greatest Common Divisor
Java, 38 bytes
f=(int a,b)->{return b==0?a:f(b,a%b);}