New answers tagged

0 votes

Increment base-36 strings

Ruby -p, 39 bytes Port of Dom Hastings’ Perl 5 answer; give them an upvote. ...
Jordan's user avatar
  • 9,834
1 vote

Increment base-36 strings

TypeScript’s type system, 145 bytes ...
noodle man's user avatar
  • 6,280
2 votes

Increment base-36 strings

Perl 5 + -pl, 34 bytes A different approach to @Xcali in their answer. s/[^z]z*$/$&=~y!0-9a-z!1-9a-z0!r/e Try it online! ...
Dom Hastings's user avatar
  • 23.3k
1 vote

"Hello, World!"

Positionally, 121 bytes / / \/ 1 \ / > ^ ^ - < I " "e m s p X!-p mmf / s /\ ;< Try ...
Mukundan314's user avatar
  • 8,464
1 vote

May the first be with you

Swift, 127 247 225 bytes ...
macOSisthebestOS's user avatar
1 vote

May the first be with you

05AB1E, 21 20 bytes „€Û‹›#`UVlY¡XY:Xý¹.Ï Try it online! I could not figure out a way of doing this shorter without using variables, so here we are. I'm sure ...
Matthew Welmers's user avatar
2 votes

May the first be with you

Vyxal r, 21 20 19 18 bytes ⇩1∆o‛°⇩"JḂǓ"ƛ÷V;•F Try it Online! Neat. String compression helps here but honestly the ...
pacman256's user avatar
  • 3,440
2 votes

May the first be with you

Python 3.8 (pre-release), 113 102 bytes -11 bytes thanx to naffetS ...
movatica's user avatar
  • 1,104
0 votes

Split string on first occurrence of each character

Scala 3, 109 bytes _.foldLeft(Seq.empty)((l,c)=>if(l.exists(_.contains(c)))l.dropRight(1):+l.last.appended(c)else l:+c.toString) Attempt This Online!
t9dupuy's user avatar
  • 151
0 votes

Swap letter cases

Scala 3, 52 bytes _.map(c=>if c.isLower then c.toUpper else c.toLower) Attempt This Online!
t9dupuy's user avatar
  • 151
2 votes

Swap letter cases

Labyrinth, 41 bytes " @ ,::4/*_ . _6 " $* %23 326#( _ / %#) Try it online! Labyrinth doesn't have any built-ins related to letter case, and making ...
Bubbler's user avatar
  • 75.2k
0 votes

Swap letter cases

Rattle, 55 bytes |!II^P[gnsF0*32+~,>]`:sF2$F1-~:s<91[1g>64]:s<123[1g>96] Try it Online! By design, Rattle does not have many built-ins to encourage ...
Daniel H.'s user avatar
  • 3,378
0 votes

Split string on first occurrence of each character

Vyxal, 5 bytes ÞUÞṗḢ Try it Online! Þṗ # Partition before ÞU # Uniquity mask Ḣ # Remove leading empty list
emanresu A's user avatar
  • 37.2k
0 votes

"99 Bottles of Beer"

YASEPL, 264 bytes ...
madeforlosers's user avatar
0 votes

Swap letter cases

Brachylog, 8 bytes {ụ?ḷ|ụ}ᵐ Try it online! Explanation We check if a character is invariant by uppercasing, in which case we return the lowercase version, else we ...
Fatalize's user avatar
  • 38.5k
0 votes

Swap letter cases

Pascal, 179 B This is a full program requiring a processor supporting ISO standard 10206 “Extended Pascal” (in particular the ...
Kai Burghardt's user avatar
1 vote

Swap letter cases

Lua, 107 bytes o=""s=io.read()for c in s:gmatch"."do if c==c:lower()then o=o..c:upper()else o=o..c:lower()end end print(o) Try it online! ...
Ed The ''Pro'''s user avatar
4 votes

Swap letter cases

Bash, 11 bytes The ~~ operator in Bash can be used to toggle the case of all characters in a string. echo ${1~~} Try it online!...
vengy's user avatar
  • 1,841
2 votes

Swap letter cases

Japt v2.0a0, 7 bytes r\lÈc^H Try it
Shaggy's user avatar
  • 41.7k
1 vote

One more LUL and I'm out

YASEPL, 161 bytes ...
madeforlosers's user avatar
0 votes

Mowing the Grass

YASEPL, 86 bytes =s=1'=l®1=i=h=c`1!¥i,1}7,"v",2=c`2!}7,"w",3!c+`3!}7,"W",4!c++`4!c}4,h,5!h$c`5!i+}2,l>h and just for fun, ibe, 130 ...
madeforlosers's user avatar
1 vote

Swap letter cases

YASEPL, 99 bytes =f=1'=l®1=i`1=s¥i,1=w$32=j$65=m$91`2!$j»}3,s,4!j+}2,m,2!)s!m}3,123,3+w!j+6!w-64|2`4$j+w»`3!~!i+}2,l explanation: ...
madeforlosers's user avatar
3 votes

Swap letter cases

Haskell + hgl, 16, 12 bytes m$TL?.TU~<iU Attempt This Online! Thanks to Bubbler's comment on a different post for helping me realize how to take 4 bytes off ...
Wheat Wizard's user avatar
  • 97.8k
2 votes

Swap letter cases

Java 10, 64 bytes s->{for(var c:s)System.out.print(c>64&c<91|c>96&c<123?c^=32:c);} Input as a character-array; output is printed directly ...
Kevin Cruijssen's user avatar
1 vote

Compiler for LaTeX

Python 3, 513 bytes ...
Arnold Palmer's user avatar
2 votes

Swap letter cases

Excel, 71 bytes =LET(c,MID(A1,ROW(A:A),1),d,LOWER(c),CONCAT(IF(EXACT(c,d),UPPER(c),d))) Input is in the cell A1. Output is ...
Engineer Toast's user avatar
5 votes

Swap letter cases

Bash + coreutils, 16 bytes Exactly what tr is for. tr A-Za-z a-zA-Z Attempt This Online!
qwr's user avatar
  • 12.1k
1 vote

Swap letter cases

APL+WIN, 42 bytes Prompts for input. Code adjusted to account for difference between APL+WIN atomic vector and that of Dyalog Classic ...
Graham's user avatar
  • 5,916
5 votes

Swap letter cases

V (vim), 2 bytes V~ Try it online!
tsh's user avatar
  • 34.5k
2 votes

Swap letter cases

MathGolf, 7 bytes ô∙!=¿δ! Try it online. Explanation: ...
Kevin Cruijssen's user avatar
1 vote

Swap letter cases

05AB1E (legacy) / 2sable, 1 byte š Try it online in 05AB1E (legacy) or try it online in 2sable. 05AB1E, 2 bytes Try it ...
Kevin Cruijssen's user avatar
4 votes

Swap letter cases

R, 31 bytes \(s)chartr("a-zA-Z","A-Za-z",s) Attempt This Online!
pajonk's user avatar
  • 15.8k
5 votes

Swap letter cases

K (ngn/k), 20 bytes {`c$(_x)-32*~"a{"'x} Try it online! Lowercase the entire string using the builtin _ and then ...
Bubbler's user avatar
  • 75.2k
2 votes

Swap letter cases

Haskell, 64 58 bytes -6 bytes thanks to Bubbler. import Data.Char f s=[last(toUpper:[toLower|c<'a'])c|c<-s] Try it online! I wish there were a more ...
totallyhuman's user avatar
  • 16.8k
2 votes

Swap letter cases

APL (Dyalog APL), 13 12 bytes ⊢⎕C¨⍨¯1*⎕C≠⊢ Attempt This Online! ...
Mukundan314's user avatar
  • 8,464
0 votes

Swap letter cases

Python 3, 12 Bytes s=s.swapcase()
Tinyfold's user avatar
3 votes

Swap letter cases

K (ngn/k), 27 26 24 bytes -1 byte thanks to @akamayu and another -1 thanks to @ngn! ngn/K has a builtin for converting to lower case (_), but none for converting to ...
ovs's user avatar
  • 59k
3 votes

Swap letter cases

Perl 5 -p, 14 bytes s/\pL/$&^$"/ge Try it online!
Xcali's user avatar
  • 14.4k
0 votes

Swap letter cases

Go, 142 bytes ...
bigyihsuan's user avatar
  • 9,208
1 vote

Swap letter cases

Japt v2.0a0, 9 bytes ®c^H*Zè\l Try it ...
noodle man's user avatar
  • 6,280
1 vote

Swap letter cases

PowerShell Core, 42 bytes $args|%{[char]($_-bxor32*($_-in"a".."z"))} Try it online! Takes an array of characters as input Returns an array of ...
Julian's user avatar
  • 2,848
2 votes

Swap letter cases

TypeScript’s type system, 141 bytes 141 bytes with capitalization builtins: ...
noodle man's user avatar
  • 6,280
4 votes

Swap letter cases

J, 16 14 bytes 3!:12"+~'`'&I. NOTE: fails on ATO's older J but works in j9.4.2 -9 thanks to ovs!! -2 thanks to Bubbler for a very nice refinement! The ...
Jonah's user avatar
  • 33.3k
1 vote

Swap letter cases

Charcoal, 10 bytes ⭆S⎇№αι↧ι↥ι Try it online! Link is to verbose version of code. Explanation: ...
Neil's user avatar
  • 169k
1 vote

Swap letter cases

Retina 0.8.2, 7 bytes T`Ll`lL Try it online! Link includes test cases. Explanation: Simply transliterates using the shortcuts for upper and lowercase letter ranges....
Neil's user avatar
  • 169k
0 votes

One more LUL and I'm out

TypeScript's type system, 100 77 bytes type F<N>=`One more ${N extends[1,...infer K]?`"${F<K>}"`:"LUL"} and I'm out` Try it at the ...
noodle man's user avatar
  • 6,280
3 votes

Swap letter cases

Uiua SBCS, 1 byte ¯ Try it on Uiua pad!
chunes's user avatar
  • 23.5k
0 votes

Mowing the Grass

Uiua SBCS, 13 bytes ⬚0/↥⊜/+.◿3-@@ Try it! ...
chunes's user avatar
  • 23.5k
6 votes

Swap letter cases

C (gcc), 40 bytes f(char*s){if(*s^=isalpha(*s)/32)f(s+1);} Try it online! C (gcc), 45 42 bytes ...
Mukundan314's user avatar
  • 8,464
4 votes

Swap letter cases

JavaScript (ES6), 56 bytes -5 thanks to @ngn s=>s.replace(/./g,c=>c[`to${c<{}?'Low':'Upp'}erCase`]()) Try it online! JavaScript (Node.js), 45 bytes -6 ...
Arnauld's user avatar
  • 191k

Top 50 recent answers are included