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 |
A competition to solve a particular problem through the usage and manipulation of strings.
1
vote
Don't google "google"
/^google$/}}
Call with g(string), print with print g(string).
How it works
The ternary operator only evaluates the expression if the condition is met. … So when the input isn't google, it simply returns the original string and passes it on to length. …
3
votes
Mixing characters in a string
Python 3 - 161 149
import sys
t=sys.stdin.read().split()
q=list(t[0])
c=1
i=int
while c<len(t):n=q;a=i(t[c]);b=i(t[c+1]);n[a]=q[b];n[b]=q[a];q=n;c+=2;
print(''.join(q))
Golfed more by swapping ar …
4
votes
CodeGolf - Barry the messy developer #2
Perl, 77 73 bytes
while(<>){@p=split",";print($p[0]<$p[1]and$p[2]=~/D/?"STOP":"WAIT")."\n"}
Here's how it works:
while(<>) parses every line.
@p=split"," splits it by every comma. It's using th …
2
votes
Count the number of vowels in each word of a string
Perl, 60 45
$/=" ";while(<>){$n=()=/[aeiou]/gi;print"$n "
Thanks to kirbyfan64sos for saving me 15 bytes - that really helped!
Note there's an extra space at the end of the output.
1
vote
Difference should make no difference
Perl, 93556
chomp($A=<>);$AAA=$AAAA=0;foreach$AAAAA(split'',$A){$AA=ord($AAAAA);$AAA+=($AAAA-$AA)**2 if($AAAA!=0);$AAAA=$AA}print'#Perl, '.$AAA
I'll try to cut this down some more.
It turns out that …
1
vote
"Hello, World!"
Perl 6, 18 bytes
say"Hello, World!"
I'm pretty sure this is as short as you can get, please let me know if there's any improvements that can be made.
4
votes
1, 2, Fizz, 4, Buzz
Perl 5, 109 93 bytes
for$i(1..100){if($i%3<1){say"Fizz"};if($i%5<1){say"Buzz"};if($i%3>0&&$i%5>0){say$i};say"\n";}
There might be some more golfing potential here.
Takes advantage the fact that 0 is …