# VEVO User Account Checker

We often see music videos on Youtube. Many Youtube channels that host music videos are "powered by VEVO". Those can be easily identified by both embedding VEVO at their video thumbnails and appending VEVO to their channel name.

Now write some code to test whether a string given by user is a VEVO user account or not.

Requirements for valid VEVO user account strings:

• Must only contain uppercase, lowercase, and digit characters. (no whitespace or punctuation)

• Must not exceed 80 characters length.

• Must have "VEVO" substring at the end of string

Test cases:

Valid inputs:

AdeleVEVO
ConnieTalbotVEVO
SHMVEVO
justimberlakeVEVO
DJMartinJensenVEVO
test123VEVO


Invalid inputs:

syam kapuk
jypentertainment
Noche de Brujas
testVEVO123


Of course, because this is , I'm looking for the shortest code using any programming language.

• Nice first question! +1 – LiefdeWen Dec 21 '17 at 10:47
• test-cases: VEVO and ūņīčōdēVEVO – dzaima Dec 21 '17 at 11:02
• other suggested test cases: test123VeVo and one with more than 80 characters – Arnauld Dec 21 '17 at 11:09
• You should wait a lot longer before accepting a best answer; the question has only been up for an hour and there are plenty more languages that people might answer in! – Luke Stevens Dec 21 '17 at 11:56
• "uppercase, lowercase, and digit characters" requires defining (I would assume (as, I believe, all have done already) that you mean A-Za-z0-9; but it could mean anything that may be uppercased or lowercased, for example ạ and Ạ and digits in other alphabets, for example 九 (9). – Jonathan Allan Dec 21 '17 at 21:19

# Python 2, 45 bytes

-3 bytes thanks to Rod. -2 bytes thanks to ovs.

lambda s:len(s)<81*s.isalnum()<'VEVO'==s[-4:]


Try it online!

A regex solution turns out to be longer.

lambda s:re.match('^[^\W_]{0,76}VEVO$',s) import re  # Japt v2.0a0, 20 16 bytes Returns 1 for valid or 0 for invalid. [\l\d] would also work in place of [^\W_] for the same byte count. è/^\w{0,76}VEVO$


Explanation: è counts the number of matches of the RegEx in the input. In Japt, the \w RegEx class doesn't include underscore.

• Nice one. Best I could do without regex is ;¥oB+mc)¯80 ©"VEVO"¥Ut4n – ETHproductions Dec 21 '17 at 14:13
• @ETHproductions, nice trick with B+mc :) By the way, if Japt2 had a character class for [A-Za-z0-9], we could beat Retina here! Might even be worth overriding \w & \W. – Shaggy Dec 21 '17 at 15:37
• Heh, I think I was actually planning to do that originally... I should get back to work on Japt in general :P – ETHproductions Dec 21 '17 at 15:48

# JavaScript (ES6), 273634 31 bytes

Saved 2 bytes thanks to @Neil and 3 bytes thanks to @Shaggy

s=>/^[^\W_]{0,76}VEVO$/.test(s)  ### Test cases let f = s=>/^[^\W_]{0,76}VEVO$/.test(s)

console.log(f('syam kapuk')) // (INVALID)
console.log(f('jypentertainment')) // (INVALID)
console.log(f('Noche de Brujas')) // (INVALID)
console.log(f('testVEVO123')) // (INVALID)
console.log(f('ConnieTalbotVEVO')) // (VALID)
console.log(f('SHMVEVO')) // (VALID)
console.log(f('justimberlakeVEVO')) // (VALID)
console.log(f('DJMartinJensenVEVO')) // (VALID)

• Doesn't \w match _s as well? – Neil Dec 21 '17 at 11:19
• I think ((?!_)\w) saves 2 bytes. – Neil Dec 21 '17 at 11:28
• Would [^\W_] work for a 3 byte saving? – Shaggy Dec 21 '17 at 12:14
• @Shaggy Heck. For some reason, I was thinking such characters classes were not working within character sets. Thanks! – Arnauld Dec 21 '17 at 12:41
• Doesn't JS have any way of skipping the lambda? Like /^[^\W_]{0,76}VEVO$/.test or something? – totallyhuman Dec 21 '17 at 18:02 # PHP, 51 bytes -10 bytes thanks to @Ismael Miguel for using <?= instead of <?php echo! and removing the closing tag <?=preg_match("/^[^\W_]{0,76}VEVO$/",fgets(STDIN));


Try it online!

Thanks for the other answers so I didn't have to write the regex!

• Instead of <?php echo, you can do <?=preg_match("/^[^\W_]{0,76}VEVO$/",fgets(STDIN));. – Ismael Miguel Dec 22 '17 at 1:50 • You're welcome. You can leave out the closing PHP tag. Quoting the documentation: "If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file." (php.net/manual/en/language.basic-syntax.phptags.php). This should save you 2 more bytes. Also, instead of [^\W_], just use \w, which is the same as [a-zA-Z_]. – Ismael Miguel Dec 22 '17 at 15:47 • Thanks as well, I have a few answers to update now! – NK1406 Dec 22 '17 at 15:49 • You're welcome. One advice: reading the documentation and getting familiar with it will help a lot. – Ismael Miguel Dec 22 '17 at 15:52 # APL (Dyalog), 25 bytes ≢'^[^_\W]{0,76}VEVO$'⎕S 3


Try it online!

# C (gcc), 83 bytes

c,i;f(char*s){for(c=i=0;s[i];c+=!isalnum(s[i++]));c=i<81*!c*!strcmp("VEVO",s+i-4);}


Try it online!

• I don't see any return statement, how does this return c? Undefined behavior? – MD XF Dec 22 '17 at 3:33
• @MDXF This is indeed undefined behavior and an abuse of how gcc uses the same registers for variable assignment and return values (see tips for golfing in C ). This is not portable and does not necessarily work with other compilers (for instance it doesn't work with clang) – scottinet Dec 22 '17 at 9:12
• that's very impressive. How did you find that out? – MD XF Dec 22 '17 at 22:26
• sometimes f("VO" also be true, when before is "VI" stored; or maybe fault – l4m2 Dec 29 '17 at 6:56

# Dyalog APL, 47 bytes

{0::0⋄(∧/(1(819⌶)t)∊⎕A,⎕D)∧77>≢t←,∘'VEVO'⍣¯1⊢⍵}


Try it online!

A pure regex solution is 32 bytes, but also is much more boring than this approach.

{0::0⋄(∧/(1(819⌶)t)∊⎕A,⎕D)∧77>≢t←,∘'VEVO'⍣¯1⊢⍵} a dfn with right arg '⍵'
0::0⋄                                          on error, return 0
,∘'VEVO'       a train that appends VEVO
⍣¯1    apply it -1 times
⍵  on '⍵'
and error if impossible (which returns 0)
t←               save on variable 't'
≢                 get the length of that
77>                  if that's smaller than 77
∧                     and
(1(819I)t)                              [for each of] 't' uppercased
∊⎕A,⎕D                        is it in the uppercase alphabet concatenated with the digits
∧/                                        reduced by and

• Instead of using ⍣¯1 to check for VEVO and needing the dfn guard, you can do 'VEVO'≡¯4↑⍵. Moving things around a bit gets me {('VEVO'≡¯4↑⍵)∧∧/⍵∊⎕D,⎕A,(819⌶)⎕A} – user41805 Dec 21 '17 at 18:24
• @Cowsquack yeah, I might have forgotten about ↑.. There are other better ways to do this challenge though (i.e. Eriks answer) and I like this idea :p – dzaima Dec 21 '17 at 18:34

# Grime, 13 bytes

en{-76"VEVO"


Try it online!

Nothing fancy here. Match the entire input against the pattern: at most 76 alphanumeric characters, followed by the string VEVO. Prints 1 for match and 0 for no match. I remembered that the last quote could be removed at end of line, but apparently it just causes a parse error.

# C# (.NET Core), 87 + 18 = 105 bytes

Try it online!

a=>a.Where(x=>char.IsLetterOrDigit(x)).Count()==a.Length&a.Length<81&a.EndsWith("VEVO")

• Wouldn't this fail if the input contains any non-alphanumeric characters? – Shaggy Dec 21 '17 at 12:21
• @Shaggy You are right, will fix a bit later. – LiefdeWen Dec 21 '17 at 13:05
• I have checked with TIO and found that input "ConnieTalbotVEVO" (which should be valid input) was falsely declared as invalid input. – Bagas Sanjaya Dec 21 '17 at 23:32
• @BagasSanjaya It is because I put tabs after it in the test case, take the tabs out and it will be the same as the test case above and will work. – LiefdeWen Dec 22 '17 at 5:56
• 73+18: a=>a.All(x=>char.IsLetterOrDigit(x)&x<123)&a.Length<81&a.EndsWith("VEVO") only ASCII letters or 67+18: a=>a.All(x=>char.IsLetterOrDigit(x))&a.Length<81&a.EndsWith("VEVO") with unicode support – dg3 Dec 22 '17 at 10:50

# ><>, 147 125 bytes

!\i:0(?^1[::::::"/9@Zz"!
;>{(?;{(?v{(?;{(?v{(?;{(?v
~l1-?!v >       > !|!: !<
;v    ]/~l99*-0(?!;4["OVEV"{-?;{-?;{-?;{-?;1n


Try it online!

# ><>, 147 bytes

Try it online!

This prints 1 if the input string is valid and nothing for an invalid input.

Edit 1: Changed the Alphanumeric checks to use ranges rather than comparing against every character. (saving 22 bytes)

• I don't have the time right now to golf this, but I'm pretty sure you can lose bytes by doing comparisons to character codes. The gist of it would be to reject things less than '0' and greater than 'z' and then reject things between '9' and 'A' as well as between 'Z' and 'a'. – cole Dec 21 '17 at 17:14
• @cole :- I wasn't at my PC to change this yesterday after the post but you are right, comparisons do cut a bit off. I'm sure if you scan across the code you may be able to drop some extra bytes off. – Teal pelican Dec 22 '17 at 10:26

# Bash, 5326 30 bytes

[[ $1 =~ ^[^\W_]{0,76}VEVO$ ]]


Exit code 0 for VALID results and 1 for INVALID results.

Still working on 80 characters or less.

-27 bytes from removing output, thanks to @KeyWeeUsr

+4 bytes, fixed regex (same as everyone else)

Try it online!

• You can just echo 1 for true, or just go without any echo. There's no need to echo anything as you still end up with an exit code that you actually check with && and || – KeyWeeUsr Dec 21 '17 at 17:41
• Okay, wasn't sure what sort of output (if any) was required. The question didn't really say. – Probably Dec 21 '17 at 17:47
• The idea of 'truthy' is explained here codegolf.meta.stackexchange.com/q/2190/16658 and is generally implied universally unless specified as otherwise – Sirens Dec 22 '17 at 7:32
• This doesn't output anything on TIO. Also, your RegEx allows underscores, which it shouldn't. And you're not checking for length. We require solutions to be fully functional here, works in progress shouldn't be posted. I'd recommend deleting it until you can fix the problems. (On a related note, why do people upvote solutions that clearly don't work?) – Shaggy Dec 22 '17 at 10:35
• @Shaggy The output is via exit code. – totallyhuman Dec 24 '17 at 17:38

# ><>, 101898381 94 bytes

Edit: Switched to checking for non-alphanumeric characters rather than for alphanumeric. Switched back cause I forget to check between Z and a. Thanks @Emigna. Rip those lost bytes though

Edit 2: Also, I can totally just get rid of those }}}}. Thanks Teal pelican for that and finding the problem with TIO

Edit 3: replaced a ~~~ with a p

!\i::0(?v:::"/")$":"(*$:"")$"{"(*+$:"@")$"["(*+? 0/?("S"l/ l/"VEVO"[4pn?$0(6
!\{-?vl?
1/;n0/n


I don't know why this won't work on TIO, but it works fine here. The problem was that the {} commands in TIO don't work for an empty list. Try It Here

### How It Works

!\i::0(?v:::"/")$":"(*$:"")$"{"(*+$:"@")$"["(*+? 0/....../ ......... Checks each input is alphanumeric ... If any isn't, print 0 and exit with an error ... ... 0/?("S"l/ Checks if there are more than 80 characters ... If so, print 0 and exit with an error ... ... ... ... l/"VEVO"[4pn?$0(6 Check if the input is less than 4 characters
...               If so, print 0 and exit with an error
...

...
...
./"VEVO"[4pn?$0(6 Take the last 4 characters of the input into a new stack (first time I've actually used [) ... Add "VEVO" to the stack to compare ... ... 0/....../n ........V !\{-?vl? Check if the last 4 characters are VEVO 1/;n0/n Print 1 and exit with an error if so, else print 0 and exit  For consistency, replacing the ; in the last line with an invalid instruction makes every output an error. • I believe your TIO error might be how it works with ordering on the ending stack split. TIO LINK HERE Having a mess around in TIO you can change it to this. – Teal pelican Dec 22 '17 at 11:52 • Thanks @Tealpelican. Fixed that and killed a few more bytes – Jo King Dec 22 '17 at 12:40 • You are missing the check for characters between "Z" and "a". – Emigna Dec 22 '17 at 12:55 • @Emigna Oops, thanks! Fixed! – Jo King Dec 22 '17 at 13:00 ## C++, 129105 102 bytes Thanks to other answers that showed me that i can count the number of characters -2 bytes thanks to Zacharý #include<regex> int v(std::string s){return std::regex_match(s, std::regex("[a-zA-Z0-9]{0,76}VEVO"));}  TIO LINK • Where's TIO link at your answer? I'd like to test your code... – Bagas Sanjaya Dec 23 '17 at 7:16 • Forgive me if this is a lack of knowledge of C++. Can you move remove the variable r, and just have the regex inside the call to std::regex_match? – Zacharý Dec 23 '17 at 15:33 • There is an unneeded space after the comma – Zacharý Dec 24 '17 at 16:12 • You can remove the comma the space after the comma. – Zacharý Dec 4 '18 at 18:30 # Stacked, 21 bytes ['^\i{0,76}VEVO'-''=]  Try it online! # 05AB1E, 21 bytes žKÃQsg81‹IR4£"OVEV"QP  Try it online! # Java (OpenJDK 8), 37 36 bytes Pretty simple answer using some lovely regex. Quite possibly the shortest Java answer I've ever done. -1 bytes thanks to Neil on the Javascript answer w->w.matches("((?!_)\\w){0,76}VEVO")  Try it online! # Retina, 18 bytes A\W|_|.{81} VEVO$


Try it online!

or

^[^\W_]{0,76}VEVO$ Try it online! # Haskell, 75 bytes -2 bytes thanks to user28667. import Data.Char f s|l<-length s=all isAlphaNum s&&l<81&&drop(l-4)s=="VEVO"  Try it online! • -2 bytes if you use drop(length s-4) and extract length s – user28667 Dec 21 '17 at 15:38 # Deorst, 22 bytes '^[^\W_]{0,76}VEVO$'gm


Try it online!

Just uses the regex found by Shaggy

# V, 17 bytes

ø^¨áüä©û,76}VEVO$ Try it online! Hexdump: 00000000: f85e a8e1 fce4 a9fb 2c37 367d 5645 564f .^......,76}VEVO 00000010: 24$


Compressed regexes for the win!

ø                   " Count the number of matches of
^                  "   The beginning of the line
¨áüä©             "   A letter or number...
û,76}        "   From 0 to 76 times...
VEVO    "   Followed by "VEVO"
$" At the end of the line  # Ruby -n, 22+1 = 23 bytes p~/^[^\W_]{0,76}VEVO$/


Output 0 if true, nil if false

Try it online!

Using the same boring regex as everybody else.

import Foundation;var f={(s:String)->Bool in s.range(of:"^[^\\W_]{0,76}VEVO$",options:.regularExpression) != nil}  Try it online! # AWK, 23 bytes $0~/^[^\W_]{0,76}VEVO$/  Try it online! Outputs the account name if valid, and outputs nothing if it isn't valid # Clean, 61 bytes import StdEnv ?['VEVO']=True ?[_:l]=length l<80&& ?l ?_=False  Try it online! # Perl 5, 35 29+1(-a) = 30 bytes -6 bytes thanks to ETHproductions Added 4 bytes. Didn't see that underscore wasn't allowed. This is my first golf, so here's hoping I did it right. Returns 1 if valid, 0 if not. print/^[^\W_]{0,76}VEVO$/?1:0


Try it online!

• Welcome to PPCG! You can remove extraneous whitespace to get down to 25 (+1) bytes: print/^\w{1,76}VEVO$/?1:0 – ETHproductions Dec 21 '17 at 22:16 • +0 converts match bool into number, rather than ?1:0, saves 2 bytes. Calling with -ple prints $_ for you. So: perl -ple '$_=/^[^\W_]{0,76}VEVO$/+0'. 25 bytes. If you are happy to get blanks on non-matching lines, $_=/^[^\W_]{0,76}VEVO$/ is 23 bytes. – Phil H Dec 22 '17 at 11:06

Anonymous worksheet function that takes input from range A1 and outputs to the calling cell

=RegexMatch(A1,"^[^\W_]{0,76}VEVO

• Where's the closing bracket? – Bagas Sanjaya Jan 2 '18 at 9:11
• @BagasSanjaya that's one of the wonderful things about Google Sheets, it autocompletes unclosed strings and groups. So when this is pasted into a cell and you either click off the cell or press enter GS converts this to =RegexMatch(A1,"^[^\W_]{0,76}VEVO") without any feedback to the user and executes – Taylor Scott Jan 2 '18 at 13:55

# Clojure, 146 bytes

(fn[u](let[c count](and(<(c u)81)(=(c(filter #(let[i(int %)](or(< 47 i 58)(< 64 i 91)(< 96 i 123)))u))(c u))(clojure.string/ends-with? u"VEVO"))))


Try it online!

This would be much shorter using a regex, but I figured doing it manually would be more interesting.

(defn vevo? [username]

• @BagasSanjaya I added a link. Unfortunately TIO seems broken. It can't find the ends-with?` function, even though that's part of the standard library. – Carcigenicate Jan 6 '18 at 22:34