| Bytes | Lang | Time | Link |
|---|---|---|---|
| 067 | Tcl | 180323T141732Z | sergiol |
| 069 | Go | 240616T005323Z | bigyihsu |
| 009 | Uiua SBCS | 240615T152517Z | chunes |
| 032 | R | 240615T134955Z | Glory2Uk |
| 004 | Thunno 2 | 230608T183036Z | The Thon |
| 019 | Factor + math.unicode | 220202T230206Z | chunes |
| 019 | Julia 1.0 | 220202T225910Z | Sundar R |
| 056 | tinylisp | 220202T190632Z | DLosc |
| 012 | BQN | 211208T231751Z | DLosc |
| nan | 211209T193801Z | Larry Ba | |
| 210 | Batch | 211209T193044Z | T3RR0R |
| 033 | APOL | 211209T184007Z | Ginger |
| 104 | Whitespace | 211208T153336Z | Kevin Cr |
| 006 | MathGolf | 211208T115901Z | Kevin Cr |
| 012 | Ly | 211208T110802Z | cnamejj |
| 006 | Vyxal | 211208T005248Z | lyxal |
| 053 | TIBasic | 211208T002150Z | Youserna |
| nan | 170418T220428Z | Brad Gil | |
| 038 | F# Mono | 181228T063234Z | dana |
| 020 | Attache | 181228T021952Z | Conor O& |
| 021 | Ahead | 181106T000048Z | snail_ |
| 023 | Kotlin | 181105T234642Z | snail_ |
| 045 | R | 180330T164428Z | Andre |
| 009 | Stax | 180321T015623Z | Khuldrae |
| 158 | Rust | 180321T030953Z | dragonit |
| 013 | Befunge98 | 180304T035526Z | Jo King |
| 027 | Julia 0.6 | 180320T225808Z | gggg |
| 018 | Add++ | 180320T214404Z | caird co |
| 009 | Brachylog | 180304T050805Z | DLosc |
| 011 | Pip | 180304T043214Z | DLosc |
| 015 | Pyth | 180303T194800Z | hakr14 |
| 048 | SmileBASIC | 180303T163533Z | 12Me21 |
| 045 | C++ gcc | 170817T153056Z | Karl Nap |
| 056 | Common Lisp | 170816T110148Z | Renzo |
| nan | Perl 5 | 170815T180905Z | Xcali |
| 032 | Proton | 170815T172913Z | hyperneu |
| 013 | Braingolf | 170602T153224Z | Mayube |
| 015 | Dyalog APL | 170418T215322Z | Uriel |
| 042 | C# / Linq | 170421T184636Z | Eric B |
| 036 | Java 8 | 170419T083359Z | David Co |
| 027 | Rip | 170420T141606Z | tomsmedi |
| 045 | PHP | 170418T221328Z | Jör |
| 025 | Ruby | 170419T223222Z | Level Ri |
| 009 | CJam | 170420T013522Z | Dennis |
| 010 | Japt | 170418T232239Z | Oliver |
| 036 | R | 170419T205558Z | MickyT |
| 021 | IA32 machine code | 170419T221120Z | anatolyg |
| 522 | Excel | 170419T214411Z | Engineer |
| 049 | Aceto | 170419T124829Z | L3viatha |
| 1259 | Taxi | 170419T201652Z | Engineer |
| 009 | Pyth | 170419T195910Z | Steven H |
| 189 | Batch | 170419T191404Z | Neil |
| 025 | Röda | 170419T181301Z | fergusq |
| 018 | Alice | 170419T111032Z | user4180 |
| 016 | Pyth | 170419T172054Z | Digital |
| 047 | Bash + GNU utils | 170419T170104Z | Digital |
| 034 | QBIC | 170419T153804Z | steenber |
| 038 | Python | 170418T210944Z | ovs |
| 092 | BrainFlak | 170419T150509Z | DJMcMayh |
| 008 | MATL | 170419T000602Z | Luis Men |
| 020 | braingasm | 170419T135547Z | daniero |
| 185 | /// | 170418T214556Z | sporkl |
| 030 | PowerShell | 170418T212702Z | Sinusoid |
| nan | Ruby 2.4 | 170419T131639Z | daniero |
| 054 | R | 170418T214219Z | Giuseppe |
| 043 | C | 170418T212135Z | Steadybo |
| 032 | Groovy | 170419T115754Z | manatwor |
| nan | 170419T101406Z | auhmaan | |
| 018 | Octave | 170419T100520Z | Stewie G |
| 023 | Retina | 170419T090603Z | Neil |
| 028 | jq | 170419T093425Z | manatwor |
| 023 | Alice | 170419T092152Z | Martin E |
| 074 | Java 7 | 170419T065953Z | Kevin Cr |
| 030 | Ruby | 170419T061028Z | G B |
| 030 | Perl 5 | 170418T210458Z | Dada |
| 032 | Haskell | 170418T221835Z | xnor |
| 078 | Jelly | 170418T210515Z | Jonathan |
| 038 | Ruby 2.4+ | 170419T004943Z | snail_ |
| 006 | GS2 | 170419T004416Z | Dennis |
| 010 | J 14 bytes or | 170419T001446Z | Richard |
| 038 | Python | 170418T220034Z | xnor |
| 008 | 05AB1E | 170418T212706Z | Adnan |
| 023 | Mathematica | 170418T212357Z | Greg Mar |
| 009 | 05AB1E | 170418T211334Z | Emigna |
| 032 | Haskell | 170418T211253Z | Julian W |
| 046 | JavaScript ES6 | 170418T210414Z | Arnauld |
Tcl, 67 bytes
proc D s {expr 100==[lmap c [split $s ""] {list +[scan $c %c]-96}]}
Tcl, 70 bytes
puts [expr 100==[join [lmap c [split $argv ""] {scan $c %c}] -96+]-96]
Tcl, 71 bytes
proc D s {expr 100==[join [lmap c [split $s ""] {scan $c %c}] -96+]-96}
---
Tcl, 74 bytes
puts [expr 100==[join [lmap c [split $argv ""] {expr [scan $c %c]-96}] +]]
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}] +]}
Go, 69 bytes
func(s string)bool{i:=0
for _,r:=range s{i+=int(r)-96}
return i==100}
R, 32 bytes
sum(strtoi(scan(,""),36)-9)==100
Since a word can be imported as a character array (==vector in R), here is a solution which converts the individual letters into the corresponding base36 number, subtracts 9 from each and sums up.
Thunno 2, 4 bytes
ÄSɦ=
Explanation
ÄSɦ= # Implicit input
Ä # Alphabet to number
S # Sum the list
= # Equals
ɦ # 100?
# Implicit output
Factor + math.unicode, 19 bytes
[ 96 v-n Σ 100 = ]
Explanation
! "boycott"
96 ! "boycott" 96
v-n ! { 2 15 25 3 15 20 20 }
Σ ! 100
100 ! 100 100
= ! t
Julia 1.0, 19 bytes
s->sum(s.-'`')==100
Takes input as an array of characters (since the question explicitly allows that).
tinylisp, 56 bytes
(load library
(q((W)(e 100(s(sum(chars W))(*(strlen W)96
Anonymous function that takes a lowercase word (must be quoted, like (q bernardino)) and returns 1 for dollar words and 0 otherwise. Try it online!
Or, 53 bytes if I can swap truthy and falsey (returns 0 for dollar words and some nonzero integer otherwise):
(load library
(q((W)(-(sum(chars W))100(*(strlen W)96
Ungolfed/explanation
(load library) ; Needed for sum, *, strlen, and ungolfed aliases
(lambda (word) ; Anonymous function with one argument
(equal? 100 ; Is the following equal to 100?
(sub2 ; The difference of
(sum (chars word)) ; the sum of the codepoints of the word
(* (strlen word) 96)))) ; and 96 times the length of the word
BQN, 13 12 bytes
-1 byte thanks to Razetime
100=0+´-⟜'`'
Anonymous tacit function that takes a lowercase string as its argument. Try it!
Explanation
-⟜'`' Subtract ` from each character of the argument; gives list of numbers 1-26
0+´ Fold on addition, starting at 0
100= 1 if the result equals 100, 0 otherwise
Old solution:
Python 3, 38 bytes
lambda s:sum(ord(c)-96for c in s)==100
Realized that was a duplicate so...
Python 3, 42 bytes
lambda s:sum(n-96for n in map(ord,s))==100
Batch 210 bytes
@Set i=%1&set/A$=}=0&Setlocal Enabledelayedexpansion&@For /l %%i in (97 1 123)Do @Cmd/C Exit %%i&Set/A"!=exitcodeASCII!}=%%i-96"
@For /l %%i in (0 1 99)Do @Set/A$+=!i:~%%i,1!}
@If !$!==100 (Echo(1)Else Echo(0
Defines a group of associated variables for each character containing the appropriate cent value. iterates over the string incrementing by the cent value of the current character. } is used to associate the variables, and also is defined as a variable with zero value to prevent missing operator errors if the current index exceeds the strings length. Iterates to a string length of 100 characters seeing as 100 A's is the longest possible dollar "word"
Edit: input is via command line argument when executing from cmd.exe
APOL, 33 bytes
v(0);f(i ∆(0 +(⌕(ⓛ ∋) 1)));=(⁰ ô)
Whitespace, 105 104 bytes
[S S S N
_Push_0][N
S S N
_Create_Label_LOOP][S N
S _Duplicate_sum][S N
S _Duplicate_sum][S N
S _Duplicate_sum][T N
T S _Read_STDIN_as_Character][T T T _Retrieve_input][S N
S _Duplicate_input][S S S T S T S N
_Push_10][T S S T _Subtract][N
T S S N
_If_0_Jump_to_Label_PRINT][S S S T S S S S S N
_Push_32][T S T T _Modulo][T S S S _Add][N
S N
N
_Jump_to_Label_LOOP][N
S S S N
_Create_Label_PRINT][S N
S _Duplicate_10][T S S N
_Multiply][T S S T _Subtract][S N
S _Duplicate][N
T S T N
_If_0_Jump_to_Label_TRUTHY][S S T T N
_Push_-1][N
S S T N
_Create_Label_TRUTHY][T N
S T _Print_as_integer]
Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Input casing is irrelevant; can be lower-, upper-, or even mixed cased.
Since Whitespace can only read input one character at a time, the input must contain a trailing newline so we'll know when we're done reading characters.
Whitespace also lacks truthy/falsey values, so this program will output 0 for truthy and -1 for falsey (could be 5 bytes less with 0 as truthy and any other integer as falsey).
Try it online (with raw spaces, tabs and new-lines only).
Explanation in pseudo-code:
Integer sum = 0
LOOP:
Integer c = STDIN as character-codepoint
If(c == '\n'):
Jump to PRINT
c = c modulo-32
sum = sum + c
Jump to LOOP
PRINT:
If(sum == c*c): // Note: c=10 at this point, which is the codepoint for '\n'
Integer result = 0
Jump to TRUTHY
result = -1
TRUTHY:
Print result as integer to STDOUT
MathGolf, 6 bytes
$♥%Σ♀=
Input as a list of characters. Input casing is irrelevant; can be lower-, upper-, or even mixed cased.
Explanation:
$ # Convert each character in the (implicit) input-list to a codepoint-integer
♥% # Modulo-32 on each
Σ # Sum the list together
♀= # And check if it's equal to 100
# (after which the entire stack is output implicitly as result)
Ly, 12 bytes
iy'`*N&+'d-!
Take input as lowercase characters.
i - read input to stack as codepoints
y - push number of chars on stack
'` - push codepoint("a")-1 on stack
*N - multiple, flip sign
&+ - sum the stack
'd - push 100 (codepoint for "d") on the stack
- - subtract from sum
! - "not" to map 0 to 1 and anything else to 0, prints automatically
Vyxal, 6 bytes
C₆-∑₁=
A port of the GS2 answer. Requires input to be uppercase (7 bytes for lowercase)
Explained
C₆-∑₁= # Full program - takes single string S
C # push [ord(char) for char in S]
₆- # and subtract 64 from each
∑ # and get the sum of that.
₁= # does that equal 100?
TI-Basic, 53 bytes
ᴇ2=sum(seq(inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ",sub(Ans,I,1)),I,1,length(Ans
Takes input in uppercase in Ans. Output is stored in Ans and displayed.
Raku, 21 bytes
{100==[+] .ords X%32}
Alternate:
{Ⅽ==[+] .ords X%32}
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
}
Attache, 20 bytes
{100=Sum[_-96]}@Ords
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
R, 45 bytes
sum(as.numeric(charToRaw(scan(,"")))-96)==100
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
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.
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.
Befunge-98, 14 13 bytes
+~'@ #.-"d"$#
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
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
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.
Pyth, 15 bytes
Vz=+ZhxGN)qZ^T2
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.
| 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)
SmileBASIC, 48 bytes
INPUT W$WHILE""<W$D=D+ASC(POP(W$))-64WEND?D==100
The classic string eating loop.
C++ (gcc), 45 bytes
Unnamed generic lambda, accepting char[], std::string or any other container of char and returning via reference parameter.
0means 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;}
Perl 5, 28 + 1 (-p) = 29 bytes
s/./96-ord$&/ge;$_=-100^eval
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.
Braingolf, 13 bytes [non.competing]
{#`-}&+#de1:0
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
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?
C# / Linq, 42 bytes
Is Linq cheating?
(string w)=>{return w.Sum(x=>x-96)==100;};
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]
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;
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"]
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.
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.
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
12-bytes:
L¥U¬mc m%H x
Another 12-byte solution using a different technique
L¥U¬x@;CaX Ä
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
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).
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.
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.
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.
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
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.
Alice, 28 18 bytes
Thanks to @MartinEnder for golfing 10 bytes
=I.!'`-+?hn
>3-nO@
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
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
Python, 39 38 bytes
lambda s:sum(ord(i)-96for i in s)==100
-1 byte thanks to @JonathanAllan
Brain-Flak, 92 bytes
({{}[(((((()()()){}){}){}){}){}]})((((((()()()){}){}){}()){}){})({}[{}]<(())>){((<{}{}>))}{}
MATL, 8 bytes
96-s100=
Uses lowercase input.
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
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.
///, 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
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.
PowerShell, 36 30 bytes
$args|%{$s+=$_[0]-96};$s-eq100
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!
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
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
TRUEandFALSEas one would expect.takes input in as lowercase; would only be a switch from
letterstoLETTERSfor all uppercase
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;}
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
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 theforloop with aforeachone - v1.0 -
72 bytes- Initial solution.
Notes
- $
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".
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.
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
Alice, 23 bytes
/o!
\i@/e)q&w[?'`-+k3-n
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.
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:
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
Perl 5, 30 bytes
-1 byte thanks to @Neil (31& instead of -96+).
29 bytes of code + -p flag.
$@+=31&ord for/./g;$_=$@==100
Haskell, 32 bytes
f s=sum[1|c<-s,_<-['a'..c]]==100
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.
Jelly, 9 7?* 8 bytes
ɠO%32S⁼³
Full program, outputting 1 if the input is a dollar word, or 0 if not.
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.
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}
GS2, 6 bytes
▲1Θd←q
Input must be in uppercase.
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.
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)
Python, 38 bytes
lambda s:sum(map(ord,s))==4-96*~len(s)
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).
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
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.
05AB1E, 9 bytes
5bIvAyk>-
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
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.
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'))