We all know true and false, but what do speakers around the globe say?

| Language             | True       | False      |
| Arabic               | sahih      | zaif       |
| Armenian             | irakan     | kelc       |
| Assamese             | asol       | misa       |
| Breton               | gwir       | gaou       |
| Bulgarian            | veren      | neveren    |
| Catalan              | veritable  | fals       |
| Cornish              | gwir       | gaw        |
| Czech                | pravdivy   | nepravdivy |
| Danish               | sand       | falsk      |
| Dutch                | waar       | onwaar     |
| English              | true       | false      |
| Esperanto            | vera       | malvera    |
| Finnish              | tosi       | epatosi    |
| French               | vrai       | faux       |
| Galician, Portuguese | verdadeiro | falso      |
| Georgian             | namdvili   | cru        |
| German               | wahr       | falsch     |
| Greek                | alithis    | psevdis    |
| Hebrew               | hiyuvi     | shikri     |
| Hindi, Urdu          | thik       | jhutha     |
| Hungarian            | igaz       | hamis      |
| Icelandic            | sannur     | rangur     |
| Indonesian, Malay    | benar      | salah      |
| Irish                | fior       | breagach   |
| Italian              | vero       | falso      |
| Japanese             | shin       | nise       |
| Korean               | cham       | geojit     |
| Latin                | verus      | falsus     |
| Latvian              | patiess    | nepareizs  |
| Mandarin Chinese     | zhen       | jia        |
| Maori                | pono       | pate       |
| Persian              | dorost     | galat      |
| Polish               | prawdziwy  | falszywy   |
| Romanian             | adevarat   | fals       |
| Russian              | vernyj     | falsivyj   |
| Sardinian            | beru       | falsu      |
| Scottish Gaelic      | fior       | breugach   |
| Spanish              | verdadero  | falso      |
| Swedish              | sann       | falskt     |
| Sylheti              | hasa       | misa       |
| Turkish              | dogru      | yanlis     |
| Volapuk              | veratik    | dobik      |
| Welsh                | gwir       | anwir      |

All words ASCIIfied from Wiktionary: true, false. Preference given to first entry under 'A state in Boolean logic that indicates an affirmative or positive result'/'state in Boolean logic that indicates a negative result', then first entry under 'concurring with a given set of facts'/'untrue, not factual, wrong'. I apologise if your favourite language is not included or the word choice for your language is not optimal - go edit Wiktionary!

Write a program or function that takes one word from the table above as input and outputs a consistent truthy value if the word means 'true' and a consistent falsy value otherwise. Your code must produce the correct output for all 79 possible inputs. Shortest code (in bytes) in each language wins.

Sorted list of unique words meaning 'true':


Sorted list of unique words meaning 'false':

  • \$\begingroup\$ Is there any particular reason the output format is so strict? \$\endgroup\$ Commented May 31, 2020 at 1:51
  • \$\begingroup\$ @UnrelatedString What do you mean? You're only required to output truthy or falsy. \$\endgroup\$
    – Dingus
    Commented May 31, 2020 at 1:53
  • 1
    \$\begingroup\$ Two specific strings is a lot more than the typical "your language's truthy or falsy"/"two consistent values"/"one consistent and one non-consistent value". \$\endgroup\$ Commented May 31, 2020 at 1:54
  • 5
    \$\begingroup\$ @UnrelatedString That's what I mean by truthy and falsy. You're not required to output the literal strings 'truthy' and 'falsy'. I'll clarify in the question. \$\endgroup\$
    – Dingus
    Commented May 31, 2020 at 1:56
  • 2
    \$\begingroup\$ Using Anders Kaseorg's method on a related question I can get a 61-byte lambda function in Python 3 that takes a bytes object and returns 0 or 1. Since the author might want to post it I'll only leave this comment and keep the program hidden. // The same approach (but with details modified a little) fits in 21 bytes in Jelly. \$\endgroup\$
    Commented May 31, 2020 at 4:18

11 Answers 11


Python 2, 56 48 bytes

thanks to dingledooper for -8 bytes!

lambda s:0x420AF14A5F8266>>hash(s)%3317%890%57&1

Try it online!

All these answers do the same thing:

  1. Convert the string into an unique integer.

  2. Makes these integers smaller by repeated modulo operations. These operations are bruteforced to make the numbers as small as possible while not mixing up the two classes.

  3. Index into a binary lookup table.

Python 3, 59 58 bytes

lambda s:0x48A2D06199310566F06>>int(s[:4],36)%542%400%78&1

Try it online!

lambda s:0x453CCA1066840810431C1>>int(s,36)%2387%1770%86&1

Try it online!

lambda s:0x42744262AEA01A914800A12C>>int(s,36)%155687%95&1

Try it online!

05AB1E, 30 29 28 bytes


Try it online!

6öŽ9{%521%76%o•B&¦¿³ʒв F6•&Ā

Try it online!

  • 1
    \$\begingroup\$ How did you find the equation? \$\endgroup\$
    – PkmnQ
    Commented May 31, 2020 at 7:22
  • 5
    \$\begingroup\$ @PkmnQ bruteforcing, a lot of it. And I need to try a lot of different thing, like multiplying the integer by some constant, different ranges for the modulo, different numbers of modulo operations, ... \$\endgroup\$
    – ovs
    Commented May 31, 2020 at 7:30
  • \$\begingroup\$ Can't you remove the [:4]? (and change the modulus values) \$\endgroup\$
    Commented May 31, 2020 at 8:30
  • 5
    \$\begingroup\$ I managed to get 48 bytes. \$\endgroup\$ Commented May 31, 2020 at 18:07
  • 2
    \$\begingroup\$ @ovs Feel free to update your current Python answer with the 48-byte one :). \$\endgroup\$ Commented Jun 1, 2020 at 22:08

Ruby -n, 54 49 47 bytes

p !/^[fgmryz]a|[ncks][erw]|[bjm][hir]|ep|la|te/

Try it online! - truthy

Try it online! - falsy

Thanks to Dingus for a byte saved and Value Ink for inspiring another -2.

  • 3
    \$\begingroup\$ @Dingus $_!~/^ reads more like Perl than Ruby to me :) \$\endgroup\$ Commented May 31, 2020 at 13:09
  • \$\begingroup\$ Currently the shortest regex. Nice! \$\endgroup\$
    – Dingus
    Commented May 31, 2020 at 13:59
  • 1
    \$\begingroup\$ You should list the language as "Ruby -n" or something like that. codegolf.meta.stackexchange.com/a/14339 Also, I'm personally a fan of p ! ~/... even though the bytecount doesn't change. \$\endgroup\$
    – Value Ink
    Commented May 31, 2020 at 23:33
  • \$\begingroup\$ @ValueInk, thanks for reminding, I wish TIO template would include flags automatically, as I keep forgetting them. \$\endgroup\$
    – Kirill L.
    Commented Jun 1, 2020 at 6:40
  • \$\begingroup\$ BTW, this juggling with output methods actually yielded another -2 bytes \$\endgroup\$
    – Kirill L.
    Commented Jun 1, 2020 at 7:00

Retina, 68 67 60 58 bytes


Try it online!

Regex that matches all truthy values and none of the falsey ones.

Verify all truthy inputs

Verify all falsey inputs

  • 3
    \$\begingroup\$ Would it be shorter to match falsy inputs instead? (they seem to have a very common substring fa) (I'm not sure whether you can output inverted, probably not) \$\endgroup\$ Commented May 31, 2020 at 6:38
  • \$\begingroup\$ @mypronounismonicareinstate Yes it should. Porting my regex to Retina would be 49 bytes + whatever is required to invert the result. \$\endgroup\$
    – Arnauld
    Commented May 31, 2020 at 9:23
  • \$\begingroup\$ If so, this works for 54 bytes (I won't be surprised if there's a shorter way to invert the regex, though) (assuming Arnauld is okay with their regex being stolen) \$\endgroup\$ Commented May 31, 2020 at 9:26
  • \$\begingroup\$ @mypronounismonicareinstate Sure. Now 51 bytes, btw. \$\endgroup\$
    – Arnauld
    Commented May 31, 2020 at 10:20
  • \$\begingroup\$ @Arnauld Thanks, but I feel that updating my answer now would make it too similar to the other answers that use regex (currently yours and the Ruby answer) \$\endgroup\$ Commented May 31, 2020 at 14:32

C (gcc), 55 52 bytes

-3 bytes thanks to @G. Sliepen


Try it online!

The strategy used is the same as in @ovs's answer. We brute-force values corresponding to each string, making sure that no two truthy and falsey words share the same value. The answer is then extracted from a binary lookup table.

Here, the a64l() function converts a given string into a 32-bit signed integer.

  • \$\begingroup\$ "32-bit unsigned integer" should that be "signed"? (so you have to use a byte (U) to convert it to unsigned? \$\endgroup\$
    Commented Jun 1, 2020 at 10:49
  • \$\begingroup\$ @user202729 I double-checked, and you are correct. Fixed now. \$\endgroup\$ Commented Jun 1, 2020 at 16:55
  • \$\begingroup\$ 52 bytes by converting it to a function: f(s){s=0x4240165C085F34>>a64l(s)%19537U%11702%56&1;} \$\endgroup\$
    – G. Sliepen
    Commented Jun 1, 2020 at 19:09
  • \$\begingroup\$ @G.Sliepen That is interesting. Can you explain why the s parameter doesn't need to be declared with char*? \$\endgroup\$ Commented Jun 1, 2020 at 19:32
  • 4
    \$\begingroup\$ If you don't declare it, it becomes an int. Since you didn't #include <stdlib.h>, the compiler doesn't know that a64l() expects a string, so it just passes on the "integer" s. a64l() in turn interprets it as a pointer again. The trick with assigning the result to s causes the result to also become the return value due to the calling conventions. Of course these techniques should only ever used for Code Golf :) \$\endgroup\$
    – G. Sliepen
    Commented Jun 1, 2020 at 21:39

x86-64 machine code, 27 bytes


6b 01 35 c1 e8 06 6b c8 d3 d1 c1 48 ba 4e 88 00
02 c3 45 88 8b 48 d3 e2 1a c0 c3

A function which receives a pointer to the string in rcx, and returns the result in al.

−1 means true, and 0 means false.

Assembly source code, using ml64 (MASM) syntax:

    imul eax, dword ptr[rcx], 53
    shr eax, 6
    imul ecx, eax, -45
    rol ecx, 1;
    mov rdx, 8b8845c30200884eh;
    shl rdx, cl;
    sbb al, al;

Disassembly, while stopped on a breakpoint at the start of the function:

00007FF73978F4A0 6B 01 35             imul        eax,dword ptr [rcx],35h  
00007FF73978F4A3 C1 E8 06             shr         eax,6  
00007FF73978F4A6 6B C8 D3             imul        ecx,eax,0FFFFFFD3h  
00007FF73978F4A9 D1 C1                rol         ecx,1  
00007FF73978F4AB 48 BA 4E 88 00 02 C3 45 88 8B mov         rdx,8B8845C30200884Eh  
00007FF73978F4B5 48 D3 E2             shl         rdx,cl  
00007FF73978F4B8 1A C0                sbb         al,al  
00007FF73978F4BA C3                   ret  

It uses hashing, like many other answers. The hash function uses the first 4 bytes of the string - by luck, all strings are at least 4 bytes long (including terminating zero byte). It does the following:

  • Multiply by 53, ignoring overflow
  • Shift right by 6 bits
  • Multiply by -45, ignoring overflow
  • Rotate left by 1 bit
  • Access the 64-bit hash table, using 6 LSB of the result

Found by brute-force search. The search space was 8 + 5 + 8 + 5 = 26 bits. The "rotate left" bit count is 1 by luck, which reduces code size by 1 byte, compared to the general "rotate left" case.

  • \$\begingroup\$ Could your MASM code possibly be made to work with JWasm? (I don't know how to initialise rcx.) \$\endgroup\$
    – Dingus
    Commented Jun 2, 2020 at 12:43
  • 1
    \$\begingroup\$ See here. Not sure about how it's best to format it. Also, in assembly language its length is too big; I prefer machine code. \$\endgroup\$
    – anatolyg
    Commented Jun 2, 2020 at 13:22
  • \$\begingroup\$ I'm impressed that x86 is able to beat all of the golfing languages. Clearly our encodings are not good enough yet! \$\endgroup\$ Commented Jun 6, 2020 at 1:25
  • \$\begingroup\$ I suspect all the golfers just didn't try hard enough. user202729 suggests that there is a short answer in Jelly. \$\endgroup\$
    – anatolyg
    Commented Jun 6, 2020 at 5:41

Brachylog, 70 bytes


Try it online!

Takes input through the output variable and outputs through success or failure.


Charcoal, 41 bytes


Try it online! Link is to verbose version of code. Output is a Charcoal boolean, i.e. - for true, nothing for false. Explanation:

   θ                Input string
  ⁼                 Equals
    gaw             Literal string `gaw`
 ∨                  Boolean Or
         ”...”      Compressed string `bibrcrepfagujhjikekrlamaminenwouseteyaza`
        ⪪     ²     Split into substrings of length 2
       ⊙            Where any is nonzero
               №    Count of
                 ι  Current substring in
                θ   Input string
¬                   Boolean Not
                    Implicitly print

JavaScript (ES6),  63 62  60 bytes

Saved 2 bytes thanks to @Neil

A regular expression that matches all falsy words and none of the truthy ones.


Try it online!

  • \$\begingroup\$ Try matching rangur using ^r instead of ng? \$\endgroup\$
    – Neil
    Commented May 31, 2020 at 10:03
  • \$\begingroup\$ @Neil Nice one :) \$\endgroup\$
    – Arnauld
    Commented May 31, 2020 at 10:05

05AB1E, 41 39 bytes

.•6ðó_ ï²£Ëý¾Sð7§Ê³®6´¡Žmã•2ôåàI…gawQ~≠

-2 bytes by using a shorter compressed string from @Neil's Charcoal answer, who apparently uses the exact same approach.

Try it online or verify all test cases.


.•6ðó_ ï²£Ëý¾Sð7§Ê³®6´¡Žmã•
         # Push compressed string "bibrcrepfagujhjikekrlamaminenwouseteyaza"
  2ô     # Split it into parts of size 2
    å    # Check for each whether it's a substring of the (implicit) input-string
     à   # And check if any is truthy
I        # Push the input again
 …gawQ   # Check that it's equal to string "gaw"
~        # Check if either of the two is truthy by using a bitwise-OR
 ≠       # And invert the boolean (!= 1)
         # (after which the result is output implicitly)

See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•6ðó_ ï²£Ëý¾Sð7§Ê³®6´¡Žmã• is "bibrcrepfagujhjikekrlamaminenwouseteyaza".

  • \$\begingroup\$ What was your previous compressed string? The edit history is unenlightening... \$\endgroup\$
    – Neil
    Commented Jun 2, 2020 at 10:26
  • \$\begingroup\$ @Neil Oh, I edited a few seconds too soon apparently before the grace period of 5 minutes was over.. -_-' It was "aobrcreleoepfahuiaifkrlamaminengninlnwobpste" (.•bÙвfƒôSÐ4Ólα$šη€mªδP‚Á¥PnÀ•) \$\endgroup\$ Commented Jun 2, 2020 at 10:33
  • \$\begingroup\$ So the uncompressed string was the same, but you just found a better way of compressing it? Or have I missed something? \$\endgroup\$
    – Neil
    Commented Jun 2, 2020 at 11:02
  • \$\begingroup\$ @Neil Now it probably makes more sense.. Not sure how I ended up copying the wrong strings to my answer (the TIOs were correct..) It went from .•bÙвfƒôSÐ4Ólα$šη€mªδP‚Á¥PnÀ•/"aobrcreleoepfahuiaifkrlamaminengninlnwobpste" to .•6ðó_ ï²£Ëý¾Sð7§Ê³®6´¡Žmã•/"bibrcrepfagujhjikekrlamaminenwouseteyaza" \$\endgroup\$ Commented Jun 2, 2020 at 11:29
  • \$\begingroup\$ Ah, thanks, it's good to know that my list of falsy letter pairs is pretty short! \$\endgroup\$
    – Neil
    Commented Jun 2, 2020 at 11:57

Io, 109 bytes

-10 bytes thanks to Neil.

method(x,"bi br cr ep fa gu jh ji ke kr la ma mi ne nw ou se te ya za gaw"split select(i,x findSeq(i))size<1)

Try it online!

Io, 119 bytes

Searches for prefixes of existing values.

method(x,"dob fa ga ham an br cr e pate ge j k ma mi ne ni on ps sal shik ra ya za"split select(i,x findSeq(i)==0)size)

Try it online!

  • \$\begingroup\$ method(x,"bi br cr ep fa gu jh ji ke kr la ma mi ne nw ou se te ya za gaw"split select(i,x findSeq(i))size<1) is 109 bytes, and also gives the correct truthiness. \$\endgroup\$
    – Neil
    Commented May 31, 2020 at 10:36

C (gcc), 125 \$\cdots\$ 101 95 bytes

Saved a byte thanks to ceilingcat!!!

#define f(s)!index(" %&(-.049;ADHJQRSYZis",*s**s*s[l=strlen(s)-1]*s[l-1]%3519%163%108%92+32)

Try it online!

Inputs a string and returns \$1\$ for words meaning 'true' and \$0\$ for words meaning 'false'.


The first, second to last, and last characters of all the word strings form a unique triplet of characters across all words. Multiplying the ASCII values of first character squared and the other two together yields unique 32-bit integers across all words. These numbers modulus values found by a Python script yield a distinct set of integers for all 'false' words in the range \$(0,96)\$. These numbers can then be transformed back to printable ASCII characters by adding \$32\$ to them. Then it's simply a test if a string put through these calculations yields a character that can be found in a given string (also generated by the Python script).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.