Skip to main content
49 votes

Be the First 1 (leave only the first Truthy)

Python 2, 35 bytes while 1:b=input();print b;True&=b<1 Try it online! Input and output are lines of True/False. Based on Dennis's solution. Redefines the ...
xnor's user avatar
  • 145k
46 votes

Mathematics is fact. Programming is not

Mathematica, 25 17 bytes Input[]/.!x_:>1-x Takes input from a user prompt. Assumes Mathematica's notebook environment for implicit printing. To make it a ...
Martin Ender's user avatar
43 votes

Prove me wrong!

Mathematica, 12 bytes SatisfiableQ Well, there's a built-in... Input format is And[Or[a, b, Not[c], Not[d]], Or[...], ...]. ...
Martin Ender's user avatar
42 votes
Accepted

Count trailing truths

Dyalog APL, 6 2 bytes ⊥⍨ Test it on TryAPL. How it works ⊥ (uptack, dyadic: decode) performs base conversion. If the left operand is a vector, it performs ...
Dennis's user avatar
  • 210k
36 votes
Accepted

Be the First 1 (leave only the first Truthy)

APL, 2 bytes <\ Evaluates to the function "scan using less-than". Try it online! Explanation In APL, the operator \ (...
Zgarb's user avatar
  • 42.7k
31 votes

Automate your first grade counting exercise

Perl 6, 119 113 bytes {my \n=<① ⑳ ㉑ ㉟ ㊱ ㊿>.map:{|map *.uniname.words[2..*].join,$^a..$^b} /\d/??n[^$_]!!1..1+first $_,n,:k} Unicode database FTW! Uses ...
smls's user avatar
  • 4,450
31 votes

Mathematics is fact. Programming is not

Bash + Unix utilities, 21 17 bytes sed s/.!!*$/1/|bc Verify the test cases online! Added a TIO link to the test suite. This must be saved in a file and run as ...
Mitchell Spector's user avatar
30 votes

Invert a boolean array

05AB1E, 1 byte Code: _ Explanation: _ # Logical not Try it online!
Adnan's user avatar
  • 44.4k
28 votes

(A → B) → (¬B → ¬A)

88 82 77 72 steps Thanks to H.PWiz for better combinator conversions that saved 10 steps! Explanation You might be familiar with the Curry–Howard correspondence, in which theorems correspond to ...
Anders Kaseorg's user avatar
27 votes

Be the First 1 (leave only the first Truthy)

Aceto, 19 17 bytes New version (17 bytes): This new version takes the characters one at a time and is best executed with the -F option. It works similar, but not ...
L3viathan's user avatar
  • 3,411
26 votes

(A → B) → (¬B → ¬A)

91 Steps Full Proof: ...
Tipping Octopus's user avatar
25 votes

Mathematics is fact. Programming is not

Retina, 20 15 14 bytes Thanks to Leo for saving 1 byte. 0! 1 !! ^1|!0 Try it online! Explanation 0! 1 Turn ...
Martin Ender's user avatar
19 votes

Count trailing truths

JavaScript (ES6), 21 bytes f=l=>l.pop()?f(l)+1:0 Test cases ...
Arnauld's user avatar
  • 193k
19 votes

Mathematics is fact. Programming is not

Grime, 14 12 9 bytes e`\0!~\!_ Try it online! Explanation This matches the input against a pattern, printing 1 for match ...
Zgarb's user avatar
  • 42.7k
19 votes

(A → B) → (¬B → ¬A)

59 steps Norman Megill, author of Metamath has told me about a 59 step proof, which I'm going to post here in this community wiki. The original can be found in theorem 2.16 on this page. http://us....
18 votes

Mathematics is fact. Programming is not

Brainfuck, 85 72 (84) bytes ,[>-[-----<->]<++[>++++[-<++++>]+<[[+],[[-]>-<]]]>[<<+[-->]>[<],>-]<]<+. to ...
Rupert Tombs's user avatar
18 votes

Be the First 1 (leave only the first Truthy)

Java8, 24 19 Bytes Long::highestOneBit Hope this is legal; I got the impression the input / output doesn't have to evaluate as true/false in the language. Takes ...
JollyJoker's user avatar
18 votes

Create a Boolean Calculator

Python, 3 bytes ÷ 1 op = score 3 min Try it online! Implements AND, with inputs like ...
xnor's user avatar
  • 145k
16 votes

Mathematics is fact. Programming is not

Brainfuck - way to many bytes (232 bytes) Clearly the wrong language for winning in code golf. Mainly I noticed a lack of anyone using this esolang. There is a good online interpreter bf interpeter ...
CodyCode's user avatar
  • 161
15 votes

Run Stackylogic

Retina, 79 78 73 68 66 65 63 62 55 44 bytes Byte count assumes ISO 8859-1 encoding. +`(.)([^_]*)\?<|(¶.*)0<|1<(¶.+) $2$1$4<$3 1< Input is via ...
Martin Ender's user avatar
15 votes

Invert a boolean array

Jelly, 1 byte ¬ Try it online! ¬ is logical NOT (1 if false-y, else 0). C (“complement”, ...
lynn's user avatar
  • 68.8k
15 votes

Invert a boolean array

Javascript ES6, 15 bytes a=>a.map(b=>!b) Not much explanation needed I guess ...
Bassdrop Cumberwubwubwub's user avatar
15 votes

Mathematics is fact. Programming is not

Python, -44- 42 bytes Saved 2 bytes thanks to Zgarb! lambda x:(x[-1]=='0')^len(x.rstrip('!'))%2 Step by step: x[-1]!='0' if ...
busukxuan's user avatar
  • 2,808
15 votes

Implement the Conjunction of a Three-Valued Logic

Python, 22 bytes lambda s:s["T"<s<"UT"] Try it online!
Anders Kaseorg's user avatar
14 votes

Invert a boolean array

Matlab, 4 1 byte This should be self explanatory. ~ Matlab has the one-byte negation operator ~, if you want a function you ...
flawr's user avatar
  • 43.8k
13 votes

Run Stackylogic

Convex, 102 95 bytes Well, a list-of-stacks-based language coded in a stack-based language turned out to be quite difficult. Mark my words: I will get this to 100 bytes or less! EDIT: Success! ...
GamrCorps's user avatar
  • 7,592
13 votes

Automate your first grade counting exercise

Python3, 276 271 269 243 237 235 232 217 bytes Taking a cue from the @smls perl submission... ...
kuupaork's user avatar
  • 231
13 votes

Mathematics is fact. Programming is not

JavaScript (ES6), 43 41 29 bytes s=>+eval(s.replace(/.!+$/,1)) Non-regex method (41 31 bytes) Below is my initial approach. It's slightly more interesting, ...
Arnauld's user avatar
  • 193k
13 votes

Mathematics is fact. Programming is not

Retina, 13 bytes A somewhat weird approach, but it's short and it works. 0$ !1 !! ^\d With the first two lines we replace an ending ...
Leo's user avatar
  • 12.7k
13 votes

Mathematics is fact. Programming is not

Jelly, 5 bytes VeMḂ$ Try it online! Monadic function expecting a string. Inputs with leading !s cause a ...
Jonathan Allan's user avatar

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