We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Gift
- Not to be confused with GIFt.
Gift is a festive, joke esoteric language created by User:UW that has no practical uses. It takes your wish list as input, and outputs "coal" if you ask for something that is too expensive.
Input
The input can be made up of multiple lines, and is meant to represent a wish list. Here's an example:
a brand new car a red sweater 10 candy bars maybe
Note that blank lines are ignored.
Output
Gift outputs one of two things:
- the first character of each line, one after the other
- the string "coal", if it decides that you've asked for something that is too expensive (see the explanation below)
Explanation
How does the interpreter know if something is too expensive?
Gift has no understanding of the words in the input, and simply uses a hash function for arbitrary reasons:
- For each line in the input, a hash is calculated (32-bit FNV-1a, case-insensitive). Spaces and tabs are ignored. The resulting hash is a 32-bit integer.
- If this integer is not a multiple of 4, the item on that line is declared as being too expensive. So, you will get coal more often than not. The hash can't be changed by simply adding more spaces or by changing a letter's case.
- If at least one item in the list is deemed too expensive, the output will simply be "coal". You won't be told what item caused that output.
- If no item is deemed too expensive, the first character of each line will be printed.
Examples
Successuful example
Large hoodie orange socks lemons maybe?
Output: Lol (aka the first character of each line)
Notice how the output contains no spaces, even if there is a blank line.
Failed example
Input:
a really nice car brand new pc
Output: coal (because the second item is deemed too expensive)
Hello World
Hen eight cute rabbits light green paper long piece of paper orange socks ,+ _-- White pants orange coat really nice cardboard box light green paper dark pink sweater !
Note: since Gift can't output spaces, it's replaced by a dash (_).
Another version by PSTF:
Huacors eksjrngm l3ryi l3ryi osur ,+ _-- Whizlg oslfksk rkshdrg ldugve dhoy8w !
This is the result of random typing.
Quine
coal
Self-explanatory.
Besides that, there are 62 one-character quines:
\x01 \x05 \x11 \x15 \x19 \x1d ! % ) - 1 5 9 = A E I M Q U Y ] a e i m q u y } \x81 \x85 \x89 \x8d \x91 \x95 \x99 \x9d \xa1 \xa5 \xa9 \xad \xb1 \xb5 \xb9 \xbd \xc1 \xc5 \xc9 \xcd \xd1 \xd5 \xd9 \xdd \xe1 \xe5 \xe9 \xed \xf1 \xf5 \xf9 \xfd
Some characters are escaped and should be unescaped to work, \r and \t have a valid hash, but aren't valid as they're whitespaces.
99 bottles of beers
9isurhfmisuckjhr 9ursdfkhpodidl _++ bfsiurchseopljtsoph5io osojtpsei[ctp[esoxu[d tusroylr.pjviftj[hso tj9psorlyr5poyvruphl --snip--
Too long.
4aaa
6 interpreter
6kjserkxsdfkisrhfxerf
A somewhat optimized version
6qwertyuiop
Definitely output "coal"
c82ohe3u1o83f oal2uur730284 a83020291lfil l3pdie08ro4i4
or simply:
coal
Ninety PCs open source printer is coal exhausted .exhausted
Interepters:
- Gift online interpreter - the source code can be found on GitHub.
- Interpreter in Python (kind of):
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
FNV_32_PRIME = 0x01000193
FNV1_32_INIT = 0x811c9dc5
import sys
if sys.version_info[0] == 3:
_get_byte = lambda c: c
else:
_get_byte = ord
def fnva(data, hval_init, fnv_prime, fnv_size):
assert isinstance(data, bytes)
hval = hval_init
for byte in data:
hval = hval ^ _get_byte(byte)
hval = (hval * fnv_prime) % fnv_size
return hval
def fnv1a_32(data, hval_init=FNV1_32_INIT):
"""
Returns the 32 bit FNV-1a hash value for the given data.
"""
return fnva(data, hval_init, FNV_32_PRIME, 2**32)
line1 = input("Enter the first line of your code (blank line to end program): ")
if line1 != "":
line2 = input("Enter the 2nd line (blank to end): ")
if line2 != "":
line3 = input("Enter the 3rd line (blank to end): ")
if line3 != "":
line4 = input("Enter the 4th line (blank to end): ")
if line4 != "":
line5 = input("Enter the 5th line (blank to end): ")
if line5 != "":
line6 = input("Enter the 6th line (blank to end): ")
if line6 != "":
line7 = input("Enter the 6th line (blank to end): ")
if line7 != "":
line8 = input("Enter the 8th line (blank to end): ")
if fnv1a_32(line1) % 4 == 0 or fnv1a_32(line2) % 4 == 0 or fnv1a_32(line3) % 4 == 0 or fnv1a_32(line4) % 4 == 0 or fnv1a_32(line5) % 4 == 0 or fnv1a_32(line6) % 4 == 0 or fnv1a_32(line7) % 4 == 0 or fnv1a_32(line8) % 4 == 0:
print("coal")
else:
if line8 == "":
if line7 == "":
if line6 == "":
if line5 == "":
if line4 == "":
if line3 == "":
if line2 == "":
if line1 == "":
pass
print(line1[0])
print(line1[0] + line2[0])
print(line1[0] + line2[0] + line3[0])
print(line1[0] + line2[0] + line3[0] + line4[0])
print(line1[0] + line2[0] + line3[0] + line4[0] + line5[0])
print(line1[0] + line2[0] + line3[0] + line4[0] + line5[0] + line6[0])
print(line1[0] + line2[0] + line3[0] + line4[0] + line5[0] + line6[0] + line7[0])
print(line1[0] + line2[0] + line3[0] + line4[0] + line5[0] + line6[0] + line7[0] + line8[0])
- Stephen Ignatius Abel's Python interpreter for this esolang:
import fnvhash
import sys
def gift(input_text: str) -> str:
"""
执行 Gift 语言的核心逻辑。
参数:
input_text: 多行字符串,代表愿望清单。
返回:
字符串 "coal" 或所有行首字符的连接。
"""
lines = input_text.splitlines()
for line in lines:
# 1. 忽略空行[reference:12]
if not line.strip():
continue
# 2. 规范化字符串:移除空格/制表符并转为小写[reference:13]
# fnvhash 库需要 bytes 类型,因此进行编码
normalized_line = line.replace(" ", "").replace("\t", "").lower()
line_bytes = normalized_line.encode('utf-8')
# 3. 计算 32-bit FNV-1a 哈希[reference:14]
# fnvhash.fnv1a_32 返回一个整数
hash_value = fnvhash.fnv1a_32(line_bytes)
# 4. 判定是否“太贵”:哈希值不是4的倍数[reference:15]
if hash_value % 4 != 0:
return "coal"
# 5. 所有项目都通过:输出每行的第一个字符[reference:16][reference:17]
# 注意:需要再次处理,跳过空行,取每行第一个非空白字符?
# 根据规范,是“每一行的第一个字符”[reference:18],示例也表明是直接取第一个字符[reference:19]。
# 但示例输入 "a red sweater" 输出 'a',可见是忽略前导空格的第一个可见字符。
# 更准确地说,是取每行修剪后的第一个字符。
first_chars = []
for line in lines:
stripped_line = line.strip()
if stripped_line: # 跳过空行
first_chars.append(stripped_line[0])
return ''.join(first_chars)
# --- 测试示例 ---
if __name__ == '__main__':
# 示例 1:成功 (来自 Wiki)[reference:20]
success_input = """Large hoodie
orange socks
lemons maybe?"""
print(f"输入:\n{success_input}")
print(f"输出: {gift(success_input)}") # 预期输出: Lol
print("-" * 20)
# 示例 2:失败 (来自 Wiki)[reference:21]
fail_input = """a really nice car
brand new pc"""
print(f"输入:\n{fail_input}")
print(f"输出: {gift(fail_input)}") # 预期输出: coal
print("-" * 20)