Skip to main content
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
Results tagged with
Search options not deleted user 51825

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

10 votes

Convert to camelCase

s->{String[]a=s.replaceAll("`|'","").split("[\\W_]+|(?<=[a-z])(?=[A-Z][a-z])");s="";for(String w:a){String t=w.toLowerCase();s+=a[0]==w? … Call like so: UnaryOperator<String> op = s->{String[]a=s.replaceAll("`|'","").split("[\\W_]+|(?<=[a-z])(?=[A-Z][a-z])");s="";for(String w:a){String t=w.toLowerCase();s+=a[0]==w? …
CAD97's user avatar
  • 1,337
5 votes

Full Width Text

class F{public static void main(String[]a){System.out.print(new java.util.Scanner(System.in).nextLine().replaceAll("(.)", "$0 "));}} class W{public static void main(String[]a){for(char c:a[0].toCharArray …
CAD97's user avatar
  • 1,337
6 votes

Make this code explanation pretty again

=' ')t--;c.add(i+1,s+l.substring(t));l=l.substring(0,t);}c.set(i,l);}} Takes in the format f.accept(List<String> code, String seperator). Formats in-place. … Indented + example usage: static BiConsumer<List<String>, String> prettify = (code, seperator) -> { int space = 0, i=0, t; String line; for (; i<code.size(); i++) { // for each line …
CAD97's user avatar
  • 1,337
3 votes

Divide a string

Rust, 107 bytes fn f(s:&str,n:usize)->(Vec<&str>,&str){let c=s.len()/n;((0..n).map(|i|&s[i*c..i*c+c]).collect(),&s[c*n..])} Try it online! Formatted: fn q129259(s: &str, n: usize) -> (Vec<&str> …
CAD97's user avatar
  • 1,337
2 votes

Creating a falling ball map

n->{String s="";for(;n-->0;){int r=(int)(Math.random()*30);for(int i=0;i<30;){s+=i>r&i<r+6|r>24&i++<=r%25?" … ":"_";}s+="\n\n\n\n";}return s;} Slightly ungolfed: Function<Integer, String> fallingBall = n -> { String s = ""; for (;n-->0;) { int r = (int)(Math.random()*30); for (int i= …
CAD97's user avatar
  • 1,337
0 votes

Decode Baby-talk!

Or, the above code can be prepended with fun main(z:Array<String>)= and compiled normally for a cost of 26 more bytes. Try it online! Indented: readLine()!! …
CAD97's user avatar
  • 1,337
6 votes

The XOROR sequence

(s,n)->{String o=s;for(;n-->=0;){o="";for(int i=0;i<s.length();i++){char c=(char)((i>1?s.charAt(i-1):' ')^s.charAt(i)|(i<s.length()-1?s.charAt(i+1):' '));o+=c>126?' … ':c;}s=o;}return o;} Readable version: static BiFunction<String, Integer, String> f = (s,n)->{ String o=s; for(;n-->=0;) { o = ""; for (int i=0;i<s.length();i++) { …
CAD97's user avatar
  • 1,337
9 votes

Generate a parity bit

e;} This is a lambda for a BiFunction<String, Character, Boolean>. e and o appear to be reversed in the return statement because apparently my logic was backwards. …
CAD97's user avatar
  • 1,337
4 votes

Print the Stack Exchange favicon

The first replace isn't part of the loop because it pulls double duty changing s into a String instead of a &'static str. …
CAD97's user avatar
  • 1,337