New answers tagged

0 votes

Change the quotations as if in Microsoft Word

C (clang), 81 bytes x,o;f(*s){for(x=o=0;*s=*s-39?s[x=0]:8216+(x||o&&!s[x=1]||o>64&&s[1]>64);o=*s++);} Try it online!
user avatar
  • 2,057
2 votes

Is string X a subsequence of string Y?

Factor + math.combinatorics, 19 bytes [ all-subsets in? ] Try it online!
user avatar
  • 10.8k
1 vote

Determine whether strings are anagrams

Knight, 51 bytes O?C=cB;=iP;=x*'0'256;Wi;=xSx=aAiT+1Gx aT=iSiF1""xCc Try it online! This challenge was made a lot easier because inputs were length 8 ...
user avatar
1 vote

Encode the alphabet cipher

Knight, 45 41 bytes -4 thanks Aiden ;=xP W<1Lx;O++*'0'-2L=a-Ax 96a'\'=xSxF1"" Try it online!
user avatar
1 vote

Negative of an ASCII photo

Regex (PCRE2), 19 bytes s/(#)| /${1:+ :#}/g Try it online! Try it on regex101! This is a single regex substitution, to be applied once. In this explanation, ...
user avatar
  • 9,540
2 votes

Negative of an ASCII photo

MATL, 4 bytes 5\Zc Input is a char matrix containing and #. Try it online! How it works <...
user avatar
  • 100k
2 votes

Divisor of a string

Haskell + hgl, 12 bytes he<<fl lq<pt Attempt This Online! Explanation pt gets all ways to partition the input into ...
user avatar
  • 89.4k
0 votes

Implement String Projection

Scala, 8 bytes _.filter Try it online! This is an expression of type String => Set[Char] => String. It uses the fact ...
user avatar
  • 2,905
1 vote

Covfefify a string

Knight, 161 bytes ...
user avatar
  • 8,966
1 vote

Covfefify a string

Vyxal o, 32 bytes ðp≬k∪$cḊṘ÷Ḣ₴₴h:₴$hJ«ƛKS⟩NĖ!ǐ«ḂĿd Try it Online! Port of Grimmy's 05AB1E answer.
user avatar
  • 8,966
0 votes

Change the quotations as if in Microsoft Word

Retina 0.8.2, 28 bytes (?<=^| )'|\b'(?=') ‘ ' ’ Try it online! Link includes test cases. Explanation: ...
user avatar
  • 146k
0 votes

Change the quotations as if in Microsoft Word

sed, 109 bytes :z;s/'''/''’/g;t z; s/''/‘’/g s/ '(.)/ ‘\1/g s/([a-zA-Z])'([a-zA-Z ])/\1’\2/g s/^'/‘/g s/'$/’/g Try it online!
user avatar
  • 2,790
1 vote

Implement String Projection

Ruby, 29 bytes ->s,a{s.gsub(/./){a[_1]&&_1}} Previous version which had flaws indicated by Deadcode: ...
user avatar
2 votes

Add parentheses to Polish notation

nearley, 78 bytes m->_ p _{%a=>a.flat(1/0)%} p->[\d]:+|[-+/*] _ p _ p{%a=>['(',a,')']%} _->" ":* Post-processing functions for production ...
user avatar
0 votes

Unfolding the Hexagony source code

Knight, 158 152 bytes ...
user avatar
  • 5,623
0 votes

Could you make me a hexagon please?

Knight, 58 57 bytes ;=n+~1P;=i~1W>+1*2n=i+1iO+*' '=xI>=x-n iFx~x*'* '+1-*2n x Try It Online!
user avatar
  • 5,623
1 vote

Implement String Projection

Raku, 22 bytes {$^a.trans($^b=>""):c} Try it online! trans is Raku's beefed-up version of Perl 5's transliteration ...
user avatar
  • 5,676
0 votes

Implement String Projection

GolfScript, 15 bytes ~`{1$?)\''if}+% Try it online!
user avatar
2 votes

Change the quotations as if in Microsoft Word

Retina, 42 bytes '('+) ‘$.1*’ (^| )' $1‘ '($|\w) ’$1 Assumes rule 6 takes prio over the other rules. I have the feeling the first step can be shorter (perhaps with ...
user avatar
0 votes

Implement String Projection

Red, 48 bytes func[a b][foreach x a[if find/case b x[prin x]]] Try it online!
user avatar
  • 10.8k
2 votes

Divisor of a string

Red, 62 bytes func[s][b: s forall s[if(replace/all copy b s"")=""[print s]]] Try it online! The key to this is that ...
user avatar
  • 10.8k
4 votes

Divisor of a string

Nibbles, 5.5 bytes (11 nibbles) |.,,$<$@~%@ ...
user avatar
2 votes

Divisor of a string

Perl -p, 22 bytes /^(.*)\1+$(??{say$1})/ Try it online! This uses a "postponed" regular subexpression embedded code ...
user avatar
  • 9,540
2 votes

Divisor of a string

Zsh, 47 bytes for c (${(s..)1})s+=$c&&[[ $1 = ($s)# ]]&&<<<$s Try it online! Fairly straightforward: ...
user avatar
0 votes

Fill in the Blanks, Please!

PowerShell Core, 46 bytes param($a,$b)-join($a-split'_+'|%{$_ $b[$i++]}) Try it online!
user avatar
  • 1,798
1 vote

Fill in the Blanks, Please!

K (ngn/k), 27 bytes {(*c),/y,'1_c:(~#:')_"_"\x} Try it online! Splitting based on "runs of underscores" seems longer than splitting by single ...
user avatar
  • 64.8k
0 votes

Fill in the Blanks, Please!

Regex (.NET), 46 bytes s/_+(?<=((?=.*?(\2?`([^`]*)))_+.*?)*)|`.*/$3/g Try it on regex101! - .NET Input is taken as the string with blanks followed by the full ...
user avatar
  • 9,540
0 votes

Fill in the Blanks, Please!

Regex (RE2 or better), 23 bytes s/_+(.*?)`([^`]*)/$2$1/ Try it online! - RE2 Try it online! - ECMAScript Try it online! - Perl Try it online! - PCRE2 Try it online!...
user avatar
  • 9,540
1 vote

Find columns where all characters are the same

JavaScript (Node.js), 67 bytes (Anonymous function) a=>[...a[0]].reduce((p,c,i)=>p+(a.every(s=>s[i]==c)?i+c+" ":""),"") Try ...
user avatar
  • 149
2 votes

"Hello, World!"

Carbon, 62 bytes package c api;fn Main()->i32{Print("Hello, World!");return 0;} Try it Online! Thanks to @Steffan for fixing this Carbon is a new ...
user avatar
  • 3,337
3 votes

Divisor of a string

sed -n, 58 46 bytes s/^/\n/ :a /^\(.*\)\n\1*$/P s/\n\(.\)/\1\n/ ta Attempt This Online!
user avatar
  • 1,305
3 votes

Divisor of a string

Charcoal, 15 bytes ΦEθ…θ⊕κ№Eθ×ι⊕μθ Try it online! Link is to verbose version of code. Explanation: ...
user avatar
  • 146k
4 votes

Divisor of a string

Raku, 25 bytes {~«m:ex/^(.+)$0*$/»[0]} Try it online! m/^(.+)$0*$/ looks for patterns of letters which, repeated, comprise the ...
user avatar
  • 5,676
4 votes

Divisor of a string

Ruby, 43 bytes ->s{(s+?␀+s).scan(/(?=(.+)␀\1*$)/).flatten} Try it online! This concatenates the string to itself with a NUL (ASCII 0) character between, in ...
user avatar
  • 9,540
5 votes

Divisor of a string

C# (Visual C# Interactive Compiler), 68, 58 bytes Iterate and replace every substring starting from index 0 and check if it equals an empty string Credit to @Acer for the syntatic sugar ...
user avatar
  • 51
11 votes

Divisor of a string

Python, 53 bytes lambda s,t="":[t for c in s if~-any(s.split(t:=t+c))] Attempt This Online!
user avatar
  • 8,060
4 votes

Divisor of a string

Python 3.8, 56 bytes -7 bytes thanks to user loopy walt lambda s,d='':[d for c in s if len(s)//len(d:=d+c)*d==s] Attempt This ...
user avatar
  • 897
5 votes

Divisor of a string

K (ngn/k), 19 bytes {(x{#,/y\x}/:)_,\x} Try it online! ,\x get all prefixes of the input ...
user avatar
  • 55k
3 votes

Divisor of a string

Husk, 7 bytes fȯEC¹Lḣ Try it online! ...
user avatar
3 votes

Divisor of a string

Rust, 108 106 bytes -2 bytes thanks to alephalpha ...
user avatar
  • 1,625
3 votes

Divisor of a string

Retina 0.8.2, 17 bytes &!`(.+)$(?<=^\1+) Try it online! Link includes test cases. Explanation: &!` List all ...
user avatar
  • 146k
7 votes

Divisor of a string

05AB1E, 6 5 bytes ηʒKõQ Try it online or verify all test cases. Explanation: ...
user avatar
5 votes

Divisor of a string

Ruby, 53 52 bytes ->s{(1..k=s.size).map{|x|w=s[0,x];w*k==s*x ?w:s}|[]} Try it online!
user avatar
  • 18.2k
6 votes

Divisor of a string

K (ngn/k), 26 bytes {((#(,x)^,\(#x)#,:)')_,\x} Try it online! I guess this is somewhat a new strategy. For each prefix, tests if the original input appears in the ...
user avatar
  • 64.8k
6 votes

Divisor of a string

J, 19 bytes <\#~<=<\$~&.>#+#\|# Try it online! <\$~ Cyclically extend each prefix to the following length: ...
user avatar
  • 28.5k
4 votes

Divisor of a string

Knight, 32 bytes ;=x=yP Wx;I?y*x/LyLxOxN=xGxF-LxT Try it online! ...
user avatar
  • 8,966
6 votes

Divisor of a string

Haskell, 42 bytes f s|p<-scanr(:)""s=[t|t<-p,a<-p,(a*>t)==s] Try it online! scanr(:)""s lists ...
user avatar
  • 138k
7 votes

Divisor of a string

Factor + grouping.extras, 73 70 57 48 bytes [ dup head-clump [ ""replace ""= ] with filter ] Attempt This ...
user avatar
  • 10.8k
5 votes

Divisor of a string

Python, 65 63 bytes lambda s:[s[:i]for i in range(1,len(s)+1)if len(s)//i*s[:i]==s] Attempt This Online! A very unclever solution. Saved -2 bytes from @ruancornelli.
user avatar
  • 1,413
4 votes

Divisor of a string

Haskell, 65 bytes d s|r<-[1..length s]=[z|z<-(`take`s)<$>r,s`elem`[[1..n]>>z|n<-r]] Try it online!
user avatar
  • 451

Top 50 recent answers are included