New answers tagged

1

Kotlin, 27 bytes s2.filter{it !in s1}.none() Try it online!


1

Kotlin, 35 bytes ('a'..'z').all{s.contains(it,true)} Try it online!


0

Burlesque, 16 bytes zzXX@azr@Jx/IN=s Try it online! [IN] zz # Lowercase input [in] XX # Split into characters [i,n] @azr@ # Push lowercase alphabet [i,n],[a,..,z] Jx/ # Duplicate and bring the input to the top [a,..,z],[a,..,z],[i,n] IN ...


0

Dyalog APL, 13 bytes ∧/⎕A∊1(819⌶)⊢ explanation: 1(819⌶)⊢ ⍝ uppercase ⎕A∊ ⍝ check if all uppercase letters belong to the string ∧/ ⍝ AND reduction of the boolean vector


1

GolfScript, 18 bytes Port of the GS2 answer. {32|}%[123,97>]\-! Try it online! Explanation { }% # Map for every item in input 32| # Toggle the 6th bit (turning capitalization on) [123, # Generate exclusive range from '}' (previous 'z') to 0 97>] # Select all that are >= 'a' ...


0

GolfScript, 20 bytes .,2//zip{"ab"=}%{&}* Try it online!


1

C# (Visual C# Interactive Compiler), 535 bytes a=>b=>{int y=0,e=a.Length,k=0,o,q;var z=new int[e];for(;k<e;k++)if(a[k]<41){for(o=q=1;o>0;q++)o+=a[q+k]<41?1:a[q+k]==41?-1:0;q--;z[k+q]=k+1;z[k]=k+q+2;}void t(string s,int j){for(;j<e;){var l=a[j++];var w=j<e&&a[j]==42;if(j>1&&a[j-2]<41)for(int r=j,d=0;r<z[j-2]-1;...


0

TI-BASIC, 13 bytes sum(Ans=seq(X!,X,1,69 Input is an integer in Ans. Output is 1 if the input is a factorial, 0 if not. Due to precision in = checks being limited to 10 decimal places, this program will produce erroneous answers for numbers whose length is \$>10\$ digits. Explanation: seq(X!,X,1,69 ;generate a list of all factorial numbers ...


1

PowerShell, 24 bytes !("$args"[0,-1]|gu).Rank Try it online!


0

Burlesque, 6 bytes l_-]== Try it online! l_ # Non-destructive tail, leaving the rest of the string on top of the stack -] # Destructive head == # Equal


0

05AB1E, 8 bytes H8(вÆü‹P Try it online! or validate all test cases. Input is a list of hex digits. Output is 1 for truthy, 0 for falsy. H # convert from hex 8(в # convert to base -8 Æ # reduce by subtraction ü‹ # pairwise less-than P # product


0

Fortran (GFortran), 57 bytes read*,i k=1 do j=1,i k=k*j if(i==k)l=1 enddo print*,l end Try it online! On some compilers may result in gibberish on false-y due to uninitialised l. Can be solved with 3 bytes (l=0) or compiler flags (e.g. -finit-integer=0). Strictly 1 is not a truthy in Fortran, but spec specified 1/0 for true/false.


0

Burlesque, 13 bytes riJro?!jFi0>= Try it online! If you accept -1 as falsey (technically isn't in burlesque) and >0 as truthy can save 3 bytes. riJ # Read as int and duplicate on stack ro # Range from [1,N] ?! # Factorial each jFi # Find the index of the element == N 0>= # Found index


0

GolfScript, 17 bytes ~.),{,1\{)*}/}%?) Try it online! Explanation ~ # Evaluate the input . # Duplicate the value ) # Increment the value , # Generate range from 1 to input { }% # Map every item , # Generate a to-0 range 1\ # Make the initial ...


0

GolfScript, 7 bytes )\(@=\; Try it online! Explanation ) # The last character \( # And the first character @=\; # Are they equal


1

Perl 6, 33 bytes <dd "<$_>~~.EVAL"eq slurp>~~.EVAL Try it online! Outputs either Bool::True or Bool::False to STDERR. This is the basic quine format, with an added check against input (eq slurp).


1

Keg, 36 28 26 bytes `:&\`ⁿ^\`ⁿ&⅀=`:&\`ⁿ^\`ⁿ&⅀= Try it online! Same concept as before, but shorter. Answer History `:&\`ⁿ⅍^\`ⁿ⅍++&+¿=`:&\`ⁿ⅍^\`ⁿ⅍++&+¿= Try it online! Who knew generating a program that knows itself would be so unreadable! Explained The very first step here is to generate the string that will be ...


2

APL (Dyalog Unicode), 17 11 bytesSBCS -6 bytes thanks to Bubbler outputs 1 if tangential, 0 if not 0=-/|2-/5⍴⎕ Try it online! Explanation: 0=-/|2-/5⍴⎕ ⎕ take 4 complex numbers as evaluated input 5⍴ reshape to 5 2-/ difference between each pair of numbers | absolute value -/ alternating sum 0= ...


2

Burlesque, 11 bytes =[{L[2dv}al Try it online! =[ # Group consecutive like values { L[ # Length of (group) 2dv # Divisible by 2 }al # All


1

GolfScript, 7 bytes 2/zip~= Try it online! Explanation 2/ # Split input into parts of 2, e.g. tt,ee,ss,tt zip # Read the list horizontally, yielding test, test ~ # Put the two strings onto the stack, yielding test,test = # Check whether they are equal, yielding 1 # False case: # tteesst #->tt,ee,ss,t #-&...


2

naz, 50 bytes 2a2x1v1x1f1r3x1v2e2x2v1r3x2v1e0m1o0x1x2f0m1a1o0x1f Works for any input string, provided it's passed as a file terminated with the control character STX (U+0002). Explanation (with 0x commands removed) 2a2x1v # Set variable 1 equal to 2 1x1f1r3x1v2e # Function 1 # Read a byte ...


2

APL, 9 chars/bytes 2≡≢∪∨∘⍳⍨⎕ get the input ⎕ compute least common divisor between n and all integers from 1 to n ∨∘⍳⍨ count of unique values ≢∪ if it's exactly 2, then it's prime 2≡


1

GolfScript, 4 bytes Pretty basic solution, disregarding the existing longer solution. Also, I beat CJam! ~\-! Try it online! Explanation ~ # Dump items of list to the stack \- # Swap and find the difference ! # Negate the result


6

APL (Dyalog Unicode), 295 277 bytes a←819⌶⎕A E←{⍵{(⍺⊆⍨~⍵),⍺[⍸⍵]}(⍵∊'|+')∧0=+\-⌿'()'∘.=⍵}1↓¯1↓⊢ M←{c←⊃⌽⍵⋄c∊'0',a:0⋄c∊'_*':1⋄r s o←E⍵⋄o='|':∨/∇¨r s⋄∧/∇¨r s} D←{c←⊃⌽⍵⋄c∊'0_':'0'⋄c=⍺:'_'⋄c∊a:'0'⋄c='*':1⌽∊')('(⍺∇¯1↓⍵)'+'⍵⋄r s o←E⍵⋄o='|':1⌽∊')('(⍺∇r)'|',⍺∇s⋄M r:1⌽∊')(('(⍺∇r)'+'s')|',⍺∇s⋄1⌽∊')('(⍺∇r)'+'s} {M⊃D/(⌽⍵),⊂⍺} Try it online! -18 bytes thanks to @ngn. ...


0

GolfScript, 10 bytes Empty list is false, a list with something is true. (Seems like cheating. But it isn't.) ~32base 4& Try it online! Explanation ~ # Evaluate the input 32base # Convert to base-32 # Copy 4& # Setwise and: does this list have 4?


1

Perl 5, 34 + -p flag = 35 bytes Full program. Takes the simple regex pattern, followed by string to match against, from stdin as two separate lines, then loops and does it again, until EOF is encountered. Prints 1 for a match or nothing for a non-match (with no newline in either case). @ankh-morpork has pointed out that technically, given the question's ...


2

PHP, 983 976 954 930 910 892 838 bytes <?php list(,$s,$i)=$argv;$p=0;$u=[2,[3,[2,[1,'('],$o=[2,[4,[2,&$u,[1,'|+']]],&$u],[1,')']],[1,'_'.join(range('a','z'))]],[5,[1,'*']]];m($o,$a);$s=$i;$p=0;echo m(o($a))&&$p==strlen($s);function m($m,&$a=[]){global$p,$s;$r=$p;$n=array_shift($m);foreach($m as$t){$b=[];if($n==1)if(($c=$s[$p]??0)&&...


1

R, 72 71 70 bytes `-`=function(l)!anyDuplicated(head(l,l[1]+1),l[1]) -(l=scan())&-rev(l) Try it online! Saved a byte thanks to Sumner18.


0

Perl 5, 47 + -alp flag = 50 bytes $_=$F[0];s/[_+]/()/g;s/\*+/*/g;$_=$F[1]=~/^$_$/ Try it online! Perl 5, 41 + -alp flag = 44 bytes Obsolete: it not supports _***-like regexes $_=eval'$F[1]=~/^'.($F[0]=~y/_+//rd).'$/' Try it online!


1

05AB1E, 9 bytes ĆüαnOtιOË Try it online! Port of Nick Kennedy's Jelly answer. It turned out pretty short, despite 05AB1E's lack of complex numbers.


1

J, 36 28 bytes *&({.(-:~.)@-.~}.{.~{.<.#)|. Try it online! *&( )|. Take the original input (implicit in the hook) and its reverse |., and multiply the boolean values * produced by transforming them with the verb in parens &( ) Let's break down the verb in parens... }.{.~{.<.# From the beheaded }. input take {.~ this many ...


1

Wolfram Language (Mathematica), 24 bytes Returns Sphere if the quadrilateral is tangential, Insphere if it is not. Head@Insphere@Polygon@#& Try it online! Wolfram Language (Mathematica), 38 bytes Returns True if the quadrilateral is tangential, False if it is not. 0=={1,-1,1,-1}.Norm/@(#-RotateLeft@#)& Try it online!


1

05AB1E, 13 bytes ‚εć©£®KDÙQ}P Port of @NickKennedy's Jelly answer, so make sure to upvote him as well! Try it online or verify all test cases. Explanation:  # Bifurcate the (implicit) input-string; short for Duplicate & Reverse copy ‚ # Pair this reversed input with the duplicated input ε # Map over the inner lists ...


5

Python 3, 47 bytes f=lambda l,i=3:i+1and abs(l[i]-l[i-1])-f(l,i-1) Try it online! Take complex number input. Outputs as Truthy/Falsey swapped. Test cases from Noodle9. 48 bytes lambda a,b,c,d:A(a-b)+A(c-d)-A(b-c)-A(d-a) A=abs Try it online!


2

JavaScript (ES6), 74 bytes Takes input as a list of coordinate pairs. Returns \$0\$ (falsy) for tangential or a non-zero value (truthy) for non-tangential. a=>(g=_=>Math.hypot(([x,y]=a[i],[X,Y]=a[++i&3],x-X),y-Y))(i=0)-g()+g()-g() Try it online!


4

Jelly, 9 8 bytes ṁ5ạƝŒœ§E Try it online! Explanation 5ị€ | Modular index 1,2,3,4,5 into list ạƝ | Absolute difference of neighbouring pairs Œœ | Split into odd and even indices § | Sum of inner lists E | Equal A monadic link taking a list of complex coordinates and returning 1 for tangential and 0 for not. Based on @...


5

Python 3, 89 \$\cdots\$ 59 55 bytes lambda l:sum((-1)**i*abs(l[i-1]-l[i])for i in range(4)) Try it online! A list of vertices as complex numbers is passed in. The lengths of the sides \$(a, b, c, d)\$ are calculated and uses \$a+c=b+d\$ for a tangential quadrilateral. Returns's a falsy value (0) for a tangential or a truthy value (nonzero) otherwise.


11

MATL, 11 10 bytes 5:)d|2e!sd Input is a vector of four complex numbers. Output is 0 (which is falsy) if tangential, or nonzero (which is truthy) if not tangential. Try it online! Or verify all test cases. Explanation The code computes the difference between sums of lengths of opposite sides. This difference is zero if and only if the quatrilateral is ...


3

Python 2, 95 88 75 74 bytes lambda x:all(A[:A[0]+1].count(a)<2for A in[x,x[::-1]]for a in A if a-A[0]) Try it online! 7 bytes saved thx to Jo King; then 8 more thx to Value Ink; and then 5 more from Jo King; and 1 byte thx to mypetition pointing out an extra space. Function taking a list of ints; returns False/True.


2

Perl 5 -MList::Util=uniq,head -pF,, 71 66 bytes sub b{(@_=grep$_-@_[0],head$_[0]+1,@_)==uniq@_}$_=b(reverse@F)*b@F Try it online!


3

Jelly, 12 bytes ,Uḣ⁹ḟQƑʋḢ$€Ạ Try it online! A monadic link taking a list of integers and returning a Jelly Boolean (1 for True, 0 for False). Explanation ,U | Pair with reversed list ʋḢ$€ | For each pair, do the following as a dyad using the popped head as the right argument y: ḣ⁹ | - First y integers ḟ | - ...


2

Python 3.8 (pre-release), 138 \$\cdots\$ 102 91 bytes lambda x:all(len(set(t:=[e for e in l[1:l[0]+1]if e-l[0]]))==len(t)for l in[x,x[::-1]]if l) Try it online! Saved 11 bytes thanks to @JoKing!!!


2

Ruby, 64 56 bytes Mimics the JavaScript answer in that it takes a helper function and checks the array and its reversed version, but the check for uniqueness is done by taking the subarray based on the key, removing all copies of the key, then checking if the (modified) subarray matches its deduplicated version. -8 bytes by improving the empty list check, ...


2

Charcoal, 31 bytes ∨¬⮌θ⬤E⟦⮌θθ⟧✂⮌ι⁰⊟ι¹⬤ι∨⁼№ιλ¹⁼λ§ι⁰ Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, which is - for true and nothing for false. Explanation: ∨¬⮌θ If the reversed list is empty then the result is true. (Don't ask me why I need to reverse the list first... I think the implicit input uses a subtly different data ...


4

JavaScript (ES6),  88 75 71  69 bytes a=>(g=_=>!a.reverse().some(o=(v,i,[k])=>v-k&&o[v]&(o[v]=i<=k)))()&g() Try it online! Commented The function \$g\$ reverses the input array and performs the test with the resulting leading key. g= _ => // g takes no explicit input !a.reverse() // reverse ...


0

05AB1E, 29 bytes í‚εεÐ0:«NFÁ]€ø`IIø)J€€γ˜4ùS{θ Input as a character matrix. Try it online or verify all test cases. Explanation: í # Reverse each row of the (implicit) input-matrix ‚ # Pair it with the (implicit) input-matrix ε # Map over both matrices: ε # Map over each row: Ð ...


0

W , 3 bytes Sm! Explanation Sm! With implicit input: baSm! baS % Produce a,b m % Produce a%b ! % Negate the value


1

W d, 10 8 bytes ℤ∂¶ø⬯`λ⑲ Explanation: Uncompressed: 25m4&16|m! 25m % If the input is modulo-able by 25: 4& % Return 4 16| % Otherwise, return 16 m! % Modulo input by the value. Negate the value.


0

Symbolic Raku, 17 bytes $_=?($_%%[^] ^$_) Try it online! Suprisingly, this is shorter than the my previous Raku answer, though one byte longer than using the built-in Explanation: $_= # Set the output to ?( ) # The boolean of $_ # If the input is %% # Divisible by [^] # Only one ...


0

tq, 10 bytes ?-1!xp*p%? Explanation Uses Wilson's theorem to do the prime-checking. ?-1! # Generate all numbers from 2 to input - 1 x, # Preserve this value, prevent it from being printed p*p # Generate all possible combinations of those numbers %? # Does the product of any combination equal to the input?


Top 50 recent answers are included