New answers tagged

0 votes

Split string on first occurrence of each character

Perl 5 + -pl, 22 bytes s@.@$/x!$h{$&}++.$&@ge Try it online!
Dom Hastings's user avatar
  • 23.2k
0 votes

Split string on first occurrence of each character

Uiua SBCS, 6 bytes ⊜□\+◰. Try it! ⊜□\+◰. . # duplicate ◰ # mark firsts \+ # cumulative sum ⊜□ # split
chunes's user avatar
  • 23.4k
0 votes

Complete a sequence using its distances

Uiua SBCS, 14 bytes ⍥(◴⊂:⌵↘1°\+.)∞ Try it! ...
chunes's user avatar
  • 23.4k
0 votes

Strings without twin letters

Nekomata, 4 bytes ŧĉᵐz Attempt This Online! ...
alephalpha's user avatar
  • 47.5k
1 vote

Enumerate the Phat-fingered-lights-out numbers

Scala 3, 212 bytes A port of @Arnold Palmer's Python answer in Scala. Golfed version. Attempt This Online! ...
138 Aspen's user avatar
  • 5,331
0 votes

Trim elements from the ends of a list

Perl 5 -a, 59 bytes $_=<>;for$i(0,-1){splice@F,$i,1while/(^| )$F[$i]\b/}say"@F" Try it online!
Xcali's user avatar
  • 14.2k
0 votes

Trim elements from the ends of a list

BQN, 16 bytes (⌽(∨`·∧˝≠⌜)/⊢)⍟2 Takes the list as its right argument and the elements to trim as its left argument. Try it at BQN online! Explanation ...
DLosc's user avatar
  • 38.4k
0 votes

Program ordinals and omega squared

Self-modifying Brainfuck, 47 bytes -[[<]>[>.]+0]<[<]>-[+[>]<-[<]<[[<]+[>.]<]]>[.>] The ...
2014MELO03's user avatar
1 vote

3D Hide & Seek Word Puzzle

JavaScript, 249 bytes ...
Matthew Jensen's user avatar
1 vote

Strings without twin letters

jq, 67 bytes def f($n):combinations($n)|join("")|select(test("(.)\\1";"x")|not); Try it online! Defines a function ...
GammaFunction's user avatar
1 vote

What and where is the max?

Ruby, 55 bytes ->a{b=a.flatten [m=b.max,b.index(m).divmod(a[0].size)]} Attempt This Online!
Jordan's user avatar
  • 9,814
0 votes

BalancE the UppercasE

Uiua SBCS, 19 bytes ⍜⊜□⍚(⍜▽⌵↥⇌.=1±.)⌵±. Try it! ...
chunes's user avatar
  • 23.4k
0 votes

Trim elements from the ends of a list

Uiua SBCS, 11 bytes ▽¬↥⇌∩\×⇌.∊, Try it!
chunes's user avatar
  • 23.4k
1 vote

Calculate Home Primes

Uiua SBCS, 13 bytes ⍥(⋕/◇⊂°⋕°/×)∞ Try it! ...
chunes's user avatar
  • 23.4k
0 votes

The Programming Language Quiz, Mark II - Cops

???, 37 bytes print foreach n in range(100), n * 1; Output separated by newlines, preceded by a line containing 100.
noodle man's user avatar
  • 6,121
2 votes

Strings without twin letters

Perl 5 -nl, 30 bytes map!/(.)\1/&&say,glob"{$_}"x<> Try it online!
Xcali's user avatar
  • 14.2k
1 vote

Enumerate the Phat-fingered-lights-out numbers

C (gcc), 107 bytes b[2],i,c,k;f(n){k=c=0;while(k^n){b[0]=b[1]=i=0;while(i<32)b[i%2]+=(c>>i++)&1;if(b[0]==b[1])k++;c++;}n=c-1;} Try it online! Uses a ...
Arnold Palmer's user avatar
0 votes

Reconstruct Matrix from its diagonals

Vyxal, 2 bytes Þ„ Try it Online! So apparently lyxal forgot there was a built in for this :p
pacman256's user avatar
  • 3,300
1 vote

Strings without twin letters

Perl 5 + -lF -M5.10.0, 40 bytes !/[^@F]|(.)\1/&&say for A x($;=<>)..Z x$ Try it online!
Dom Hastings's user avatar
  • 23.2k
1 vote

Explicit-ify APL expressions involving trains

Tamsin, 348 bytes ...
Mukundan314's user avatar
  • 8,124
1 vote

Strings without twin letters

Scala 3, 128 bytes A Port of @Arnold Palmer's Python answer in Scala. Golfed version. Attempt This Online! ...
138 Aspen's user avatar
  • 5,331
3 votes

Strings without twin letters

K (ngn/k), 22 21 bytes: -1 byte due to @ovs. {(+j)@&~|/=':j:!y#,x} Try it online
akamayu's user avatar
  • 51
2 votes

Strings without twin letters

05AB1E, 5 bytes ãʒüÊP Inputs in the order \$n,L\$. Try it online or verify all test cases. Or alternatively: ãʒDÔQ Try it ...
Kevin Cruijssen's user avatar
2 votes

Strings without twin letters

R, 70 bytes \(L,n,x=combn(rep(L,n+1),n))unique(x[,apply(x,2,\(a)all(diff(a)))],,2) Attempt This Online! Uses a rather loose definition of string - a vector of ...
pajonk's user avatar
  • 15.6k
1 vote

Remove first encountered elements from a second list

Uiua SBCS, 3 bytes ▽¬◰ Try it!
chunes's user avatar
  • 23.4k
2 votes

Strings without twin letters

Retina, 41 bytes "$&"+%Lw$`,.*(.) $`$1$&$' \d|,.+ A`(.)\1 Try it online! Link includes test cases. Takes comma-separated input. Explanation: <...
Neil's user avatar
  • 169k
9 votes

Strings without twin letters

Husk, 4 bytes fΛ≠π Try it online! Short and straightforward solution, the MVP here is Λ, thanks to its overload that can take a ...
Leo's user avatar
  • 12.6k
2 votes

Strings without twin letters

Brachylog, 13 10 bytes -3 bytes inspired by a suggestion from Fatalize gʰj₎∋ᵐ.ẹ~ḅ Generator solution. Takes input as a list containing a string and an integer. ...
DLosc's user avatar
  • 38.4k
3 votes

Strings without twin letters

Jelly, 6 bytes ṗnƝẠ$Ƈ A dyadic Link that accepts the alphabet on the left and the word length on the right and yields a list of valid words. Try it online! How? <...
Jonathan Allan's user avatar
6 votes

Strings without twin letters

Ruby, 42 bytes ->l,n{(?A*n..?Z*n).grep_v /[^#{l}]|(.)\1/} Attempt This Online! Input in uppercase. Start with a list of all \$n\$-letter strings, then remove ...
Dingus's user avatar
  • 11.1k
2 votes

Enumerate the Phat-fingered-lights-out numbers

Python 3, 107 bytes f=lambda n,i=0,l=[]:i-1if n==sum(l)else f(n,i+1,l+[a(i,2)==a(i,3)]) a=lambda n,s:sum(map(int,bin(n)[s::2])) Try it online! Uses the same logic ...
Arnold Palmer's user avatar
3 votes

Strings without twin letters

C (gcc), 168 160 bytes -8 Thanks to corvus_192 for pointing out newline separation between values was allowed ...
Arnold Palmer's user avatar
5 votes

Strings without twin letters

Vyxal, 5 bytes ↔'ÞǓ⁼ Try it Online! generates all combinations of length n using the characters in the input string, then filters by those which are equal to the ...
pacman256's user avatar
  • 3,300
4 votes

Strings without twin letters

MATL, 9 bytes Z^t!dXAY) Try it online! Explanation ...
Luis Mendo's user avatar
  • 104k
2 votes

Strings without twin letters

Charcoal, 20 bytes ⊞υωFN≔ΣEηEΦυ⌕μκ⁺κμυυ Attempt This Online! Link is to verbose version of code. Explanation: ⊞υω Start with ...
Neil's user avatar
  • 169k
1 vote

Minimal cost path in wall-breaking maze

Python3, 378 bytes ...
Ajax1234's user avatar
  • 6,893
3 votes

Strings without twin letters

Python 3, 74 67 64 bytes -7 thanks to @Albert.Lang, -3 thanks to @Mukundan314 f=lambda l,n:[""][n:]or[c+w for w in f(l,n-1)for c in{*l}-{*w[:1]}] Try it ...
Arnold Palmer's user avatar
1 vote

The Programming Language Quiz, Mark II - Cops

???, 70 bytes >1+v< / > \ (!_++)t(!_++^!# @!d_+) / v""<> / > ^>^ ~~<^\=~~
Fmbalbuena's user avatar
  • 3,831
8 votes

Strings without twin letters

Google Sheets, 127 113 bytes =sort(let(L,torow(A:A,1),s,reduce(,sequence(B1),lambda(a,_,tocol(a&L))),filter(s,1-regexmatch(s,join("|",L&L))))) ...
doubleunary's user avatar
  • 1,388
3 votes

Strings without twin letters

Excel ms365, 122 bytes Assuming: \$L\$ - Given input in the first row 1:1 starting from A1 onwards; \$n\$ - Given integer in <...
JvdV's user avatar
  • 3,613
3 votes

Compute the phat-fingered double-bit-flip distance

Python3, 56 bytes p=lambda a,b,c=0:abs(c)+(a^b and p(b//2,a//2,c+a%2-b%2)) Thanks to @loopy walt for an elegant way to remove the mask completely by alternating ...
Vincent's user avatar
  • 31
1 vote

The shortest way to find one unique value when all other values are the same

HBL, 13.5 bytes -(+(1(%.))('1(%.)))(1(21(%. Try it! Port of Arnauld's answer.
Fmbalbuena's user avatar
  • 3,831
3 votes

Strings without twin letters

Uiua SBCS, 23 21 20 bytes ▽≡(/×≡/≠◫2).⊏☇1⇡▽:⧻, Try it! ...
chunes's user avatar
  • 23.4k
0 votes

Panfix to parenthesized infix

Tamsin, 135 bytes ...
Mukundan314's user avatar
  • 8,124
3 votes

Strings without twin letters

APL+WIN, 42 bytes Prompts for string followed by n: n←m←⎕⋄⍎∊(⎕-1)⍴⊂'n←n∘.,m⋄'⋄(0=+/¨2=/¨,n)/,n Try it online! Thanks to Dyalog Classic
Graham's user avatar
  • 5,846
6 votes

Strings without twin letters

Haskell, 49 47 bytes l#1=pure<$>l l#n=[c:a:r|a:r<-l#(n-1),c<-l,a/=c] Try it online! Edit: Thanks to @xnor for taking off two bytes! I didn't know you ...
colossus16's user avatar
  • 1,851
3 votes

Strings without twin letters

JavaScript (ES10), 54 bytes Expects (a)(n), where a is an array of characters. Returns an array of strings. ...
Arnauld's user avatar
  • 191k
0 votes

Make an alphabet searchlight!

Vyxal 3 j, 7 bytes kZ€ƛd«Ḣ Try it Online! ...
pacman256's user avatar
  • 3,300
2 votes

What and where is the max?

Python 3.8 (pre-release), 66 bytes Vanilla Python approach, outgolfed by the numpy versions. ...
movatica's user avatar
  • 1,025
1 vote

Enumerate the Phat-fingered-lights-out numbers

05AB1E, 7 bytes ∞<ʒb®ö_ Outputs a lazy infinite list. Try it online. Or: [Nb®ö_– Infinitely outputs all results on a ...
Kevin Cruijssen's user avatar

Top 50 recent answers are included