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
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
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
Results tagged with Search options user 60553

A competition to solve a particular problem through the usage and manipulation of strings.

2
votes
Ruby, 54 bytes ->w{c=w.chars.uniq;c==(s=c.sort)?2:(c==s.reverse)?1:0} Returns 0 if the word is not wavy, 1 if backwards wavy, and 2 if forwards wavy.
answered Oct 28 '16 by Lee W
1
vote
Ruby, 123 117 111 102 bytes ->s{s.gsub(/ .|^./,&:upcase).gsub(/ (A[nts]?|The|By|In|To|Up|And|But|[NF]or|O[rnf])(?= )/,&:downcase)} Sorry for all the edits - this should be the last one.
answered Oct 28 '16 by Lee W
1
vote
Ruby, 28 bytes ->s{puts s.sub(/\d+/,"\n\\&\n")} This surrounds the first cluster of digits with newlines.
answered Nov 8 '16 by Lee W
1
vote
Ruby, 41 30 (+1) bytes p gsub(/./){$&.ord%2}!~/(.)\1/ Call this from the command line with the -n flag, like so: ruby -ne 'p gsub(/./){$&.ord%2}!~/(.)\1/' Replaces each character with the parity …
answered Oct 13 '16 by Lee W
1
vote
Ruby, 38 bytes ->s,n{s[0]==s[-1]?s[0..-2]*n+s[0]:s*n} I think this is pretty self-explanatory. I'm still wondering if there's a more concise way to represent the s[0..-2] block, but I haven't found …
answered Oct 11 '16 by Lee W
0
votes
Ruby, 51 bytes ->s{puts s.chars.permutation.map(&:join).uniq.sort}
answered Nov 16 '16 by Lee W
0
votes
Ruby, 30 bytes ->w{w.count('aeiouAEIOU')%2>0} Returns true for an odd word and false for an even word. The existing Ruby solution returns 0 for even words, which is a truthy value in Ruby.
answered Oct 12 '16 by Lee W
2
votes
Ruby, 39 characters ->s{a,*b,c=s.chars;[a,*b.shuffle,c]*''}
answered Nov 10 '16 by Lee W
2
votes
Ruby, 39 bytes ->n{puts a=?#*n,[?#+' '*(n-=2)+?#]*n,a} Turns out to be shorter this way than all the fancy stuff I was trying. Be advised that this doesn't handle 0 or 1 at all.
answered Nov 7 '16 by Lee W
2
votes
Ruby, 13 (+1) bytes p $_.count ?[ Called with -n argument: ruby -ne 'p $_.count ?[' EDIT: Changed to actually print out the answer
answered Nov 10 '16 by Lee W