We all know that if you google the word "google" it will break the internet.

Your task is to create a function that accepts one string and returns its length, in the fewest possible Unicode characters.

However, if the given string is google (lowercase), it will cause an error.

For example, g('bing') will return 4 but g('google') will cause an error.

Please provide an example of usage, and the error if possible.

## The Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

## Language Name, N bytes


where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes


If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes


You can also make the language name a link which will then show up in the snippet:

## [><>](https://esolangs.org/wiki/Fish), 121 bytes


/* Configuration */

var QUESTION_ID = 197625; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 8478; // This should be the user ID of the challenge author.

/* App */

return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

}

jQuery.ajax({
method: "get",
dataType: "jsonp",
crossDomain: true,
success: function (data) {
data.items.forEach(function(a) {
});
comment_page = 1;
}
});
}

jQuery.ajax({
method: "get",
dataType: "jsonp",
crossDomain: true,
success: function (data) {
data.items.forEach(function(c) {
if (c.owner.user_id === OVERRIDE_USER)
});
else process();
}
});
}

var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

function getAuthorName(a) {
return a.owner.display_name;
}

function process() {
var valid = [];

var body = a.body;
if(OVERRIDE_REG.test(c.body))
body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
});

var match = body.match(SCORE_REG);
if (match)
valid.push({
user: getAuthorName(a),
size: +match[2],
language: match[1],
});
else console.log(body);
});

valid.sort(function (a, b) {
var aB = a.size,
bB = b.size;
return aB - bB
});

var languages = {};
var place = 1;
var lastSize = null;
var lastPlace = 1;
valid.forEach(function (a) {
if (a.size != lastSize)
lastPlace = place;
lastSize = a.size;
++place;

.replace("{{NAME}}", a.user)
.replace("{{LANGUAGE}}", a.language)
.replace("{{SIZE}}", a.size)

var lang = a.language;
lang = jQuery('<a>'+lang+'</a>').text();

languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
});

var langs = [];
for (var lang in languages)
if (languages.hasOwnProperty(lang))
langs.push(languages[lang]);

langs.sort(function (a, b) {
if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
return 0;
});

for (var i = 0; i < langs.length; ++i)
{
var language = jQuery("#language-template").html();
var lang = langs[i];
language = language.replace("{{LANGUAGE}}", lang.lang)
.replace("{{NAME}}", lang.user)
.replace("{{SIZE}}", lang.size)
language = jQuery(language);
jQuery("#languages").append(language);
}

}
body {
text-align: left !important;
display: block !important;
}

width: 290px;
float: left;
}

#language-list {
width: 500px;
float: left;
}

font-weight: bold;
}

table td {
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="language-list">
<h2>Shortest Solution by Language</h2>
<table class="language-list">
<tr><td>Language</td><td>User</td><td>Score</td></tr>
<tbody id="languages">

</tbody>
</table>
</div>
<tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>

</tbody>
</table>
</div>
<table style="display: none">
</tbody>
</table>
<table style="display: none">
<tbody id="language-template">
</tbody>
</table>

• @Geobits That is simply a test to see if I will google Google, which I will not. :D – rybo111 Sep 28 '15 at 16:33
• Does the function need to be case sensitive? Should it throw given 'gOOgle'? – AXMIM Sep 30 '15 at 22:07
• When I type google into google (the search bar on chrome), a message came up asking if I wanted to go to google. (Now that it is a tld, this makes sense i.e. com.google works). I clicked it and got a dns lookup error. Internet:broken! – Craig Oct 1 '15 at 4:18
• I'm voting to reopen this. I have seen no questions about what constitutes an error for this challenge and it already has 154 answers so I don't think it's fair to change the spec. This may not be an example of a good question but it's clear enough. If an answer really comes down to whether or not a certain output is an error it probably just won't get as many upvotes, anyway. – Poke Aug 1 '18 at 19:52

# Japt, 14 bytes

U¥goog¤?Þ:Ul


Try it here!

### Explanation

U¥goog¤?Þ:Ul
U                     // U is the input
¥                    // ¥ is the Unicode shortcut for ==
                   // backticks are used to uncompress goog¤
Þ           // An undefined variable
Ul        // l is a built-in that returns the length of U
// Implicit: output result of last expression

• Can you explain? – Adám Jan 10 '17 at 23:10
• @Adám Added an explanation :) – Oliver Jan 10 '17 at 23:40

# C# .NET, 65 bytes

int g(string s){return(s!="google")?s.Length:(1/int.Parse("0"));}


Test:

Console.WriteLine(g("str"));

• with C# 6.0 you can save a few characters by doing an expression-bodied method: int g(string s)=>s!="google"?s.Length:(1/int.Parse("0")); – DLeh Sep 28 '15 at 19:18
• also you could cause an exception by recursing, eventually you'll get a stack overflow int g(string s)=>s!="google"?s.Length:g(s); – DLeh Sep 28 '15 at 19:19
• You can make it crash faster by just calling int.Parse(""). Although the infinite recursion strategy would be even shorter. – sara Sep 29 '15 at 9:23
• @kai Something like "".Length is shorter than int.Parse(""). – Bob Sep 29 '15 at 12:41
• @Bob "".Length just returns 0, it doesn't throw. – DLeh Oct 1 '15 at 13:03

# PHP 5.4+, 40 49 bytes

This one is quite unexpectedly long.

function g($x){echo[strlen($x),[]][$x==google];}  To run it, just pass a value: g($argv[1]);


Test-cases:

$php google.php googlea 7$php google.php google
Notice: Array to string conversion in [...][...] on line 1
Array

I'm not sure if this can ve considered an error for this challenge or not.

One could use the over-used boring method:

function g($x){echo strlen($x)/$x==google;}  Which gives me a size of only 43 bytes. As an alternative, one could use an exit error code, using the exit construct, for also 49 bytes: function g($x){exit($x==google?strlen($x).'':1);}


All values between 1 and 254 are valid error codes that PHP uses when exiting.

• You could use function g($x){echo$x==google?a():strlen($x);} which is 46 bytes (3 bytes shorter) and throws an actual error and not just a warning. Also your second example function g($x){echo strlen($x)/$x==google;} should be: function g($x){echo strlen($x)/($x!=google);}. / has a higher precedence than == and you have to switch it to !=as well to make it work. – insertusernamehere Nov 16 '15 at 22:53 # Common Lisp, 50 48 bytes (defun g(s)(if(equal s"google")(g s)(length s)))  Ungolfed: (defun g(s) ; Define a function g with one argument s (if (equal s "google") ; If s == "google", (g s) ; Then recurse! (length s) ; Else, return the length of s in characters ) )  Defines a function g that accepts one string as input. If it is not exactly 'google', then it returns the length. Otherwise, it will call itself on the same string, creating an infinite recursive loop and eventually causing a stack overflow error. Usage (inside an interactive CLISP shell): >(load "google.lsp") Finished loading. >(g "foo") 3 >(g "Lisp is cool!") 13 >(g "google") *** - Program stack overflow. RESET  This is pretty long compared to the others, but using recursion seemed fitting for Lisp. • This won't cause a stack overflow in some Common Lisp implementations (CCL and SBCL won't overflow). – nanny Sep 28 '15 at 20:57 # Scala, 48 def g(s:String)=if(s=="google")0/0 else s.length  To call:  g("bing") //> res1: Int = 4 g("google") //> java.lang.ArithmeticException: / by zero  • you can use an anonymous function, and shave off 4 characters. also, it will be more neat, IMHO, to use ??? rather than 0/0. – Jacob Mar 27 '16 at 14:55 # C - 99 75 67 63 bytes g(char*s){int i=0,j=*s;while(s[i])j^=s[++i];return j^9?i:g(s);}  ## Ungolfed: int g(char *s){ int i = 0, j = s[0]; // first char of s while(s[i] != '\0'){ j ^= s[++i]; // j = j XOR [next char] } if(j != 9){ // g^o^o^g^l^e = 9 return i; } else { g(s); // infinite recursion } }  Using it: g("bing") // 4 g("duckduckgo") // 10 g("google") // segmentation fault  Will return the length if g XOR o XOR o XOR g XOR l XOR e isn't 9, else it will infinite recurse causing a stack overflow. ## How it works I used a (very) crappy hashing algorithm (a XOR b XOR c ...) to get a single number from the first six chars of the string. Collision likelyhood is very high, but if we assume the string has to be the name of an actual search engine, then the collision likelyhood is fairly low. So, first we have i, which iterates through the string until s[i] is NUL (0), and while counting the length of the string, the selected char is XOR'd onto j, which is initialized to the first char in s. For "google", the result of this operation is 9. The main thing this takes advantage of is the way pointers work in C. A pointer is actually a large number that denotes an address in memory, &var will return a pointer to var, while *var will dereference a pointer (grab the value at that address). Thus, *s is equivalent to s[0]. I think this is where most beginners get lost, confused and frustrated when it comes to C, like when you try to send a struct * to a function that takes struct * by sending &struct_ptr, which would be a memory address to a memory address, effectively making the compiler give an error such as function expects 'struct *' but got 'struct **'. • Also, this function uses no library functions. I assume using strlen and strcmp is cheating and/or not worth the #include <string.h>. – Braden Best Sep 29 '15 at 21:39 • I think you need to give correct output for every string other than google. – lirtosiast Sep 29 '15 at 21:50 • @ThomasKwa Ah well, I tried. – Braden Best Sep 29 '15 at 22:02 # bash + coreutils, 57493836 33 bytes [ "$1" = google ];expr ${#1} /$?


Calling it with google produces expr: division by zero.

The quotes around $1 are required in order to handle the empty string correctly. The use of${#1} is shamelessly stolen from Tarod's answer.

• Good! But I think you're mixing bash & linux commands. If you want to, check my answer where I'm using bash to count characters. Happy coding! :) – Tarod Sep 29 '15 at 21:57
• @Tarod You're right, I should have said bash + coreutils. Combining your use of Bash to count the length of the input with my use of expr allows a shorter answer than either though - see my edit. – Ben just now edit – Ben Sep 29 '15 at 22:22
• Amazing! :D I'm going to upvote you! Good job, Ben! :) – Tarod Sep 30 '15 at 6:08
• BTW, I think you should set a new title for your answer. Just 'bash'. – Tarod Sep 30 '15 at 11:55
• I don't think so - expr seems to be part of coreutils. – Ben Sep 30 '15 at 13:16

# O, 20 characters

{."google"={@}{.e}?}


Sample run:

bash-4.3$java xyz.jadonfowler.o.O <( echo '{."google"={@}{.e}?} :f "yahoo" f o' ) 5 bash-4.3$ java xyz.jadonfowler.o.O <( echo '{."google"={@}{.e}?} :f "google" f o' )
java.lang.ArrayIndexOutOfBoundsException: Can't pop from empty stack!
java.lang.ArrayIndexOutOfBoundsException: Can't pop from empty stack!


# Scala, 36 34 30 29 characters

s=>(Set(s)-"google").max.size


Calling this function on "google" produces java.lang.UnsupportedOperationException: empty.max

• Nice idea! However, I'm afraid it does not compile, one must declare s's type: (s:String)=>... When I copy-paste it to scala's REPL I get <console>:1: error: ';' expected but '=>' found. – Jacob Mar 27 '16 at 14:58
• @Jacob it compiles if the type of s can be inferred from the context, e.g.: val s: String => Int = s=>(Set(s)-"google").max.size. – Ben Mar 27 '16 at 21:57
• If you want us to use it like that, you must add val s:String=>Int= to your answer. The answer should be a valid Scala expression as-is. – Jacob Mar 28 '16 at 2:06
• @Jacob it is a valid Scala expression as-is: an anonymous function is a perfectly valid self-contained answer. Valid Scala expressions aren't only those that can be pasted into the Scala REPL without context. The question asks for a function that takes a string and returns an integer: in contexts in which such a function is expected, the answer will compile. However, feel free to take this to Meta. – Ben Mar 28 '16 at 8:48

# Matlab, 50 51 bytes

Thanks to @rayryeng for removing 1 byte.

This uses an anonymous function, and exploits the fact that the error function with an empty input issues no error.

It's noteworthy that the error given for input 'google' is meta: it's an error using the error function.

@(s)eval('error(find(strcmp(s,''google''))),numel(s)')


Examples:

>> @(s)eval('error(find(strcmp(s,''google''))),numel(s)')
ans =
>> ans('abcd')
ans =
4

ans =
Error using error
The message must be specified as either a string or a message structure.

• You could potentially save a byte if you used strcmp! – rayryeng - Reinstate Monica Oct 1 '15 at 15:22
• Slight change to your error statement... still an isequal there! – rayryeng - Reinstate Monica Oct 1 '15 at 16:38
• @rayryeng Oops... I should have pasted the new thing from scratch! Corrected, thanks – Luis Mendo Oct 1 '15 at 16:41

## Perl 6, 19 bytes

{.comb/!/^google$/}  .comb returns list of characters in string (which in numeric context is a number of characters, I use this instead of .chars because it's shorter). Because there is nothing before a period, Perl 6 assumes you wanted to call a method on $_. This is divided by a negated match on regex ^google$ with implicit $_ variable. If it matches, the value becomes 0, and Perl 6 errors because of a division by zero.

Example:

> {.comb/!/^google$/}("qwerty") 6 > {.comb/!/^google$/}("google")
Attempt to divide 6 by zero using div
in any interactive at src/Perl6/Compiler.nqp line 62


# Java, 8468 37 bytes

b->b.equals("google")?1/0:b.length();


This is a java.util.function.Function<String, Integer> that divides by 0 if b is the string google.

# CoffeeScript 43 bytes

(g)->return g.length if g!="google";throw-1


Makes an anonymous function that throws -1 if the string is "google", and returns it's length otherwise. Not as obfuscated as I wanted, though.

Link to the online testing environment.

Another variation, 1 byte longer:

(g)->if g!="google"then g.length else throw-1

• Nah, too late. There is already a better answer in CoffeeScript... – Bojidar Marinov Sep 28 '15 at 18:15

## Lua, 42 Bytes

This challenge has made me realize how hard it is to cause an error in Lua.

x=io.read()print(x~="google"and #x or t())


Takes an input and if that input isn't google than print the length of the input, if not call a function t which doesn't exist, throwing an error.

• Can shave off one byte by removing the space before the '#x'. – ouflak Nov 22 '18 at 16:27
• Can shave off two more bytes on top of that by saying 'or~x' instead of 'or t()'. Throws a conversion error. – ouflak Nov 22 '18 at 16:38

## Prolog – 32 bytes

"google"*_:-x.
X*Y:-length(X,Y).


Defines a predicate (*)/2 that throws ERROR: */2: Undefined procedure: x/0 for the input "google":

?- "bing" * Length.
Length = 4.

ERROR: */2: Undefined procedure: x/0
Exception: (8) x ? no debug

• Ha nice! I tried a Prolog one and only got 56 chars (I'm a beginner). What does the * do? – whitfin Oct 6 '15 at 8:21
• @zackehh *, +, ... are valid names for predicates. They have to be written in infix notation and are quite handy for golfing because you can omit the parentheses and the comma for a predicate with two argument. a(A,B):-A is B.A*B:-A is B.: 3 bytes saved for every invocation. – kay - SE is evil Oct 6 '15 at 11:22
• learn something new every day, thanks! ;) – whitfin Oct 6 '15 at 15:11

^(google)|(.*)$/((^^\2))^^(1\1)  In rs, ^^ is the length and repetition operator. Used in the unary form, it will get the length of the following text (^^\2). Used in binary form, it will repeat the LHS RHS times ((^^\2))^^(1\1). Take the input bing. The input is not google, so the second group will match, not the first. Once the substitutions take place, the result is ((^^bing))^^(1). ^^ gets the length to result in (4)^^(1), and the result gets repeated 1 time to result in 4. However, if the input is google, the first group will match. That will result in ((^^))^^(1google) after substitutions. ^^ will just get the length of the empty string (0), so the result after ^^ is applied will be (0)^^(1google). Now the repetition operator can do its work...or not. See it will try to repeat 0 1google times. As 1google isn't a number, the output will be: Traceback (most recent call last): File "c callback", line 6, in <module> File "<string>", line 5, in <module> File "<string>", line 167, in main File "<string>", line 125, in run File "<string>", line 72, in expand ValueError: invalid literal for int() with base 10: '1google'  Live demo. (Put the input text in the box at the bottom left.) # PHP error via a warning(), 62, 52 46 bytes I feel dirty for these, but it isn't about pretty: function g($s){echo$s!=google?strlen($s):g();}


This will give "Warning: Missing argument 1 for g()" when you insert 'google', thought that was funny.

function g($s){echo$s!=google?strlen($s):die(err);} function g($s){if($s!=google){return strlen($s);}die(error);}

# PHP error as string, 46 bytes

function g($s){echo$s!=google?strlen($s):err;}  String dont have to be quoted (but should be!) You can run these via the commandline using g($argv[1]);, or via an older PHP version's register_globals method as an GET g($_GET['string']) or whichever :) • If it is to play a bit 'dirty', you could use err instead, since it is a common abbreviature – Ismael Miguel Sep 29 '15 at 14:14 • You mean instead of the string 'error'? I wan't too sure about wether to count those bytes, so I just left it there, it's about the logic anyways. – Martijn Sep 29 '15 at 14:16 • It is. But hey, everybody knows what err means, and you save 2 bytes! Some used undefined variables to show errors. Why can't you use an abbreviation!? – Ismael Miguel Sep 29 '15 at 14:24 • I guess your right, changed it. Still thinking of another method. I could simply call a undefined function, would safe me even more, but I tough of that as cheating – Martijn Sep 29 '15 at 14:57 • That's quite a funny alternative! I wouldn't have though of that! – Ismael Miguel Sep 30 '15 at 9:10 # C# 4.0, 51 bytes int g(string s){return s.Length/(s!="google"?1:0);} Sample: string userInput = Console.ReadLine(); Console.WriteLine(g(userInput));  Output: // "pogi" 4 // "google" DivideByZeroException was unhandled  # C++14, 47 bytes [](auto s){return s=="google"?throw:s.size();};  This is a generic lambda expression in C++14. It simply checks if the argument (string) is "google" and calls terminate if it is - else it returns the length of the string. It can be called as such: [](auto s){return s=="google"?throw:s.size();}("some_string"s);  Zereges has a very similar answer here written in C++11. Since this was C++14 it was O.K. by him for me to post this. ## Befunge-93, 59 characters <+1\_v#+1:~ vp00$<
<*_v#:\
v_v>$"google"*****-!# < >00g.@>1  Befunge has no way to actually throw an error, so I just push an "infinite" number of 1s onto the stack. An error will happen somewhere eventually... ### Explanation Anyway, this works by reading in the input and simultaneously keeping track of its length. <+1\_v#+1:~  This length is stored at location 0,0. vp00$<


The remaining numbers are multiplied together.

<*_v#:\


This is then compared to the product of "google".

v_v>$"google"*****-!#  If they are the same (i.e., if their difference is zero), then the "error" is thrown. Otherwise, the value stored at 0,0 is retrieved and outputted. < >00g.@>1  # PHP 5.4, 81 bytes <?function g($s){eval('if(isset('.($s==google?"$s":'$s').'))print strlen($s);');}
// following added for easy testing, not included in bytes count
g($argv[1]);  Everyone's favourite error when searching for Google! Didn't work out quite as obfuscated as I'd hoped... Usage: php 58891.php 'test' 4 php 58891.php 'google' # error  • Just thought I'd point this out: the challenge ID is 58891, not 85591. Otherwise, good job! – clap Oct 6 '15 at 1:59 • @ConfusedMr_C hah, good spot! I'd like to say I did that deliberately, but that would definitely be a lie! – Dom Hastings Oct 6 '15 at 4:43 # O, 17 bytes {e\"google"=L@N?} To use this function: "wow" {e\"google"=L@N?} ~ Explanation: e\ Get the length of the string and swap it on the stack "google"= Compare the string ? If L@ True (it is google): Rotate top three elements on the stack, throwing an underflow error N False (it is not google): do nothing Length is printed out automatically  # PARI/GP, 21 19 bytes x->#x/(x!="google")  Example: ? g = x->#x/(x!="google") %1 = (x)->#x/(x!="google") ? g("bing") %2 = 4 ? g("google") *** at top-level: g("google") *** ^----------- *** in function g: #x/(x!="google") *** ^-------------- *** _/_: impossible inverse in dvmdii: 0. *** Break loop: type 'break' to go back to GP prompt break>  # Ruby, 4632 29 bytes ->s{b=Hash.new(0);b['google']=nil;b[s]+s.size}  New shortened approach: ->g{(g.to_a-['google'])[0].size}  Reduced 3 bytes with manatwork's suggestion ->g{([g]-['google'])[0].size}  • Couple of tips to shorten it: new(0)new 0; nilp. Possibly more tips to shorten it: Tips for golfing in Ruby. – manatwork Nov 26 '15 at 15:44 • Found different approach. Thanks anyway :) @manatwork – Vasu Adari Nov 26 '15 at 15:59 • Interesting. Which Ruby version? The 2.1.5 I use has no String#to_a method. But with the shorter [g]-['google'] works. – manatwork Nov 26 '15 at 16:02 • I missed it. Thank you very much :). My ruby version is 2.0.0p576. – Vasu Adari Nov 26 '15 at 16:08 # Japt, 16 14 bytes (non-competing) U¥goog¤?Δ:Ul  Throws reference error on input of "google". Try it online! • Nice! Two tips: 1) "google" can be compressed to goog¤, wrapped in backticks. 2) == can be compressed to ¥. – ETHproductions Nov 26 '15 at 15:36 • Totally ignored compression. I have only scratched the surface of your language @ETHproductions, and thought this may be a great starting point for it. The \u<hex> shorthands are easily missable, better put it inside the docs. – noisyass2 Nov 27 '15 at 2:24 • I've added a section on Unicode shortcuts in the online interpreter. @ThomasKwa You are correct. I've edited the post. – ETHproductions Dec 4 '15 at 17:14 # 05AB1E, 10 bytes (non-competing) Non-competing, since the language postdates the challenge. Code: g“Š¹“¹Q</Ä  Explanation: g # Take the length of the implicit input “Š¹“ # Compressed version of "google" ¹Q # Take the first input again and check if equal to "google" < # Decrement on the bool / # Divide the length by the value Ä # Take the abstract value of the result # This is then implicitly printed  Try it online!. When the input is google, nothing is printed due to a division by zero exception. • *absolute value – Oliver Ni Feb 6 '17 at 2:08 # Gogh, 20 bytes ÷GD$"google"={¤+}¦:$ Usage: ./gogh o '÷GD$"google"={¤+}¦:$' "google"  ### Explanation  “ Implicit input ” ÷ “ Duplicate the input ” GD “ Push a range of [1, len(input)] ”$            “ Rotate input to the TOS                                     ”
{¤+}¦:       “ Error if equals "google" (empties stack and tries addition) ”
\$            “ Leave the length on the stack                               ”
“ Implicit output                                             ”

• Note: this answer is non-competing. – Zach Gates Mar 26 '16 at 3:39
• Gogh is epic. Just saying. – Rɪᴋᴇʀ Mar 26 '16 at 3:53

# Julia, 26 24 chars

Two characters shorter now, thanks to Dennis.

The challenge says ‘[...]in as few amount of Unicode characters as possible’, so I’m going for ≠ and ℕ in my solution.

Anonymous function. Just assign it to a variable:

f->f≠"google"?endof(f):ℕ


In the case of "google" you get the error message:

julia> (f->f≠"google"?endof(f):ℕ)("google")
ERROR: UndefVarError: ℕ not defined


As ordinary function (26 chars):

x(f)=f≠"google"?endof(f):ℕ


ℕ is an unassigned variable, so it produces an error message. If that doesn’t count or is against the rules, then just using !f (one char longer) instead would produce an error anyway. Boolean not is not defined for strings.

# Fuzzy Octo Guacamole, 19 bytes (non-competing)

"google".^={e}_!r_;


"google' pushes the string "google" to the stack.

. swaps the active stack.

^ gets input.

= is the rocketship operator, pushes 0 for equality, -1 for less than, and 1 for greater than as x <=> y with x as the top of the active stack, and y as the top of the inactive one.

{ and } denote an if statement, like bf's goto/if thing. Skips the code inside braces if the top of the stack is truthy.

e errors. That's it.

_ pops the stack, this time is just to remove the equality check result and show the input.

! sets the universal register to the top of the stack, or the length of the top of the stack for strings/lists.

r clears the register and pushes it back to the stack.

_ pops again, and

; prints.

So this checks for equality, then does a clumsy cast to int, and than prints the result.

• the quotes... aren't maTCHED the song of unmatched quotes will exti​nguish the voices of mor​tal man from the sp​here I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful t​he final snuffing of the lie​s of Man ALL IS LOŚ͖̩͇̗̪̏̈́T ALL I​S LOST the pon̷y he comes he c̶̮omes he comes the ich​or permeates all MY FACE MY FACE ᵒh god no NO NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨe̠̅s ͎a̧͈͖r̽̾̈́͒͑e n​ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂҉̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ – cat Mar 26 '16 at 12:10
• -1 for unmatched quotes ಠ_ಠ – cat Mar 26 '16 at 12:15
• @tac they represent the beginning and end of the string literal. That is intentional. – Rɪᴋᴇʀ Mar 26 '16 at 15:31
• I know that, I just don't know why anyone would willingly create a language that uses unmatched things. (I know many golfing languages do it and it makes my eyes bleed) – cat Mar 26 '16 at 15:32
• @tac I can make it work with matched ones also if you want. – Rɪᴋᴇʀ Mar 26 '16 at 15:39

# C++14, 42 chars

For giggles, as I did not see a very good c++ solution. My TI-89 solution is superior at 34 bytes

[](auto s){return s.size()/(s!="google");}