Gift

From Esolang
Jump to navigation Jump to search

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:

  1. 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.
  2. 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.
  3. 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.
  4. If no item is deemed too expensive, the first character of each line will be printed.

Examples

Input:

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.


Input:

a really nice car
brand new pc

Output: coal (because the second item is deemed too expensive)

Implementation