Bernardino identifies unaltered dollar words

47

3

Definition

A dollar word is a word where when each of its letters is given a cent value, from a = 1 to z = 26, and the letters are summed, the result is 100. Here is an example on CodeReview, and here is a list of dollar words I found online.

Input

Input will be alphabetical from a-z, in your one language's text datatypes (arrays are allowed). You do not need to account for any other input - there will be no spaces, apostrophes, or hyphens. You can take as lowercase, uppercase, or a combination. Trailing newlines are allowed.

Output

Output a truthy value if the input is a dollar word, and a falsey value if it is not.

Test Cases

Truthy:

buzzy
boycott
identifies
adiabatically
ttttt

Falsey:

zzz
zzzzzzz
abcdefghiljjjzz
tttt
basic

This is code-golf, so the shortest answer in bytes wins! Standard loopholes and rules apply. Tie goes to first poster.

Stephen

Posted 2017-04-18T20:56:40.603

Reputation: 12 293

20Title has dollar words in it, sorry if it threw you off. – Stephen – 2017-04-18T20:56:58.977

Answers

7

GS2, 6 bytes

▲1Θd←q

Input must be in uppercase.

Try it online!

How it works

  Θ       Combine the previous two tokens into a block and map it over the input.
▲             Push 64.
 1            Subtract 64 from the character on the stack.
   d      Take the sum of the resulting character array.
    ←     Push 100.
     q    Compare the two items on the stack for equality.

Dennis

Posted 2017-04-18T20:56:40.603

Reputation: 196 637

13

Python, 39 38 bytes

lambda s:sum(ord(i)-96for i in s)==100

Try it online!


-1 byte thanks to @JonathanAllan

ovs

Posted 2017-04-18T20:56:40.603

Reputation: 21 408

12

05AB1E, 8 bytes

Code:

Ç96-O4bQ

Uses the CP-1252 encoding. Try it online!

Explanation:

Ç          # Convert the string into a list of character codes
 96-       # Subtract 96 of each element
    O      # Take the sum
     4b    # Push 100 (4 in binary)
       Q   # Check if equal

Adnan

Posted 2017-04-18T20:56:40.603

Reputation: 41 965

2Tn works too :P – Magic Octopus Urn – 2017-04-19T14:34:22.543

Ç4+OTn%0Q was another idea I had, but it's worse. – Magic Octopus Urn – 2017-04-19T17:25:29.713

11

Perl 6, 21 bytes

{100==[+] .ords X%32}

Try it

Alternate:

{Ⅽ==[+] .ords X%32}

Try it

Note that the is ROMAN NUMERAL ONE HUNDRED U+216D with a unival of … 100
Which takes 3 bytes to encode.

Expanded:

{  # bare block lambda with implicit parameter $_

  100     # is 100
  ==      # equal to
  [+]     # the sum of the following

    .ords # the ordinals of the input (implicit method call on $_)
    X[%]  # crossed using the modulus operator
    32    # with 32 to get 65..90 or 97..122 to become 1..26
}

Brad Gilbert b2gills

Posted 2017-04-18T20:56:40.603

Reputation: 12 713

11

MATL, 8 bytes

96-s100=

Uses lowercase input.

Try it online!

Explanation

The code is as readable as it gets:

96-   % Implicitly input string. Subtract 96 from each char interpreted as ASCII code
s     % Sum of array
100=  % Does it equal 100? Implicitly display

Luis Mendo

Posted 2017-04-18T20:56:40.603

Reputation: 87 464

7

JavaScript (ES6), 46 bytes

Returns 0 or 1.

let f =

w=>[...w].map(c=>p-=parseInt(c,36)-9,p=100)|!p

console.log(f('buzzy'))
console.log(f('qwerty'))

Arnauld

Posted 2017-04-18T20:56:40.603

Reputation: 111 334

Interestingly when I tried reduce and recursion they both came out 2 bytes longer. – Neil – 2017-04-19T00:06:01.653

@Neil Actually, it was using reduce() during the first few minutes of the grace period when I initially posted it. – Arnauld – 2017-04-19T10:50:14.777

7

C, 45 43 bytes

Thanks to @Neil for saving two bytes and making the solution case-insensitive!

n;f(char*s){for(n=100;*s;)n-=*s++&31;n=!n;}

Try it online!

Steadybox

Posted 2017-04-18T20:56:40.603

Reputation: 15 798

Seems like you can save a byte by setting n=0 globally and then skipping the first clause of the loop spec, no? edit: never mind—I guess that would only work for the very first call. – Julian Wolf – 2017-04-18T21:23:35.200

3Could counting down from 100 save bytes? Also, &31 might work to make your code case insensitive. – Neil – 2017-04-19T00:09:28.953

Out of curiosity, how does n=!n work? I understand it checks if n is zero, because based on some test I see !0 returns 1; !15 returns 0; and !-15 returns 0 as well. But why? Which operand is ! in C when using it as !integer? – Kevin Cruijssen – 2017-04-19T12:11:00.240

@KevinCruijssen ! is just the logical not. In C, 0 means false, and any other integer value means true. So !0 == 1, and !n == 0 for every n != 0. – Steadybox – 2017-04-19T12:15:32.927

@Steadybox Ah, I didn't knew this part: "and any other integer value means true", but it indeed makes sense. I always (incorrectly) thought of it as 0=false; 1=true instead, hence my confusion. Thanks for the answer. – Kevin Cruijssen – 2017-04-19T12:39:44.263

7

Haskell, 32 bytes

f s=sum[1|c<-s,_<-['a'..c]]==100

Try it online!

The idea is to make a list of characters from a to the given character for each character in the list, and check that the total length is 100.

Other attempts:

f s=sum[1|c<-s,_<-['a'..c]]==100

f s=sum[fromEnum c-96|c<-s]==100
f s=100==length((\c->['a'..c])=<<s)
(==100).length.(>>= \c->['a'..c])
(==100).length.(=<<)(\c->['a'..c])
(==100).length.(enumFromTo 'a'=<<)
f s=100==length(do c<-s;['a'..c])

Too bad enumFromTo is so long.

xnor

Posted 2017-04-18T20:56:40.603

Reputation: 115 687

1You're right that the length is a shame—(100==).length.(enumFromTo 'a' =<<) is such a clean use of point-free-ness – Julian Wolf – 2017-04-19T23:58:11.487

6

Jelly, 9 7?* 8 bytes

ɠO%32S⁼³

Full program, outputting 1 if the input is a dollar word, or 0 if not.

Try it online!

How?

ɠO%32S⁼³ - Main link
ɠ        - read a line of input from STDIN
 O       - cast to ordinals
  %32    - mod 32 (vectorises) (-3*32=96 from lowercase; -2*32=64 from uppercase)
     S   - sum
       ³ - literal: 100
      ⁼  - equal?

* Could it be 7 bytes?

The only reason this took input with ɠ was to keep ³ as the literal 100 rather than the 3rd command line input (1st program input).

A way to avoid that would be, as pointed out by Dennis, to create 100 using the raw literal form ȷ2 which is 102. This leads to another 8 byte O%32S=ȷ2, but this is now an unnamed monadic function (as well as operating as a full program with a 3rd argument).

Since, in golf, one may create variables or helper functions which restrict the program in which they may reside (one cannot reuse the name in-scope without stopping the function from being reusable), maybe restricting the program to only taking input from STDIN may also be acceptable, in which case the 7 byte O%32S=³ would be acceptable here as an unnamed function.

Jonathan Allan

Posted 2017-04-18T20:56:40.603

Reputation: 67 804

1Alternatively, O%32S=ȷ2. Works for uppercase and lowercase input. – Dennis – 2017-04-18T21:18:34.860

@Dennis It may be borderline but wouldn't O%32S⁼³ actually be a valid entry as it does define an unnamed, reusable function, so long as the rest of the program it is in does not use command line arguments for input? – Jonathan Allan – 2017-04-18T21:43:45.323

Hm, I guess that could be done. Not that different from using a global variable in C, for example. – Dennis – 2017-04-18T21:59:42.727

6

Haskell, 32 bytes

f w=sum[fromEnum c-96|c<-w]==100

This works for lowercase input. For uppercase, s/96/64/. Mixed-case support would add a bunch of bytes.

Julian Wolf

Posted 2017-04-18T20:56:40.603

Reputation: 1 139

6

Mathematica, 23 bytes

100==Tr@LetterNumber@#&

Pure function taking a string (or an array of letters) as input, case-insensitive, and returning True or False. Here Tr just adds the letter-numbers together; everything else is self-explanatory.

Greg Martin

Posted 2017-04-18T20:56:40.603

Reputation: 13 940

6

R, 55 54 bytes

function(x)sum(match(el(strsplit(x,"")),letters))==100

-1 byte thanks to BLT

  • returns a function that does the required computation, which returns TRUE and FALSE as one would expect.

  • takes input in as lowercase; would only be a switch from letters to LETTERS for all uppercase

Giuseppe

Posted 2017-04-18T20:56:40.603

Reputation: 21 077

1function(x)sum(match(el(strsplit(x,"")),letters))==100 saves a byte. – BLT – 2017-04-19T00:35:20.170

6

Java 8, 36 bytes

s->s.chars().map(c->c%32).sum()==100

Try it online!

Note: case independent.

David Conrad

Posted 2017-04-18T20:56:40.603

Reputation: 1 037

6

Alice, 23 bytes

/o!
\i@/e)q&w[?'`-+k3-n

Try it online!

Input should be lower case. Prints 1 for dollar words and 0 otherwise.

Explanation

Time to show off Alice's tape and some advanced control flow. Despite being fairly good at working with integers and strings individually, Alice has no built-ins to a) determine a string's length, b) convert between characters and their code points. The reason for this is that all of Alice's commands either map integers to integers or strings to strings. But both of those would require mapping strings to integers or vice versa, so they don't fit into either of Alice's modes.

However, in addition to it's stack, Alice also has a tape and Cardinal and Ordinal mode interpret the data on the tape in different ways

  • In Cardinal mode, it's a regular tape familiar from other languages like Brainfuck. You can store one integer in each cell and you can move a tape head around. The tape is infinitely long and initially holds a -1 in every cell. The cells are also indexed and the tape head starts at index 0.
  • Ordinal mode has its own tape head (also starting at index 0) and it interprets the tape as a list of strings. Strings are terminated by non-character cells (i.e. any values which are not a valid Unicode code point), in particular -1. So for Ordinal mode, the tape is initially filled with empty strings.

This tape can be used for both of the above operations: to get a string length, we write it to the tape in Ordinal mode, seek the terminating -1 in Cardinal mode and retrieve the position of the tape head. To convert characters to their code points, we simply read them off the tape in Cardinal mode.

The other two important features used in this solution are the return stack and an iterator. Alice has a return stack which is usually filled when using the jump command j, and which you can pop an address from to jump back with k. However, it's also possible to push the current address to the return stack without jumping anywhere with w. If we combine w with the repeat command &, we can push the current address to the return stack n times. Now each time we reach k, one copy is popped off the return stack and we perform another iteration from w (starting at the cell after it, because the IP moves before executing another command). When the return stack becomes empty, k does nothing at all and the IP simply passes through. Hence &w...k pops an integer n and then executes ... n+1 times, which gives us a very concise way to express a simple for loop.

On to the code itself...

/     Reflect to SE. Switch to Ordinal.
i     Read the input word as a string.
      Bounce off bottom boundary, move NE.
!     Store the input word on the tape.
      Bounce off top boundary, move SE.
/     Reflect to E. Switch to Cardinal.
e     Push -1.
)     Seek right on the tape for a -1, which finds the -1 terminating
      the input word.
q     Push the tape head's position, which gives us the string length N.
&w    Repeat this loop n+1 times (see above for an explanation)...
  [     Move the tape head left by one cell.
  ?     Retrieve the code point of the character in that cell.
  '`    Push 96.
  -     Subtract it from the code point to convert the letters to 1...26.
  +     Add the result to a running total. This total is initialised to 
        zero, because in Cardinal mode, the stack is implicitly filled with
        an infinite amount of zeros at the bottom.
k    End of loop.
     Note that the above loop ran once more than we have characters in the
     string. This is actually really convenient, because it means that we've
     added a "-1 character" to the running total. After subtracting 96 to
     convert it to its "letter value" this gives 97. So dollar words will
     actually result in 100 - 97 = 3, which we can check against for one
     byte less than for equality with 100.
3-   Subtract 3 to give 0 for dollar words.
n    Logical NOT. Turns 0 (dollar words) into 1 and everything else into 0.
     The IP wraps around to the beginning of the first line.
\    Reflect to NE. Switch to Ordinal.
o    Implicitly convert the result to a string and print it.
     Bounce off top boundary, move SE.
@    Terminate the program.

Martin Ender

Posted 2017-04-18T20:56:40.603

Reputation: 184 808

Nice! I got 41 with my first try – user41805 – 2017-04-19T10:09:21.643

6

Ruby, 25 bytes

->s{s.sum-s.size*64==100}

Works for uppercase.

I see a couple of more complex Ruby entries, but it really is this simple. s.sum adds the ASCII codes of the input string, and from this we subtract 64 times the length of the string.

Example of use

f=->s{s.sum-s.size*64==100}

puts f["ADIABATICALLY"]
puts f["ZZZ"]

Level River St

Posted 2017-04-18T20:56:40.603

Reputation: 22 049

This only works on Ruby 2.4 and currently does not work on TIO – G B – 2017-04-24T05:51:35.407

1@GB thanks for the comment but I'm running on 2.2.6 and it works fine for me. The feature has been documented since 1.9.3. It works on TIO.run and Ideone.com for me too. – Level River St – 2017-04-24T19:32:28.793

You are right, I thought it was the same as Array#sum, which is new in 2.4 – G B – 2017-04-25T05:29:01.590

Actually, it's not the sum of ASCII values, the definition is "Returns a basic n-bit checksum of the characters in str". This works in this case, of course. – G B – 2017-04-26T09:34:09.140

5

Perl 5, 30 bytes

-1 byte thanks to @Neil (31& instead of -96+).

29 bytes of code + -p flag.

$@+=31&ord for/./g;$_=$@==100

Try it online!

Dada

Posted 2017-04-18T20:56:40.603

Reputation: 8 279

Can you use 31&ord instead? – Neil – 2017-04-19T00:07:33.537

@Neil Hum... I've always been using -96+ for such things.. Thanks a lot for that! (but now I feel like I should go back through my old posts and replace every -96+ :x ) – Dada – 2017-04-19T05:19:43.610

The question specifies arrays are allowed as input. This can thus be briefer as a subroutine: {$@+=31&ord for@_;$@==100} (untested) – msh210 – 2017-04-19T06:17:22.277

I guess it depends on context - here you're using it in a +=, but in other cases you might waste the saving on parentheses. – Neil – 2017-04-19T07:44:32.613

@msh210 The challenge says your one language's text datatypes. Arrays are hardly Perl's text datatype... (Otherwise it would have saved 1 byte indeed) – Dada – 2017-04-19T07:50:19.453

@Neil yea, & precedence is a bit low, but I'm pretty sure it could have saved me one byte more than once! – Dada – 2017-04-19T07:51:39.957

5

05AB1E, 9 bytes

5bIvAyk>-

Try it online!

Explanation

As 1 is the only truthy value in 05AB1E we can save a byte using subtraction over comparing to 100.

5b         # convert 5 to binary (results in 101)
  Iv       # for each letter in input word
    Ayk    # get the index of the letter in the alphabet
       >   # increment
        -  # subtract from total

Emigna

Posted 2017-04-18T20:56:40.603

Reputation: 50 798

5

PowerShell, 36 30 bytes

$args|%{$s+=$_[0]-96};$s-eq100

Try it online!

Inputs as an array, but I'm wondering if there is a better way to handle characters.

EDIT Missed an easy space but @AdmBorkBork kindly let me know :P also, there was in fact a better way to handle the characters!

Sinusoid

Posted 2017-04-18T20:56:40.603

Reputation: 451

Hiya - a couple quick golfs. You don't need the parens around [char]$_-96, and you don't need the space between -eq and 100, getting you down to 33. You can also do "$_"[0] instead of [char]$_, getting you down to 32. Try it online!

– AdmBorkBork – 2017-04-19T13:01:08.000

Are the " around $_ necessary? It appears to work without the cast. Could it be due to the input being a string array already? – Sinusoid – 2017-04-19T13:32:44.867

Ah, indeed you are correct. The " aren't needed in this particular instance. – AdmBorkBork – 2017-04-19T13:34:27.597

5

Dyalog APL, 17 15 bytes

100=+/17-⍨⎕AV⍳⍞

Uses the Dyalog Classic character set.

              ⍞  ⍝ string input
          ⎕AV⍳   ⍝ index in the character map
      17-⍨       ⍝ subtract 17 from each ('a' = 18)
    +/           ⍝ sum
100=             ⍝ equal to 100?

Uriel

Posted 2017-04-18T20:56:40.603

Reputation: 11 708

By default all submission must be full programs or functions. REPL programs are allowed as long as they're identified as such. However, you still have to request user input. – Dennis – 2017-04-19T07:04:58.163

5

Alice, 28 18 bytes

Thanks to @MartinEnder for golfing 10 bytes

=I.!'`-+?hn
>3-nO@

Try it online!

This submission uses a different method than @MartinEnder's answer.

This submission outputs 0x00 for falsy and 0x01 for truthy.

So here is a version that outputs 0 or 1 instead: Try it!

Explanation

The explanation below is for the "visible" version. Both are very similar, except in the first program, the last o doesn't convert the 0 or 1 into a string (because we are in cardinal mode), but instead takes the number and output the character at that code point.

=                 Does nothing, but will be useful later on
I                 Read a character and push its code point onto the stack
                  If there is no more input, -1 is pushed instead
.                 Duplicate it
!                 Store it on the tape
#                 Skip the next command
o                 Gets skipped
'`                Push 96
-                 Subtract it from the character
+                 And add it to the total
?                 Load the number on the tape
h                 Increment it
n                 And negate it
                  For all characters that are read, ?hn results in 0,
                  but if -1 is pushed, then the result becomes 1

After this the IP wraps around to the left edge at the =. If the top value of the stack is 0, the IP continues on with its path, increasing the total sum of all the characters, once it is done with the input (the top of the stack will be 1), then the IP turns right (90 degrees clockwise).

One thing is important to note, the loop on the first line will iterate once after the input has ended. This will subtract 97 (96 from the '` and -1 from the lack of input) from the total.

>                Set the direction of the IP to East
3-               Subtract 3 from it (yields 0 if sum is 100, something else otherwise)
n                Negate it; Zero becomes 1, non-zero numbers become 0
/                Mirror; the IP gets redirected South-East
                 The IP reflects off the bottom and goes North-East
                 Now the program is in Ordinal mode, where numbers are automatically converted into strings when being used
o                Output the top of the stack as a string
                 IP reflects off the top and heads South-East
@                End the program

user41805

Posted 2017-04-18T20:56:40.603

Reputation: 16 320

5

Taxi, 1259 bytes

Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to Auctioneer School.Go to Auctioneer School:s 1 r 1 l 1 l.Pickup a passenger going to Chop Suey.0 is waiting at Starchild Numerology.Go to Starchild Numerology:s 1 l.Pickup a passenger going to Addition Alley.Go to Chop Suey:e 1 l 2 r 3 r 3 r.[a]Switch to plan "b" if no one is waiting.Pickup a passenger going to Charboil Grill.Go to Charboil Grill:n 1 l 3 l 3 l.Pickup a passenger going to What's The Difference.Go to Go More:e.64 is waiting at Starchild Numerology.Go to Starchild Numerology:e 2 r.Pickup a passenger going to What's The Difference.Go to What's The Difference:e 1 l 2 r 1 l.Pickup a passenger going to Addition Alley.Go to Addition Alley:e 2 r.Pickup a passenger going to Addition Alley.Go to Chop Suey:n 1 r 2 r.Switch to plan "a".[b]Go to Addition Alley:n 1 l 2 l.Pickup a passenger going to Equal's Corner.100 is waiting at Starchild Numerology.Go to Starchild Numerology:n 1 l 1 l 3 l 2 r.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:w 1 l.Switch to plan "c" if no one is waiting."TRUE" is waiting at Writer's Depot.[c]"FALSE" is waiting at Writer's Depot.Go to Writer's Depot:n 1 l 1 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.

With line breaks, it looks like this:

Go to Post Office:w 1 l 1 r 1 l.
Pickup a passenger going to Auctioneer School.
Go to Auctioneer School:s 1 r 1 l 1 l.
Pickup a passenger going to Chop Suey.
0 is waiting at Starchild Numerology.
Go to Starchild Numerology:s 1 l.
Pickup a passenger going to Addition Alley.
Go to Chop Suey:e 1 l 2 r 3 r 3 r.
[a]
Switch to plan "b" if no one is waiting.
Pickup a passenger going to Charboil Grill.
Go to Charboil Grill:n 1 l 3 l 3 l.
Pickup a passenger going to What's The Difference.
Go to Go More:e.
64 is waiting at Starchild Numerology.
Go to Starchild Numerology:e 2 r.
Pickup a passenger going to What's The Difference.
Go to What's The Difference:e 1 l 2 r 1 l.
Pickup a passenger going to Addition Alley.
Go to Addition Alley:e 2 r.
Pickup a passenger going to Addition Alley.
Go to Chop Suey:n 1 r 2 r.
Switch to plan "a".
[b]
Go to Addition Alley:n 1 l 2 l.
Pickup a passenger going to Equal's Corner.
100 is waiting at Starchild Numerology.
Go to Starchild Numerology:n 1 l 1 l 3 l 2 r.
Pickup a passenger going to Equal's Corner.
Go to Equal's Corner:w 1 l.
Switch to plan "c" if no one is waiting.
TRUE is waiting at Writer's Depot.
[c]
FALSE is waiting at Writer's Depot.
Go to Writer's Depot:n 1 l 1 r.
Pickup a passenger going to Post Office.
Go to Post Office:n 1 r 2 r 1 l.

It accepts upper or lowercase because the Auctioneer School converts it all to uppercase.
Chop Suey breaks it into individual characters.
Charboil Grill converts characters to their ASCII code.
We pickup one character a time, convert it to ASCII, subtract 65, and add it to the running total.
Once there aren't any more characters, compare the total to 100.

Returns TRUE for dollar words and FALSE for everything else.

Engineer Toast

Posted 2017-04-18T20:56:40.603

Reputation: 5 769

1In a world of "boring" unreadable code-golf langages <20bytes answers, I welcome thy entry, kind stranger. – Olivier Dulac – 2017-04-21T11:00:45.050

5

IA-32 machine code, 21 bytes

Hexdump:

33 c0 6a 64 5a 8a 01 41 24 1f 75 05 83 ea 01 d6
c3 2b d0 eb f0

Assembly code:

    xor eax, eax;   initialize eax to 0
    push 100;       initialize edx
    pop edx;            to 100
myloop:
    mov al, [ecx];  load a byte
    inc ecx;        go to next byte
    and al, 31;     convert from letter to number
    jnz cont;       not done? continue

    ;               done:
    sub edx, 1;     check whether edx got to 0; result is in CF
    __emit(0xd6);   aka SALC - set al to CF
    ret
cont:
    sub edx, eax
    jmp myloop

Counts from 100 to 0. If arrived to 0, returns true (0xff); otherwise false (0x00).

anatolyg

Posted 2017-04-18T20:56:40.603

Reputation: 10 719

4

Python, 38 bytes

lambda s:sum(map(ord,s))==4-96*~len(s)

Try it online!

Same length as ovs's solution. Rather than subtracting 96 from each ord value, this checks if the ord total equals 100+96*len(s). This is expressed one byte shorter as 4-96*~len(s), which equals 4-96*(-len(s)-1).

xnor

Posted 2017-04-18T20:56:40.603

Reputation: 115 687

In Python 3, lambda s:sum(s.encode(),96*~len(s))==4 would also work. – Dennis – 2017-04-18T23:05:04.923

4

Japt, 13 12 10 bytes

L¥U¬x_c %H

Explanation:

L¥ U¬x _c %H
L¥(U¬x(_c %H))
L¥(          )   // 100==
   U¬            //   Input split into a char array
     x(     )    //   The sum of:
       _         //     At each char:
        c        //       Get the char-code and
          %H     //       Mod 32

Test it online!

12-bytes:

L¥U¬mc m%H x

Try it online!

Another 12-byte solution using a different technique

L¥U¬x@;CaX Ä

Try it online!

Oliver

Posted 2017-04-18T20:56:40.603

Reputation: 7 160

Great job! I think you can save a byte on the first one with m%H instead of m-96 (it'll work on both cases now, bonus!), and one on the second with L¥U¬x@;CaX Ä – ETHproductions – 2017-04-19T13:18:58.030

@ETHproductions Thanks! m%H was a nice find. x@ was a great idea too! – Oliver – 2017-04-19T15:39:54.860

@ETHproductions Got it down to 10 bytes ;) – Oliver – 2017-04-19T18:10:46.853

4

Ruby, 35 30 bytes

->w{196==eval(w.bytes*'-96+')}

Try it online!

G B

Posted 2017-04-18T20:56:40.603

Reputation: 11 099

4

Retina, 47 23 bytes

\w
!$&
}T`l`_l
^!{100}$

Try it online! Note: Header lowercases input and splits it into words; results appear on separate lines. Edit: Saved far too many bytes thanks to @MartinEnder.

Neil

Posted 2017-04-18T20:56:40.603

Reputation: 95 035

It's a lot shorter to compute the letter values by gradually lowering them while inserting characters: https://tio.run/nexus/retina#C0nwScjhCk6IjkvUrYrV5lLV0HBP@B9TzqWoosZVG5KQkxCfwxWnWG1oYFCr8v@/U2pRXmJRSmZevkJmSmpeSWZaZmqxQmleYk5JalFqikJKfk5OYpFCeX5RSjEA

– Martin Ender – 2017-04-19T09:27:49.657

4

Octave, 18 bytes

@(x)sum(x-96)==100

Subtracts 96 from the input string x (lower case), to get the numeric values of the letters. Takes the sum and compares it to 100. Returns a logical 1 for truthy cases, and a logical 0 for false cases.

I could save one byte if it was OK to give false for "dollar words" and true for "non-dollar words".

Stewie Griffin

Posted 2017-04-18T20:56:40.603

Reputation: 43 471

3

///, 564 210 189 185 bytes

/~/1\/\///4/11~3/41//6/33//2/66//5/22~a/~b/1~c/4~d/3~e/31~f/34~g/6~h/16~i/46~j/36~k/316~l/346~m/2~n/12~o/42~p/32~q/312~r/342~s/62~t/162~u/462~v/362~w/3162~x/3462~y/22~z/122~5555/0///1/0

Try it online!

Prints a 1 if it is a "dollar word", otherwise prints a "0"

Input is the following: (Scroll all the way to the right)

/~/1\/\///4/11~3/41//6/33//2/66//5/22~a/~b/1~c/4~d/3~e/31~f/34~g/6~h/16~i/46~j/36~k/316~l/346~m/2~n/12~o/42~p/32~q/312~r/342~s/62~t/162~u/462~v/362~w/3162~x/3462~y/22~z/122~5555/0//INPUT WORD HERE/1/0

Works by replacing each letter with its value in unary, then replacing a unary 100 with a 0. It then substitutes whatever the word's value is with a 1. If the word's value is 0, then it will print a 1 because at the end of the code, it is replacing a 0. If the word's value is anything else, it will just print that 0.

The golf works by using common occurrences in the code as replacements.

Comrade SparklePony

Posted 2017-04-18T20:56:40.603

Reputation: 5 784

3

Ruby (2.4+), 38 bytes

Takes input in lowercase. Requires Ruby 2.4's Array#sum so it won't run on TIO.

->a{a.chars.map{|c|c.ord-96}.sum==100}

snail_

Posted 2017-04-18T20:56:40.603

Reputation: 1 982

2Use String#bytes instead of String#chars so you don't have to call c.ord. – Value Ink – 2017-04-19T02:44:29.497

And use sum on the array instead of map – G B – 2017-04-19T06:07:02.343

3

Aceto, 49 bytes

TL;DR: 3rd-order Hilbert curve. Uses character input, looping until a newline is given. Sums up the values (96 (5*3+9*9) minus them), and in the end adds 100 (5*5*4) and checks whether it's zero. Uses the fairly new catch marks.

}){(
(o-+
d{))
|(&
=,d@*45(
{d""*+5(
3*)+=0
599*p

Outputs True if the given word is a dollar word, False otherwise.

Explanation:

We first construct a 96 by calculating 5*3+9*9: 53*99*+. Next, we move a stack to the right and push an empty string: )"". Because we're about to enter a repeating part, we set the catching mark using @. This is where we will return if an error occurs.

We duplicate the empty string, read a single character (,), duplicate that character, and move it to the original stack ({). Still on the right stack, we compare the top two values (the empty string and our character) and use the conditional mirror to jump to the right edge if they are equal: =|.

Assuming they're not, we now move on the left stack, push the character once more one stack to the left, duplicate the 96, go to the left stack, push the character back on the middle stack and go there again: ({d(}).

Now we convert the character to the value of its unicode codepoint and subtract it from 96, resulting in it's negated dollar value: o-. We do it this way, because we'd have to swap the values otherwise. We push the value to the left stack, go there, and add the two values there (initially 0 and our negative character value): {(+. To prepare for reading another character, we go to the middle stack again ), and then raise an error: &.

Once a newline is read and the character is therefore empty and the equality truthful, we got mirrored somewhere on the top-left quadrant; the exact position doesn't matter in our case. The next operation that does something is moving back on the stack of our final value: ((. On it, we should now have the sum of all character values, negative. That means, if it's a dollar word, it should be -100. To test whether it is, we add 100 (554**+), push 0, test for equality and print the result: =p.

L3viathan

Posted 2017-04-18T20:56:40.603

Reputation: 3 151

3

Bash + GNU utils, 47

od -An -td1 -vw1|sed 's/^/a+=-96+/;$a!a-100'|bc

Try it online.

Digital Trauma

Posted 2017-04-18T20:56:40.603

Reputation: 64 644

3

R, 36 39 bytes

Using a different method than the other R answer

function(x)sum(utf8ToInt(x)-96)==100

This is an unnamed function for lowercase characters. utf8ToInt(x) converts the string into a vector of ascii values. 96 is taken away from all items and sum checked against 100.

In use

> f=
+ function(x)sum(utf8ToInt(x)-96)==100
> f('buzzy')
[1] TRUE
> f('boycott')
[1] TRUE
> f('identifies')
[1] TRUE
> f('adiabatically')
[1] TRUE
> f('ttttt')
[1] TRUE
> f('zzz')
[1] FALSE
> f('zzzzzzz')
[1] FALSE
> f('abcdefghiljjjzz')
[1] FALSE
> f('tttt')
[1] FALSE
> f('basic')
[1] FALSE

MickyT

Posted 2017-04-18T20:56:40.603

Reputation: 11 735

You can save a few bytes by using sum(utf8ToInt(scan(,""))-96)==100 instead of defining a function using function(x). – JAD – 2017-04-20T08:17:22.383

@JarkoDubbeldam Generally that would be considered a snippet as it requires a REPL to output the result. I would have to wrap a cat around it to make it a full program – MickyT – 2017-04-20T18:19:49.540

is that new? Generally the implicit print when something is not assigned was considered 'output'. – JAD – 2017-04-21T07:12:27.230

@JarkoDubbeldam Not that new I think, I've been pinged on it before

– MickyT – 2017-04-23T22:38:33.793

Odd, that never was mentioned on any of my submissions :x – JAD – 2017-04-24T06:54:50.883

3

CJam, 9 bytes

q'`f-:+E=

Input should be in lowercase with a trailing newline. This is a tad cheaty as there's no reason to append a newline to the input, but it follows the rules as written.

Try it online!

How it works

q         e# Read all input from STDIN and push the resulting string on the stack.
 '`       e# Push the backtick character.
   f-     e# Subtract the backtick character from each input character. The
          e# difference of two characters is the difference of their code points,
          e# so this maps a..z to 1..26 and the newline to -86.
     :+   e# Take the sum.
       E  e# Push 14.
        = e# Test the sum and 14 for equality.

Dennis

Posted 2017-04-18T20:56:40.603

Reputation: 196 637

If it makes your program shorter and it doesn't really affect look, that's why it's in the rules :) – Stephen – 2017-04-20T19:19:55.443

3

C++ (gcc), 45 bytes

Unnamed generic lambda, accepting char[], std::string or any other container of char and returning via reference parameter.

  • 0 means dollar word
  • everything else is no dollar word

Even works for capital letters ;>

[](auto&s,int&r){r=100;for(auto x:s)r-=x&31;}

Try it online!

Karl Napf

Posted 2017-04-18T20:56:40.603

Reputation: 4 131

2

PHP, 45 Bytes

combination 3 Bytes saved by @user63956

input as argument list

for(;$s+=ord($argv[++$i])%32?:die($s==100););

input as string using the -R option

for(;$s+=ord($argn[$i++])%32?:die($s==100););

PHP, 48 Bytes

combination

for(;$c=$argv[++$i];)$s+=ord($c)%32;echo$s==100;

PHP, 50 Bytes

Running PHP from the commandline without a file $argv[0] is "-"

prints 1 for true and nothing for false

lowercase

echo array_sum(array_map(ord,$argv))-96*$argc==49;

uppercase

echo array_sum(array_map(ord,$argv))-64*$argc==81;

Jörg Hülsermann

Posted 2017-04-18T20:56:40.603

Reputation: 13 026

1for(;$s+=ord($argv[++$i])%32?:die($s==100);); saves 3 bytes. – user63956 – 2017-04-19T06:07:56.933

@user63956 nice trick thank you – Jörg Hülsermann – 2017-04-19T10:29:44.823

1You should either mention that you take the letters as distinct command line arguments or use -R and $argn[$i++]. – Titus – 2017-04-20T13:22:34.550

@Titus Done If you find other improvements you can edit it by yourself – Jörg Hülsermann – 2017-04-20T13:45:21.520

2

Java 7, 77 74 bytes

boolean c(String s){int r=0;for(int c:s.getBytes())r+=c&31;return r==100;}

Case-insensitive thanks to @Neil by changing c-96 to c&31.
-3 bytes thanks to @SuperChafouin.

Explanation:

Try it here.

boolean c(String s){          // Method with String parameter and boolean return-type
  int r=0;                    //  Resulting sum-integer
  for(int c:s.getBytes())     //  For each character in the String (as integer value)
    r+=c&31;                  //   Sum its alphabetic 1-indexed index (case-insensitive)
                              //  End of loop (implicit / single-line body)
  return r==100;              //  return if the sum equals 100
}                             // End of method

Kevin Cruijssen

Posted 2017-04-18T20:56:40.603

Reputation: 67 575

Could counting down from 100 save bytes? Also, &31 might work to make your code case insensitive. – Neil – 2017-04-19T07:48:04.467

@Neil Thanks for the tip of making it case-insensitive. But counting down from 100 is the same byte-count: boolean c(String s){int r=100;for(int c:s.toCharArray())r-=c-96;return r==0;} – Kevin Cruijssen – 2017-04-19T07:55:25.897

1As input is a-z, maybe you can use getBytes ? – Arnaud – 2017-04-19T08:27:12.643

Ah, of course, this is Java, it takes 3 bytes to compare to zero... – Neil – 2017-04-19T08:33:47.097

2

C#, 72 64 bytes


Golfed

(string w)=>{int s=0;foreach(var c in w)s+=c-96;return s==100;};

Ungolfed

( string w ) => {
   int s = 0;

   foreach( var c in w )
      s += c - 96;

   return s == 100;
};

Ungolfed readable

( string w ) => {
   // Initialize the var to store the sum of the chars
   //    of the given word
   int s = 0;

   // Cycle through each char
   foreach( var c in w )

      // Add it to the sum minus 96
      //    'a' == 97
      s += c - 96;

   // Return if the sum is equal, or not, to 100
   return s == 100;
};

Full code

using System;
using System.Collections.Generic;

namespace Namespace {
   class Program {
      static void Main( String[] args ) {
         Func<String, Boolean> f = ( string w ) => {
            int s = 0;

            foreach( var c in w )
               s += c - 96;

            return s == 100;
         };
         List<String>
            testCases = new List<String>() {
               "buzzy",
               "boycott",
               "identifies",
               "adiabatically",
               "ttttt",
               "zzz",
               "zzzzzzz",
               "abcdefghiljjjzz",
               "tttt",
               "basic",
            };

         foreach( String testCase in testCases ) {
            Console.WriteLine( $" Input: {testCase}\nOutput:{f( testCase )}\n" );
         }

         Console.ReadLine();
      }
   }
}

Releases

  • v1.1 - -8 bytes - Swapped the for loop with a foreach one
  • v1.0 - 72 bytes - Initial solution.

Notes

  • $

auhmaan

Posted 2017-04-18T20:56:40.603

Reputation: 906

2

braingasm, 20 bytes

Assumes input without trailing newlines, e.g echo -n "unaltered" | braingasm dollarwords.bg

,[96-[->+<],]>100-z:

Could easily been done in plain brainfuck, if I had the patience for it.

,                       Read a byte to the current cell.
 [                      While there's something in the current cell:
  96-                     subtract 96 from it,
     [->+<]               move the remainder to the next cell,
           ,              read another byte.
            ]           
             >100-      Move to next cell and subtract 100 from it,
                  z:    print 1 if remainder is zero, 0 if not.

daniero

Posted 2017-04-18T20:56:40.603

Reputation: 17 193

2

Brain-Flak, 92 bytes

({{}[(((((()()()){}){}){}){}){}]})((((((()()()){}){}){}()){}){})({}[{}]<(())>){((<{}{}>))}{}

Try it online!

James

Posted 2017-04-18T20:56:40.603

Reputation: 54 537

2

Brachylog, 12 9 bytes

-3 bytes thanks to Fatalize

ạ-₉₆ᵐ+100

Takes input as a string of lowercase letters. Try it online!

Explanation

ạ          Convert input string to a list of ASCII codes
    ᵐ      To that list, map this predicate:
 -₉₆        Subtract 96 from each charcode
     +     Sum the resulting list of numbers 1-26
      100  Succeed if the sum is 100, fail otherwise

DLosc

Posted 2017-04-18T20:56:40.603

Reputation: 21 213

2You can save 3 bytes like this: ạ-₉₆ᵐ+100 – Fatalize – 2018-03-04T07:57:00.637

2

Stax, 9 bytes

ü☺ïΦΘ╬╟₧╘

I love the ☺ in the code! Potential Stax/Emojicode polyglot in the future...?

Run and debug it at staxlang.xyz!

Unpacked (10 bytes):

{64-m|+AJ=

Explanation:

{   m         Form a block and map it over input.
 64-            Push 64 and subtract it from the character code.
     |+       Sum the resulting array.
       AJ     Push 10 and square it.
         =    Check for equality!

I'm quite new to Stax (and golfing languages); this can almost certainly be shortened. I think the { can probably be dropped with proper placement of the m...

Another approach (imperative, 10 bytes):

ú☼7Tí:£_▓δ

12 unpacked:

c|+AJ-s%64*=
c               Copy the top item on the stack.
 |+             Sum it. For a string, this sums code points.
   AJ           Push 10 and square, yielding 100.
     -          Subtract this 100 from the earlier sum.
      s         Swap the top two items, putting the input back on top.
       %        Push the input's length.
        64*     Push 64 and multiply.
           =    Check for equality!

Input for both is capital letters. For lowercase, replace 64 with 96.

Khuldraeseth na'Barya

Posted 2017-04-18T20:56:40.603

Reputation: 2 608

2

Rust, 158 bytes

fn main(){let(i,mut c)=(&mut"".into(),0);std::io::stdin().read_line(i);let l:Vec<u8>=i.trim().bytes().collect();for b in&l{c+=*b as u8-96}print!("{}",c==100)}

Ungolfed

fn main() {
    let (input_string, mut count) = (&mut "".into(), 0);
    std::io::stdin().read_line(input_string);
    let bytes: Vec<u8> = input_string.trim().bytes().collect();
    for byte in &bytes {
        count += *byte as u8 - 96;
    }
    print!("{}", count == 100);
}

Prints true if the input is a dollar word, and false if it is not. Only works on lower case letters.

dragonite44

Posted 2017-04-18T20:56:40.603

Reputation: 91

I don't believe that zero is considered a truthy value in rust. Here is how we generally define truthy. It is not the clearest, which is why we have been moving away from the terminology lately but I don't think it includes 0.

– Post Rock Garf Hunter – 2018-03-21T03:44:35.447

You can also likely save a byte by using *b as u8 instead of u64. Unless I am missing something. – Post Rock Garf Hunter – 2018-03-21T03:46:02.180

Thanks for the clarification. I've edited my answer – dragonite44 – 2018-03-21T04:20:42.947

2

R, 45 bytes

sum(as.numeric(charToRaw(scan(,"")))-96)==100

Try it online!

Returns TRUE or FALSE.

As stated in the question, expects user input in a-z, converts the characters to numbers, brings them to the 1–26 range, and checks if the sum is equal to 100.

Even if one converts it to a function, it still beats Giuseppe’s answer in terms of byte count (it would be 48):

function(x)sum(as.numeric(charToRaw(x))-96)==100

Andreï Kostyrka

Posted 2017-04-18T20:56:40.603

Reputation: 1 389

1

J 14 bytes or 10 bytes if rules allow!!!

100=+/_96+a.i.

        100=+/_96+a.i. 'identifies'
    1
        100=+/_96+a.i. 'ttttt'
    1
        100=+/_96+a.i. 'wrong'
    0

    Because:
                        a.i. gives position in code table 0-255
                    _96+ subtracts 96 ('a') from each value
                +/   adds them all together
            100= compares with 100  

IDEA: Can a "truthy" value be 100, and a "falsey value be <> 100?

If so...

+/_96+a.i.

    +/_96+a.i. 'boycott'
    100
    +/_96+a.i. 'boycot'
    80

:O)

Richard Donovan

Posted 2017-04-18T20:56:40.603

Reputation: 87

We have a rather specific definition of truthy/falsy, so I'm afraid calling 100 truthy and non-100 falsy is not allowed. 100=+/_96+a.i. is also not valid, albeit just because of a technicality: by default, submissions have to be full programs or functions. Tacit verbs are usually the shortest option.

– Dennis – 2017-04-19T00:57:39.547

I don't understand your second point. What is the difference between my attempt and the Dialog APL solution directly above it??? – Richard Donovan – 2017-04-19T03:50:07.343

I also don't understand your first point. In the discussion, it was proposed: if (x) { print "x is truthy"; } else { print "x is falsy"; }. With my idea, substitute "answer is 100" for x and all is well. – Richard Donovan – 2017-04-19T03:53:57.927

Hadn't seen the APL answer; left a comment there as well. – Dennis – 2017-04-19T07:28:28.663

1

You don't get to define which check to perform to determine truthiness; your language does. For J, non-zero integers are truthy and zero is falsy. https://tio.run/nexus/j#@59ZXFJUWpJRqWBrpWCsYKVgwKUABJlpekCyUiElX09BHaJAHSyRmlOcCpICAfW0xJximHheih6XJhdXanJGvgLczNTE5AyFeEMFAwVDBUtLBUMDg///AQ

– Dennis – 2017-04-19T07:29:42.290

1

jq, 28 characters

(25 characters code + 3 characters command line option)

[explode[]|.-96]|add==100

Sample run:

bash-4.3$ jq -R '[explode[]|.-96]|add==100' <<< 'bernardino'
true

On-line test

manatwork

Posted 2017-04-18T20:56:40.603

Reputation: 17 865

1

Groovy, 32 characters

{s->s*.value.sum{it[0]-96}==100}

Sample run:

groovy:000> ({s->s*.value.sum{it[0]-96}==100}("bernardino"))
===> true

manatwork

Posted 2017-04-18T20:56:40.603

Reputation: 17 865

1

Ruby 2.4, 30 + 1 = 31 bytes

One extra byte for the n flag: $ ruby -n dollar_words.rb

p chop.bytes.sum{|c|c-96}==100

Prints true or false for each given line of input:

$ ruby -n dollar_words.rb 
zzzzz
false
unaltered
true
dollar
false

daniero

Posted 2017-04-18T20:56:40.603

Reputation: 17 193

1

QBIC, 34 bytes

;[_lA||p=p+asc(_sA,a,1|)%32]?p=100

Explanation:

;               Get A$ from the cmd-line
[_lA||          FOR a = 0; a <= a$.Length(); a++
p=p+asc(        Increment P with the ASCII value of
_sA,a,1|)%32]     A$.Substring(a,1) mod 32 (thank you @JonathanAllan, that's a neat trick!)
?p=100          When done, print -1 if p is 100, 0 otherwise

steenbergh

Posted 2017-04-18T20:56:40.603

Reputation: 7 772

1

Pyth, 16

!-100+Fm+1xGdcQ1

Try online.

Digital Trauma

Posted 2017-04-18T20:56:40.603

Reputation: 64 644

1

Röda, 25 bytes

{[ord(_)-96]|sum|[_=100]}

Try it online!

fergusq

Posted 2017-04-18T20:56:40.603

Reputation: 4 867

1

Batch, 189 bytes

@set/p,=
@set z=1
@for %%a in (a b c d e f g h i j k l m n o p q r s t u v w z y)do @set/a%%a=z,z+=1
@set .=100
:l
@set/a.-=%,:~,1%
@set ,=%,:~1%
@if not "%,%"=="" goto l
@exit/b%.%

Takes lowercase input on STDIN and ouputs via ERRORLEVEL (0 is truthy). Batch has no character code operator so I set the variables a-z to their value in a loop, then I individually evaluate all the characters in the input word and subtract them all from 100.

By using non-alphabetic variable names the code is readily extended to handle uppercase input.

Neil

Posted 2017-04-18T20:56:40.603

Reputation: 95 035

1

Pyth, 9 bytes

q100smhxG

Explanation:

q100smhxGdQ autofill variables
       xGd  [index of d in "abcdefghijklmnopqrstuvwxyz"
      h      + 1
     m    Q  for d in eval(input())]
    s       sum(^)
q100        == 100

Test suite.

Steven H.

Posted 2017-04-18T20:56:40.603

Reputation: 2 841

Came to the exact same program, but you need to count the d for 10 bytes, no? – Dave – 2017-08-18T15:56:18.363

Nope! d automatically gets filled in, since it's inside m. Variables inside lambdas autofill to the lambda's parameter (the first input in the case of two parameters). Look at what Python code results from this Pyth.

– Steven H. – 2017-08-22T15:35:37.483

Fixed arity continues to be the greatest gift to the code golf in history, dang! – Dave – 2017-08-22T16:23:01.223

1

Excel, 52 + 2 bytes

{=SUM(IFERROR(CODE(MID(A1,ROW(A1:A100),1))-64,0))=100}

Input is in cell A1 in all uppercase.
Must be entered as an array formula with Ctrl+Shift+Enter (Adds the curly brackets { }).
Returns TRUE for dollar words and FALSE for others.

Engineer Toast

Posted 2017-04-18T20:56:40.603

Reputation: 5 769

1

Rip, 27 bytes

10gDiW[8DmsagDi]P9iDmsI[d]O

Works only for uppercase input, which it reads from stdin. Please do not end the input with a newline. :)

Explanation:

1                            0I[Push a 1 for later]
 0                           0I[Sum is 0 now]
  gDiW[                      0I[Getchar, duplicate, increment, while: while not EOF]
       8Dms                  0I[8 8 dup mul subtract: subtract 65]
           a                 0I[Add to the current total]
            gDi]             0I[Getchar, dup, increment, end while: while not EOF]
                P            0I[Pop the last -1 (=EOF) read]
                 9iDms       0I[Subtract 100 (9 incr dup mul subtract)]
                      I[d]   0I[If not zero, decrement the first 1 (see first line) to a 0]
                          O  0I[Output the result (1 if ==100, 0 else) as a number]

tomsmeding

Posted 2017-04-18T20:56:40.603

Reputation: 2 034

1

C# / Linq, 42 bytes

Is Linq cheating?

(string w)=>{return w.Sum(x=>x-96)==100;};

Eric B

Posted 2017-04-18T20:56:40.603

Reputation: 111

Given Linq is a default .NET library it might be cheating a little, but you should be fine given you specified it's C# with Linq. Also you don't need string before w, or parentheses around it, you can just do w=>{...}; – Skidsdev – 2017-06-02T15:34:38.247

Based on other Java/C# answers, this format seems OK w=>w.Sum(x=>x-96)==100. I can see how the compiler having to infer the type of w from somewhere being a little odd though. – dana – 2018-12-28T02:21:08.640

1

Braingolf, 13 bytes [non.competing]

{#`-}&+#de1:0

Try it online!

Requires all lowercase input, outputs 1 for dollar word, 0 otherwise

Explanation

{#`-}&+#de1:0  Implicit input of string as char values to stack
{...}          Foreach item on stack..
 #`            ..Push char value of ` (96)
   -           ..Subtract from input char value
     &+        Sum entire stack
       #d      Push char value of d (100)
         e     If last 2 items are equal..
          1    ..Push 1
           :   else
            0  ..Push 0
               Implicit output of last item on stack

Skidsdev

Posted 2017-04-18T20:56:40.603

Reputation: 9 656

1

Proton, 32 bytes

map(ord+((-)&96))+sum+((==)&100)

Try it online!

Waiting for pull from TIO.

HyperNeutrino

Posted 2017-04-18T20:56:40.603

Reputation: 26 575

1

Perl 5, 28 + 1 (-p) = 29 bytes

s/./96-ord$&/ge;$_=-100^eval

Try it online!

Returns 0 for truthy, anything else for falsey. Assumes lowercase input.

How?

Replace each character with the additive inverse of its position in the alphabet. Then, evaluate that equation and XOR it with -100 to determine if this is a dollar word.

Xcali

Posted 2017-04-18T20:56:40.603

Reputation: 7 671

1

Common Lisp, 56 bytes

(=(loop as x across(read-line)sum(-(char-code x)96))100)

Try it online!

Renzo

Posted 2017-04-18T20:56:40.603

Reputation: 2 260

1

SmileBASIC, 48 bytes

INPUT W$WHILE""<W$D=D+ASC(POP(W$))-64WEND?D==100

The classic string eating loop.

12Me21

Posted 2017-04-18T20:56:40.603

Reputation: 6 110

1

Pyth, 15 bytes

Vz=+ZhxGN)qZ^T2

Try it online!

The other Pyth answers use Q=eval(input()), which means the input must be in quotes in order to be valid. This program does not have that stipulation.

Pyth (indented) | Python 3 (translation)
             | G="abcdefghijklmnopqrstuvwxyz"
             | T=10
             | Z=0
             | z=input()
Vz           | for N in z:
    =+ZhxGN) |     Z+=G.find(N)+1
qZ^T2        | print(Z==T**2)

hakr14

Posted 2017-04-18T20:56:40.603

Reputation: 1 295

1

Befunge-98, 14 13 bytes

+~'@ #.-"d"$#

Try it online!

Takes input as uppercase letters. Outputs 0 for truthy, any other number for falsey.

How It Works:

 ~          Get input and continue right.
+ '@   -    Subtract 64 from the letter and add it to the total
 ~          On EOF go left instead
       -"d" Subtract 100 from the total
   @  .     Print the value and end the program

Jo King

Posted 2017-04-18T20:56:40.603

Reputation: 38 234

1

Pip, 11 bytes

A_-96MSa==h

Takes a string of lowercase letters as a command-line argument. Try it online!

How it works

             a is 1st command-line arg; h is 100 (implicit)
A_           An anonymous function that takes the ASCII value of its argument
  -96        and subtracts 96
     MSa     Map that to the characters of a and sum the result
        ==h  Test if that's equal to 100
             The result (0 or 1) is autoprinted

We use == (exact equality) instead of the usual = (numeric equality) because it has lower precedence than MS.

DLosc

Posted 2017-04-18T20:56:40.603

Reputation: 21 213

1

Add++, 18 bytes

D,f,@~,€O96€_s100=

Try it online!

caird coinheringaahing

Posted 2017-04-18T20:56:40.603

Reputation: 13 702

1

Julia 0.6, 27 bytes

s->sum(c->Int(c)-96,s)==100

Try it online!

gggg

Posted 2017-04-18T20:56:40.603

Reputation: 1 715

1

-3 bytes using broadcast subtraction instead of map: Try it online!

– sundar - Reinstate Monica – 2018-07-23T23:17:54.753

1

Tcl, 70 bytes

puts [expr 100==[join [lmap c [split $argv ""] {scan $c %c}] -96+]-96]

Try it online!


Tcl, 71 bytes

proc D s {expr 100==[join [lmap c [split $s ""] {scan $c %c}] -96+]-96}

Try it online!


Tcl, 74 bytes

puts [expr 100==[join [lmap c [split $argv ""] {expr [scan $c %c]-96}] +]]

Try it online!

Saved a byte using a command line argument instead of a function.


Tcl, 75 bytes

proc D s {expr 100==[join [lmap c [split $s ""] {expr [scan $c %c]-96}] +]}

Try it online!

sergiol

Posted 2017-04-18T20:56:40.603

Reputation: 3 055

1

Kotlin, 23 bytes

{it.sumBy{it-'`'}==100}

Try it online!

snail_

Posted 2017-04-18T20:56:40.603

Reputation: 1 982

1

Ahead, 21 bytes

>jvi96-+v
^~>'d=O~<~@

Try it online!

snail_

Posted 2017-04-18T20:56:40.603

Reputation: 1 982

1

Attache, 20 bytes

{100=Sum[_-96]}@Ords

Try it online!

Explanation

{100=Sum[_-96]}@Ords
               @Ords    convert input to ordinates
{             }         anonymous lambda, input: _
         _-96           subtract 96 from each char
     Sum[    ]          take the sum
 100=                   is it equal to 100?

Alternatives

20 bytes: {100=Sum[Ords@_-96]}

21 bytes: 100&`=@Sum@`-&96@Ords

22 bytes: {100=_}@Sum@`-&96@Ords

22 bytes: {100=Sum@_}@`-&96@Ords

24 bytes: {100=Sum!-~_}##STN=>List

25 bytes: {100-#_=Sum@_}##STN=>List

25 bytes: {100=Sum[_+1]}##STN=>List

26 bytes: {100=Sum[_+1]}##STN=>Chars

26 bytes: 100&`=@Sum##Succ@STN=>List

27 bytes: {100=_}@Sum##Succ@STN=>List

Conor O'Brien

Posted 2017-04-18T20:56:40.603

Reputation: 36 228

1

F# (Mono), 38 bytes

fun s->Seq.sumBy(fun c->int c-96)s=100

Try it online!

dana

Posted 2017-04-18T20:56:40.603

Reputation: 2 541