15
\$\begingroup\$

Your task is to write a program to print the sum of the ASCII codes of the characters of the program itself. You are not allowed to open any file (Any input such as command line arguments, standard input or files is prohibited).

The program that prints the lowest number (i.e. has the lowest sum of ASCII codes) wins.

Here is an example (not the shortest) of such a program written in C:

#include <stdio.h>
int main(){
printf("4950");/*i*/
return 0;
}

(no new line after })

\$\endgroup\$
11
  • 4
    \$\begingroup\$ It'd be interesting to see a quine solution: one that produces and sums its own bytes. \$\endgroup\$
    – Joey Adams
    Commented Jun 21, 2011 at 19:39
  • 2
    \$\begingroup\$ Not very challenging imho. It can be trivially brute-forced, especially for languages that simply dump tokens, such as PowerShell, Golfscript, etc. \$\endgroup\$
    – Joey
    Commented Jun 21, 2011 at 20:32
  • 3
    \$\begingroup\$ I downvoted and the comment gives the reason, why. As I have noted before, I don't consider the number of answers an indication of quality. Just because it can be easily solved does not make this an interesting or even challenging challenge. My opinion, at least. \$\endgroup\$
    – Joey
    Commented Jun 22, 2011 at 14:00
  • 6
    \$\begingroup\$ Wait. What? On one hand you complain that the question is easy and not interesting and then you downvote me (-2 for me). On the other hand you post 25% of answers on this question (+70 for you). \$\endgroup\$
    – Alexandru
    Commented Jun 22, 2011 at 15:28
  • 5
    \$\begingroup\$ So you see this as a reputation battle? Fine, I can easily change my answers to CW. In a way the large number of answers was a bit of a protest and to show that it's trivial to churn out lots of answers. Compare this for example to the task that wanted the alphabet four times. Also my answering self (bound to the task specifications) and my commenting self (hoping to improve general site quality) are often fairly separate. Anyway, happier now that I deleted them? They were still valid answers, though. \$\endgroup\$
    – Joey
    Commented Jun 22, 2011 at 20:09

37 Answers 37

1
2
0
\$\begingroup\$

Python, 5440

Highest score wins, right?

import sys
print sum(ord(i)for i in open(sys.argv[0]).read())

I just thought I'd post it anyway b/c it's a halfway quine solution.

\$\endgroup\$
0
\$\begingroup\$

Clojure - 8008

There's only a handful of quines so far, and clojure's not represented, so I figured I'd give it a go:

(let[s"(let[s%s](apply +(map int(format s(pr-str s)))))"](apply +(map int(format s(pr-str s)))))
\$\endgroup\$
0
\$\begingroup\$

05AB1E, 5 bytes (300)

C25LO

Try it online!

\$\endgroup\$
0
\$\begingroup\$

R, score 198

6*33

Try it online!

TIO link includes the code used to find this solution, which is the only 1+2 digit solution possible using the "*" operator.
Of, course, after finding this, I searched all the other answers for the string "6*33", which revealed that AlliedEnvy discovered the same solution in J 6 years ago...

\$\endgroup\$
0
\$\begingroup\$

Stax, score 354

|?|+

Run and debug it

|? returns the program's source. |+ sums it.

\$\endgroup\$
0
\$\begingroup\$

Zsh, 6 bytes, score 333

<<<333

< = 60, 3 = 51, so it adds up to a nice expression.

\$\endgroup\$
0
\$\begingroup\$

Scala, 1090 bytes

println (1090)    
\$\endgroup\$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.