23

bash, 14 bytes iconv -fCP1252 Try it online!


20

Java 8, 72 66 36 25 bytes s->new String(s,"cp1252") Try it online. s-> // Method with byte-array (UTF-8 by default) as parameter and String return-type new String(s,"cp1252") // Pretend this UTF-8 input is (and convert it to) Windows-1252, // and return it as UTF-8 String (by default) as well cp1252 is an alias for ...


17

JavaScript (ES6), 130 102 bytes Takes input as an array of strings in "Rs" format, where R is the rank and s is the suit. Expects "T" for 10's. Aces are low. a=>(s='A23456789TJQK')[([[R,[,S]],B,C,D]=a.map(c=>[s.search(c[0])+14,c]),R+=D<C|2*((D<B)+(C<B)))%13]+S Try it online! How? We first convert each card into an array [...


17

JavaScript (ES6),  103  100 bytes See also my other answer for less bitwise operations, more maths, and a closed-form expression Both functions expect and return an integer. 8-bit → 12-bit ( 56  53 bytes) f=n=>n&&(w=f(n-1),w+=(x=w&w-1)&x-1?w-x:1)+(w&w/2&w/4) Try it online! How? This is a recursive function that computes the next ...


16

Python 2,  40  39 bytes -1 thanks to kops! (Multiply before integer division) lambda a:[chr(r*16/3+c+59)for r,c in a] An unnamed function accepting an iterable of pairs which returns a list of characters. Try it online!


15

Python 2, 143 140 138 136 127 125 124 123 121 bytes lambda(S,V),*l:S+N[F(V)+int(`map(sorted(l,key=lambda(s,v):(F(v),s)).index,l)`[1::3],3)*3/10] N='23456789TJQKA'*2;F=N.find Try it online! Aces are high Encodes the three cards by finding their position in a sorted list of the cards (0=smallest, 1=middle, 2=largest): cards: [SK, C4, H4] sorted: [C4, ...


13

Ruby class Dakota PRIVATE_KEY = 8411088 def self.encrypt(str) str.gsub(/[A-Z]/){|c|"0#{c.downcase}"}.gsub(/[a-z]+/){|s|xor(s.to_i(36),$')} end def self.decrypt(str) str.gsub(/\d+/){|s|out = s.to_i.to_s(36);out[0] = out[0].upcase if s[0]==?0; out} end def self.xor(n, config) n^=PRIVATE_KEY if private_env?(config) n end ...


13

Gema, 17 characters [#]?=@repeat{?;#} Sample run: bash-4.4$ gema '[#]?=@repeat{?;#}' <<< '[three[two[one]1]2]3' threetwoonetwoonethreetwoonetwoonethreetwoonetwoone


12

CJam, 18 bytes UXri{_@+}*;26b'af+ Try it online in the CJam interpreter. How it works UX e# Push 0 and 1. ri{ e# Read an integer and execute the loop that many times. _ e# Push a copy the topmost integer. @ e# Rotate the bottom-most integer on top of the stack. + e# Pop the two topmost integers and push their sum. }* e# ; e# ...


12

Jelly, (17 bytes + 18 bytes) × length 6 = 210 points b36µỤỤ+×3µŒ¿b3U+Ṣ Ṣ:3_J Ṣ%3Uḅ3œ?Çḅ36 Try it online! (or with extra debug info) Having had a go at solving this challenge aiming at the stated victory condition, I thought it'd be interesting to go for a hypothetical alternative victory condition: code-golf given a minimum possible maximum length for ...


11

convey, 31 25 bytes Takes JK as 01. >="*>0 ",v+<"(6 {0>">>!`} Try it online! Compares = the string with itself with a J prepended ,0. The middle loop just adds the comparisons to a counter (starting with 0) that gets reset on a 0. Only take ! elements where the previous counter was less than 6 (6.


10

Jelly, 33 bytes ØDḊḊ;“TJQKA”p“CDHS” ¢iⱮµḊŒ¿×4+Ḣị¢ Try it online! Explanation The first line is niladic. It yields a list of the 52 cards ØDḊḊ;“TJQKA”p“CDHS” ØD Digits: '0123456789' ḊḊ Dequeue twice: '23456789' ; Append with... “TJQKA” ...the string 'TJQKA': '23456789TJQKA'. These are ...


10

JavaScript (ES6), 26 bytes Takes input in little Endian. n=>'0958634172'[n*3%77%10] Try it online!


9

R 3.5.0 or higher, 32 20 bytes scan(,"",e="latin1") Try it online! Oddly short for a string challenge in R... thanks to JayCe for golfing down 12 more bytes! scan optionally takes an encoding argument to set the encoding of the input string. latin1 corresponds to, according to the documentation of Encoding There is some ambiguity as to what is meant ...


9

Jelly, (4 3 bytes + 6 5 bytes) × length 8 = 80 64 points b⁴ÄṢŻIḅ⁴ Try it online! Jelly, (2 1 byte + 4 3 bytes) × length 10 = 60 40 points ÄṢŻI Try it online! Explanation Solution 1 This is using a different algorithm from most of the other answers. We start by encoding the value in hexadecimal (b⁴), as with the other answers, then take a cumulative ...


9

convey, 66 bytes 1<<<<,<< />>>v$1^ ,<"<##<^ :`#?@#^^ {1$v>"}%2 ~,>/+?< 3 0$,>*2 Try it online! Explanation will follow after I tried some other orientations …


9

J, 22 bytes 65(u:@+>&74)@+[:5&#.<: Try it online! [:5&#.<: Decrement each input value <: and interpret every resulting 2-element pair as a base 5 number 5&#.. 65...@+ Add 65 to each (to make it an ascii value), and... u:@+>&74 Add 1 more to each number greater than 74 +>&74 to adjust for the missing K. Finally, ...


8

CJam This is the encoder: 232375064392749269032321519657657089927649992440902190178063558812627752920796248165803740235420850037801568815744960725761679066919872746899310628404239458 128b:c~ and this is the decoder: ...


8

TeaScript, 34 bytes 37 51 54 TeaScript is JavaScript for golfing. It also brings ES2015 features to the average browser. F(x)b(26)l(#C(lc()+(l<'a'?49:10))) Try it online Explanation // x is the input F(x) // Fibonacci from input .b(26) // To Base-26 string but with 0-9, a-p // instead of a-z, to fix this... .l(# ...


8

Retina, 24 23 22 bytes +`\[([^][]*)](.) $2*$1 Try it online! This is practically a builtin in Retina 1. Edit: Saved 1 byte thanks to @Kobi. 47 45 bytes in Retina 0.8.2: ]. ]$&$*¶ {+`\[([^][]*)]¶ $1[$1] \[([^][]*)] Try it online!


8

05AB1E, 13 bytes Encoder, 8 bytes 0ì¥ĀηOØP Try it online! Explanation 0ì # prepend 0 to input ¥ # calculate deltas Ā # truthify each η # calculate prefixes O # sum each Ø # get the prime at that index P # product Decoder, 5 bytes Ò.ØÉJ Try it online! Explanation Ò # get ...


8

Python 3, 18 bytes b'~0my3[_p{'.find Try it online! Uses little-endian inputs. Contains a raw \x7F byte. Python 2, 27 bytes map(ord,'~0my3[_p{').index Try it online!


8

Jelly, 10 bytes ØAḟ”Ks5⁸œị Try it online! -1 byte thanks to Jonathan Allan! How it works ØAḟ”Ks5⁸œị - Main link. Takes a list of pairs P on the left ØA - Yield the uppercase alphabet ḟ”K - Filter out "K" s5 - Split into a 5x5 matrix, S ⁸ - Yield P œị - For each pair [A, B] in P, get the B'th ...


8

Jelly, 10 bytes ḅ5<⁴ạƊ+60Ọ Try it online! A completely different approach. Explanation ḅ5<⁴ạƊ+60Ọ Main monadic link All following operations are automatically vectorized. ḅ5 Convert from base 5 ạƊ Absolute difference with <⁴ 1 if it's less than 16, else 0 +60 Add 60 Ọ Convert to ...


8

brainfuck, 85 bytes ,[>++++++++[<------>-],<[>+++++>>[>]+[<]<<-]>+++++++++++>>>>[<<<<+>>>>-]<<<<.>>>>>>,] Try it online! Explanation , Read a character [ While not at the end of input >++++++++[<------>-] Subtract 48 to get the actual number ...


7

Java I discovered that division by zero does not cause errors in this program. This program fully encodes the Strings into a form that cannot be traced to the North Dakotan government. Due to the strange behaviour mentioned above, encoding and decoding might not work correctly in all cases. class Program{ public static void main(String[] args){ ...


7

Pyth, 98 97 95 93 90 83 80 bytes The code contains unprintable characters, so here is a reversible xxd hexdump: 00000000: 753f 7133 4a69 4832 5047 2b47 3f3c 334a u?q3JiH2PG+G?<3J 00000010: 4040 6332 2e22 275a 75ae 5751 fb4e 3cd7 @@c2."'Zu.WQ.N<. 00000020: 02ce 8719 aac1 e0e0 fe1f 09e5 85bc a767 ...............g 00000030: 8e0c 1f47 508a cad1 ...


7

Haskell, 101 96 bytes fst.(""%) infix 4% s%']':d:r=(['1'..d]>>s,r) s%'[':r|(t,q)<-""%r=s++t%q s%x:r=s++[x]%r s%e=(s,e) Try it online! Instead of using regular expression like most of the other answers, this implements a recursive parser. -5 bytes thanks to BMO!


7

Perl 5, 34 33 29 + 1 (-p) = 30 bytes s/.([^[]*?)](.)/$1x$2/e&&redo Try it online! Cut it down with some help from @Shaggy and @TonHospel.


7

Jelly, 17 bytes Encoder (10 bytes): 0;IA+\‘ÆNP Try it online! Decoder (7 bytes): ÆEĖŒṙḂ¬ Try it online! How? Encoder: 0;IA+\‘ÆNP - Link: list of integers (1s and 0s) e.g. [1,1,1,1,0] 0; - prepend a zero [0,1,1,1,1,0] I - incremental differences [1,0,0,0,-1] A - absolute values ...


Only top voted, non community-wiki answers of a minimum length are eligible