title: prepend,append-Sequence

text:
# Question
Title: prepend,append-Sequence
## Task

The prepend,append-Sequence is defined recursively, like this

* a(1) = 1
* a(n) = a(n-1).n , if n is even
* a(n) = n.a(n-1) , if n is odd

where the . represents an integer concatenation.

So the first few terms are: `1,12,312,3124,53124,531246,7531246,...` This is A053064.

Your task is, given an integer **a \> 0** to return **n**, such that the **n**th element in the prepend,append-Sequence is equal to **a** and if no such **n** exists return 0, a negative number or error out etc.

## Rules

* Input can be taken as an integer, string, list of characters/digits etc.
* Output can be printed to STDOUT or returned (integer, string etc. is fine)
* On invalid input & in the case no such **n** exists your program may do anything but return a positive integer (eg. loop forever, return 0 etc.)
* You may choose to use 0-indexing, but then the output in case no **n** exists cannot be 0

## Test cases

```
1 -> 1
12 -> 2
21 -> 0
123 -> 0
312 -> 3
213 -> 0
211917151311975312468101214161820 -> 21
2119171513119753102468101214161820 -> 0
333129272523211917151311975312468101214161820222426283031 -> 0
999795939189878583817977757371696765636159575553514947454341393735333129272523211917151311975312468101214161820222426283032343638404244464850525456586062646668707274767880828486889092949698100 -> 100

```

# Answer
> 6 votes
# C# (.NET Core), 83, 80, 60 59 bytes

```
n=>{int i=0;for(var t="";t!=n;)t=++i%2<1?t+i:i+t;return i;}

```

Try it online!

Takes the input as a string into a lambda function. 1-indexed. Returns the index of the value for truthy, or infitnitely loops for a "falsey"

# Answer
> 6 votes
# Python 2, 63 bytes

*-1 byte thanks to @EriktheOutgolfer.*

```
f=lambda x,i='1',j=2:i!=`x`and f(x,[i+`j`,`j`+i][j%2],j+1)or~-j

```

Try it online!

# Python 2, 64 bytes

***-18 bytes thanks to @officialaimm, because I didn't notice erroring out was allowed!***

```
x,i,j=input(),'1',1
while i!=x:j+=1;i=[i+`j`,`j`+i][j%2]
print j

```

**Try it online!**

# Python 2, 82 bytes (does not loop forever)

This one returns `0` for invalid inputs.

```
def f(n,t="",i=1):
 while len(t)<len(n):t=[t+`i`,`i`+t][i%2];i+=1
 print(n==t)*~-i

```

**Try it online!**

# Answer
> 6 votes
## JavaScript (ES6), 40 bytes

Takes input as a string. Throws a recursion error if no index is found.

```
f=(n,s=k='1')=>n==s?k:f(n,++k&1?k+s:s+k)

```

### Demo

```
f=(n,s=k='1')=>n==s?k:f(n,++k&1?k+s:s+k)

console.log(f('1')) // 1
console.log(f('12')) // 2
console.log(f('312')) // 3
console.log(f('211917151311975312468101214161820')) // 21
console.log(f('999795939189878583817977757371696765636159575553514947454341393735333129272523211917151311975312468101214161820222426283032343638404244464850525456586062646668707274767880828486889092949698100')) // 100
```

# Answer
> 3 votes
# Jelly, 12 bytes

```
Rs2ZU1¦ẎVµ€i

```

Try it online!

Explanation:

```
Rs2ZU1¦ẎVµ€i
         µ€  Eval this link for each (automatic [1..n] range)
R             Range
 s2           Split in pieces of: 2
   Z          Zip
    U1¦       Only keep index: 1 of: Vectorized reverse
       Ẏ      Flatten 1-deep
        V     Concatenate string versions and eval
           i Find index of y in x (y = implicit input)

```

# Answer
> 3 votes
# 05AB1E, 14 bytes

```
$vDNÌNFs}«})Ik

```

Try it online! or as a Test suite

**Explanation**

*0-indexed*.
Returns **-1** if the input is not in the sequence.

```
$                 # push 1 and input
 v                # for each y,N (element, index) in input do:
  D               # duplicate top of stack
   NÌ             # push N+2
     NF }         # N times do:
       s          # swap the top 2 elements on the stack
         «        # concatenate the top 2 elements on the stack
          })      # end loop and wrap in a list
            Ik    # get the index of the input in this list

```

# Answer
> 2 votes
# , 73 bytes

```
p=paste0;n=scan(,'');l='';while(l!=n){F=F+1;l="if"(F%%2,p(F,l),p(l,F))};F

```

Reads from stdin and returns the value of the index (implicitly printed). Infinite loops when the value isn't in the sequence. `F` is by default `FALSE` which is cast to `0` when used in arithmetic.

Try it online!

# Answer
> 2 votes
## Haskell, ~~75~~ ~~71~~ 57 bytes

```
f n=[i|i<-[1..],(show=<<reverse[1,3..i]++[2,4..i])==n]!!0

```

Takes `n` as a string.

Try it online!

# Answer
> 2 votes
# Husk, <sup>~~17~~</sup> 15 bytes

```
£moiṁsṁṠehGJC2N

```

Try it online!

1-indexed. Returns 0 if not in the sequence.

-2 bytes from Leo, `GJ`!

# Answer
> 2 votes
# Vyxal, 12 bytes

```
ɾɖ≬wJṘyRYvṅḟ

```

Try it Online! Uses 0-indexing, outputs -1 for invalid.

```
           ḟ # Find index of input in...
 ɖ           # Scan
ɾ            # range(1, input)
  ≬---       # by
   wJ        # Concatenate
     Ṙ       # Reverse
      yRY    # Reverse every other element
         vṅ  # Concatenate each list into a number

```

# Answer
> 1 votes
# Haskell, ~~115~~ 85 bytes

```
s=read.(show=<<)
f 1=1
f x|odd x=s[x,f$x-1]
f x=s[f$x-1,x]
g x=[n|n<-[1..],x==f n]!!0

```

Try it online!

# Answer
> 1 votes
# Mathematica, 135 bytes

```
s=t={};x=1;While[x<5!,{s~AppendTo~#&,s~PrependTo~#&}[[x~Mod~2+1]]@x;AppendTo[t,FromDigits@Flatten[IntegerDigits/@s]];x++];t~Position~#&

```

# Answer
> 1 votes
# Jelly,  ~~19 18~~  15 bytes

```
+ḂḶṚm2;RḤ$ṁµ€Vi

```

A monadic link taking and returning integers.

**Try it online!** (very slow - takes ~50s on TIO just to confirm that `3124` is at index `4`)

For a much faster version use the previous 18 byter (only checks up to the length of the input, which is sufficient).

### How?

```
+ḂḶṚm2;RḤ$ṁµ€Vi - Link: number, v
           µ€   - perform the monadic link to the left for €ach k in [1,2,3,...v]
                -                 (v can be big, lots of k values makes it slow!)
 Ḃ              -   modulo k by 2  = 1 if odd 0 if even
+               -   add to k = k+isOdd(k)
  Ḷ             -   lowered range = [0,1,2,...,k+isOdd(k)]
   Ṛ            -   reverse = [k+isOdd(k),...,2,1,0])
    m2          -   modulo slice by 2 = [k+isOdd(k),k+isOdd(k)-2,...,3,1]
         $      - last two links as a monad:
       R        -   range(k) = [1,2,3,...,k]
        Ḥ       -   double = [2,4,6,...,2k]
     ;          - concatenate = [k+isOdd(k),k+isOdd(k)-2,...,3,1,2,4,6,...,2k]
         ṁ      - mould like range(k) = [k+isOdd(k),k+isOdd(k)-2,...,3,1,2,4,6,...,k-isOdd(k)]
                -   (this is a list of the integers to be concatenated for index k)
             V  - evaluate as Jelly code (yields a list of the concatenated integers)
              i - first index of v in that (or 0 if not found)

```

# Answer
> 1 votes
# Swift 4, 92 bytes

This loops infinitely for invalid cases, so I didn't include them in the testing link.

```
func f(x:String){var i="1",j=1;while i != x{j+=1;i=[i+String(j),String(j)+i][j%2]};print(j)}

```

**Test Suite.**

Amusingly, it is longer with a closure:

```
var f:(String)->Int={var i="1",j=1;while i != $0{j+=1;i=[i+String(j),String(j)+i][j%2]};return j}

```

**Test Suite.**

# Answer
> 1 votes
# Perl 5, 54 + 1 (-n) = 55 bytes

```
$a=++$,%2?$,.$a:$a.$,while length$a<length;say/$a/&&$,

```

Try it online!

Returns nothing if not found.

# Answer
> 1 votes
# Japt, 17 bytes

```
@P=PiXv n X;¥P}a1

```

Try it online! or check (valid) test cases

Takes input as a string or integer. On invalid input, continues "forever" looking for a solution (thus why I didn't include them in the test cases).

Explanation:

```
@P=PiXv n X;¥P}a1
                     # Implicitly start with P = ""
@             }a1    # Repeat the function for each integer X > 0 until one returns true
 P=Pi     X          #  Insert X into P at index:
     Xv              #   X is divisible by 2?
        n            #   Times -1
           ;¥P       #  Return whether P now equals the input
                     # Implicitly output the last value of X

```

The "insert at index" portion might be a bit confusing, so I'll add more detail here. In Japt, `NvD` is a function which returns 1 if N is divisible by D, and 0 otherwise. If D is not provided, it defaults to 2. Thus `Xv`  here is equal to 1 if X is even, and 0 if X is odd. `NnD` is a function that returns `D - N`. If D is not provided it defaults to 0, effectively returning `-N`. In this program, that results in -1 if X is even, and still 0 if X is odd. Finally, in Japt indexing negative numbers count from the end of a string or array. Thus the segment `PiXv n X` evaluates to `Pi0 X` if X is odd, prepending X, but it evaluates to `Pi-1 X` if X is even, appending it instead.

---
Tags: code-golf, sequence, integer
---


title: Add N numbers without using + or -

text:
# Question
Title: Add N numbers without using + or -
Given N integers, output the sum of those integers.

## Input

You may take the integers in any reasonable format, including:

* `stdin`
* arguments
* an array or list

## Rules

## Testcases

```
n=2, 1, 2 -> 3
n=2, 2, 2 -> 4
n=2, 9, 10 -> 19
n=2, 7, 7 -> 14
n=2, 8, 8 -> 16
n=2, -5, 3 -> -2
n=2, -64, -64 -> -128
n=2, -3, 0 -> -3
n=2, 0, 3 -> 3
n=2, 0, 0 -> 0
n=2, -1, -1 -> -2
n=2, -315, -83 -> -398
n=2, 439, 927 -> 1366
n=3, 1, 2, 3 -> 6
n=3, 2, 2, 5 -> 9
n=3, 0, 9, 10 -> 19
n=3, 7, 0, 7 -> 14
n=3, 8, 8, 0 -> 16
n=3, -5, 3, -2 -> -4
n=3, -64, -64, 16 -> -112
n=3, -3, 0, 0 -> -3
n=3, 0, 3, 0 -> 3
n=3, 0, 0, 0 -> 0
n=3, -1, -1, -1 -> -3
n=3, -315, -83, -34 -> -432
n=3, 439, 927, 143 -> 1509
n=17, -74, 78, 41, 43, -20, -72, 89, -78, -12, -5, 34, -41, 91, -43, -23, 7, -44 -> -29

```

Testcases with partial sums that exceed 8 bits are only required if your integer type supports each partial sum (if any) and the final result. As a special case, `n=2, -64, -64 -> -128` is only required if your integer type can represent `-128`.

Testcases involving negative integers are only required if your language natively supports negative integers.

# Answer
# Wolfram Language (Mathematica), 2 bytes

**Tr** *finds the trace of the matrix or tensor list*

```
Tr

```

Try it online!
> 14 votes

# Answer
# Python 2, ~~97 95 93 88~~ 87 bytes

Solution that doesn't use the built-in `sum`, `eval` or `exec`:

*-2 bytes thanks to @JonathanAllan!*
*-1 byte thanks to @ovs!*

```
x=y=1
for i in input():x<<=i*(i>0);y<<=abs(i)
y/=x
print" ~"[x<y],len(bin(x/y|y/x)[3:])

```

Try it online!

**Input**: a comma separated list of numbers, from stdin.
**Output**: the sum is printed to stdout. If the sum is negative, the `~` sign is used instead of `-` due to source code restriction.

**How**: Let \\$p\\$ be the sum of all positive numbers in the list, and \\$n\\$ be the magnitude of the sum of all negative numbers. Then the sum of the list is \\$p-n\\$.

Let \\$x=2^p\\$ and \\$y=2^n\\$, then \\$\frac xy=2^{p-n}\\$.

Thus if the sum is positive (aka \\$x\>y\\$), we can calculate the sum by counting the number of zeros in the binary representation of \\$\frac xy\\$. Otherwise, we can calculate the magnitude of the sum as the number of zeros in the binary representation of \\$\frac yx\\$.
> 10 votes

# Answer
# JavaScript (ES6), 21 bytes

Takes input as an array of integers.

```
a=>eval(a.join`\x2B`)

```

Try it online!

---

# JavaScript (ES6), 40 bytes

Takes input as an array of integers.

```
a=>a.reduce(g=(x,y)=>y?g(x^y,(x&y)*2):x)

```

Try it online!
> 9 votes

# Answer
# APL (dzaima/APL), 2 bytesSBCS

Anonymous tacit prefix function

```
1⊥

```

Try it online!

Simply evaluates a "digit" list in base 1.
> 6 votes

# Answer
# C (gcc), ~~50~~ ~~45~~ ~~43~~ 38 bytes

```
f(s,e)char**s;{s=s<e?&f(&s[1])[*s]:0;}

```

*-7 bytes thanks to @S.S. Anne*
*-5 bytes thanks to @Bubbler*

Takes for input start and end pointers. It uses the fact that the address of `&a[b]` equals `a+b`. Other than that, even I am a bit confused as to how this works.

Try it online!
> 6 votes

# Answer
# , 1 bytes

Takes input as a list and... just a summation function... :-)

```
J

```

# `j`, 0 bytes

Haha, even more cheaty! The `j` flag automatically evaluates the `J` command at the end of the source code.

```

```
> 6 votes

# Answer
# Japt, 1 byte

Trivial challenges get trivial solutions!

```
x

```

Try it
> 5 votes

# Answer
# Python 2/Python 3, 3 bytes

```
sum

```

Try it online (Py 3)! or Try it online (Py 2)!
> 5 votes

# Answer
# GERMAN, 141 bytes

```
EINGABESCHLEIFENANFANGSUBTRAKTIONRECHTSEINGABESCHLEIFENANFANGSUBTRAKTIONRECHTSADDITIONLINKSSCHLEIFENENDELINKSSCHLEIFENENDERECHTSRECHTSAUSGABE

```
> 4 votes

# Answer
# Mornington Crescent, ~~634~~ 537 bytes

```
Take Northern Line to Bank
Take District Line to Parsons Green
Take District Line to Upminster
Take District Line to Temple
Take District Line to Hammersmith
Take District Line to Parsons Green
Take District Line to Upminster
Take District Line to Upminster
Take District Line to Parsons Green
Take District Line to Bank
Take Northern Line to Charing Cross
Take Northern Line to Angel
Take Northern Line to Bank
Take District Line to Upminster
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Mornington Crescent

```

Try it online!

```
// initialize adder
Take Northern Line to Bank          // save input to Hammersmith
Take District Line to Parsons Green // get 0
Take District Line to Upminster     // set Upminster = 0

// set start of loop
Take District Line to Temple

// extract leading number
Take District Line to Hammersmith
Take District Line to Parsons Green

// add it to previous sum
Take District Line to Upminster     // accumulator = sum
                                    // Upminster = previous accumulator

// save sum in Upminster
Take District Line to Upminster

// get remaining string
Take District Line to Parsons Green

// check if it is equal to "" by translating the first char to its codepoint (0 if empty)
// we ride a few extra rounds here, adding 0s to the sum
Take District Line to Bank          // save string and
                                    // get string of previous round
Take Northern Line to Charing Cross // swap accumulator with Charing Cross
                                    // and get codepoint of previous values'
                                    // first char (that's from two rounds ago)
                                    // or 0 if empty

// if string is not empty (meaning, accumulator is non-zero), repeat
Take Northern Line to Angel

// else read sum
Take Northern Line to Bank          // get empty string
Take District Line to Upminster     // swap with Upminster

// and go home, outputting the number
Take District Line to Bank          // change lines, swapping data with Bank
Take Circle Line to Bank            // swap back
Take Northern Line to Mornington Crescent // go home

```
> 4 votes

# Answer
# Python, 3 bytes

```
sum

```

Built in function which does the job

**Try it online**

---

With no built-in, **36 bytes** in Python 2:

-3 thanks to ovs!

```
lambda a:eval(`a`.replace(*',\x2b'))

```

Try it online!

Note: a single value may be represented as a singleton list (meta)
> 3 votes

# Answer
# C (gcc), 94 bytes

```
x,c;n(a,b){for(;b;b=x*2)x=a&b,a^=b;x=a;}f(a,t)int*a;{for(c=1;c<t;c=n(c,1))*a=n(*a,a[c]);c=*a;}

```

A non-trivial golfed reference implementation.

I realized I had worded myself out of an answer when I couldn't even use `+` or `-` for a counter variable.

Try it online!
> 3 votes

# Answer
# Bash \+ GNU utilities, 57 bytes

```
printf %.f $(bc -l<<<"99*l(e(`sed 's@ @/99)*e(@g'`/99))")

```

Try it online!

Reads space-separated integers from stdin, and writes the output to stdout.

This applies the exponential function to each integer, multiplies the results, and then takes the natural logarithm of the product. I need to scale the input numbers (and then "unscale" the result) so as not to overflow the exponentials on some of the starred test examples (that's what the `99*` and `/99` are doing there).
> 3 votes

# Answer
# Pyth, 1 byte

```
s

```

Try it online!

### Explanation

```
s(Q)
 (Q) : Implicit evaluated input
s    : Sum the input

```
> 3 votes

# Answer
# Mornington Crescent, 1267 bytes

Try it online!

Poorly golfed, may have to have another attempt tomorrow.

```
Take Northern Line to Bank
Take Northern Line to Euston
Take Victoria Line to Seven Sisters
Take Victoria Line to Victoria
Take Circle Line to Victoria
Take Circle Line to Bank
Take District Line to Parsons Green
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Parsons Green
Take District Line to Parsons Green
Take District Line to Upminster
Take District Line to Upney
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Parsons Green
Take District Line to Bank
Take Circle Line to Moorgate
Take Circle Line to Temple
Take Circle Line to Moorgate
Take Circle Line to Bank
Take District Line to Parsons Green
Take District Line to Upney
Take District Line to Upminster
Take District Line to Upney
Take District Line to Upminster
Take District Line to Upney
Take District Line to Upminster
Take District Line to Hammersmith
Take District Line to Parsons Green
Take District Line to Bank
Take Circle Line to Moorgate
Take Circle Line to Hammersmith
Take Circle Line to Embankment
Take Northern Line to Charing Cross
Take Northern Line to Angel
Take Northern Line to Bank
Take District Line to Upney
Take District Line to Bank
Take Circle Line to Bank
Take Northern Line to Mornington Crescent

```
> 3 votes

# Answer
# Jelly, 1 byte

```
S

```

A built-in monadic atom which given a list yields the sum.

**Try it online!**

---

No built-in, **2 bytes**:

```
ḅ1

```

Converts from base one to an integer.

Try it online!
> 2 votes

# Answer
# Keg, `-hr`, 2 bytes

```
÷⅀

```

Try it online!

The joys of not having implemented lists properly! Simply item split and summate. Essentially uses a sum function, so no imaginary points for me.
> 2 votes

# Answer
# Batch, 93 bytes

`43` is the ASCII code for `+`:

```
@!! 2>nul||cmd/q/v/c%0&&exit/b
set c=cmd/c
set/pn=
%c%exit 43
%c%set/a !n: =%=exitcodeascii%!

```

Takes input via `STDIN`, delimited by space.
> 2 votes

# Answer
# , 4 bytes

```
1&#.

```

This was literally taken from here.
> 2 votes

# Answer
# Haskell, 3 bytes

```
sum

```

Function that takes an argument as a list e.g. `sum[1,2,3]` and returns the sum of the list.
> 2 votes

# Answer
# Brainetry, 143 bytes

```
a b c d e f
a b
a b c d e f
a b c d e f g h
a b c d e f g h
a b c d e

a b c d
a
a b c d e f g h i
a b c d e f
a b c d e f g h i

a b c d e f g

```

To try it online follow this repl.it link and paste the code in the `btry/replit.btry` file, then press the green "Run" button. Does I/O as ASCII codepoints.

The program above is the golfed version of this program:

```
Let me sum some numbers carefully.
Carefully enough
so that I do not use
the plus or minus signs, that'd be awful.
After I do this, oh so very carefully,
I just have to ...
Move the pointer
left and right for
a while.
This is the main gist of the whole program.
Of course this sounds somewhat uninteresting.
That is because you, my dear reader, lack depth.
(Is it "depth"?
Maybe that's not the correct English word...)

```
> 2 votes

# Answer
# Pip, 4 bytes

```
_MSg

```

Try it online!

`MS` maps a function to an iterable and sums its results.

`_` is the identity function.

`g` is the list of command line args.
> 2 votes

# Answer
# Python 3, 62/61 bytes

Without relying on sum in other functions.

```
def f(i,x=0):
	for y in i:
		while y:x,y=x^y,(x&y)*2
	return x

```

Can be shortened to 61 by removing the function definition (-13), replacing `in i:` with `in eval(input()):` (+12) and print instead of return at the end (+0).

Try it online!
> 2 votes

# Answer
# 05AB1E, 1 bytes

```
O

```

Input as a list.

Try it online or verify all test cases.

Slightly less boring:

Try it online or verify all test cases.

**Explanation:**

```
O   # Sum the (implicit) input-list
    # (and output the result implicitly)

1β  # Convert the (implicit) input-list to base-1
    # (and output the result implicitly)

```
> 1 votes

# Answer
# PowerShell, ~~60~~ 24 bytes

```
$args-join[char]0x2b|iex

```

Try it online!

-36 bytes thanks to @mazzy
> 1 votes

# Answer
# Racket, 133 bytes

```
(define(f a[s 0])(if(null? a)s(let([c(car a)])(if(= 0 c)(f(cdr a)s)(f(cons((if(> 0 c)add1 sub1)c)(cdr a))((if(> 0 c)sub1 add1)s))))))

```

Try it online!

Well...
> 1 votes

# Answer
# perl -ple, 18 bytes

```
s/ /\x2b/g;$_=eval

```

Try it online!

Reads a space separated list of numbers from `STDIN`, writes the sum to `STDOUT`.

# perl -MList::Util=sum -alpe, 8 bytes

```
$_=sum@F

```

Try it online!
> 1 votes

# Answer
# PHP, ~~20~~ 9 bytes

```
array_sum

```

Try it online!

still wondering if this is not too easy here.. EDIT: thanks to @640KB for saving 11 bytes!
> 1 votes

# Answer
# Haskell, 3 Bytes

```
sum

```

calculates the sum of a list
> 1 votes

# Answer
# C++ (gcc), ~~83~~, 110 bytes

```
#include <iostream>
int n,x,c;int f(int i){while(i){c=n&i;n^=i;i=c<<1;}if(std::cin>>x)f(x);else std::cout<<n;}

```

Try it online!

Explanation: Reads in integer inputs and preforms bit-wise addition.

I tried to simplify the carry step like this but it gave me a negative result.
> 1 votes

# Answer
# Java 8, 35 bytes

```
x->x.stream().mapToInt(x->x).sum()

```

Takes a `List` of `Integer`s.
> 1 votes

# Answer
# x86-16 machine code, 8 bytes

```
33 D2       XOR  DX, DX         ; clear running sum (in DX)
        AN:
AD          LODSW               ; load next value into AX
03 D0       ADD  DX, AX         ; add AX to running sum
E2 FB       LOOP AN             ; loop until CX = 0
C3          RET                 ; return to caller

```

Input size in `CX`, data in `[SI]`. Output sum in `DX`.
> 1 votes

# Answer
# SQL, 21 bytes

```
SELECT SUM(N) FROM T;

```

This assumes the numbers to be in table `T`, in a column named `N`.
> 1 votes

# Answer
# MAWP 1.1, 21 bytes

```
%@[~@~1A]_1A[%M_1A]%:

```

Try it!

Input taken as:

```
number_of_inputs
n1
n2
n3
...
nN

```
> 1 votes

# Answer
# Lua, 57 bytes

```
print(load("return "..table.concat(arg,('').char(43)))())

```

Try it online!
> 1 votes

# Answer
# Java (JDK), 56 bytes

For once, in this challenge we can't use Java lambdas because its arrow `->` contains the `-` sign!
So i think the shortest way in Java to add N numbers
(unlike using a pre-built function that only adds 2 numbers, which has also been explicitly disallowed by OP)
without using `+` and `-`, is this approach:

```
int f(int...a){return java.util.Arrays.stream(a).sum();}

```

Try it online!
> 1 votes

# Answer
# Scala, 19 bytes

Try it online!

```
def f(a:Int*)=a.sum

```
> 1 votes

# Answer
# Rust, 29 (maybe 10?) bytes

Since Rust supports signed integers natively we have to use a signed type, but the challenge lets us choose the type beyond that, so I choose `i8` in order to save two bytes.

```
|n:&[i8]|n.iter().sum::<i8>()

```

Attempt This Online!

Depending on how the rules should be interpreted it could be possible to solve it using only 10 bytes:

```
|n|n.sum()

```

Attempt This Online!

by moving the type declarations into the driving code, but that requires the driving code to contain the `-` character, which I feel is against the rules.
> 1 votes

# Answer
# Thunno 2 `S`, 0 bytes

That's right. No bytes. The `S` flag takes the sum.

## Thunno 2, 1 byte

```
S

```

1 byte flagless. Built-in for `sum`.

#### Screenshots
> 1 votes

# Answer
# Desmos, 50 bytes

```
\sum_{n=1}^{a.\operatorname{length}}a\left[n\right]

```

Takes input as array `a`

View it on Desmos
> 1 votes

# Answer
# Red, 4 bytes

```
:sum

```

Try it online!

Takes the input as a block (list)
> 0 votes

# Answer
# Retina 0.8.2, 79 bytes

```
O`[^,\d]?\d\d*
\d\d*
$*
,[^,1]

^([^,1]1*),
$1;
,

\D?(1*);\1

^(\D)?(1*)
$1$.2

```

Try it online! Link includes test cases. Explanation:

```
O`[^,\d]?\d\d*

```

Sort the numbers.

```
\d\d*
$*

```

Convert the numbers to unary.

```
,[^,1]

```

Total the numbers that are less than zero.

```
^([^,1]1*),
$1;

```

Separate the numbers that are less than zero from those that are not less than zero.

```
,

```

Total the numbers that are not less than zero.

```
\D?(1*);\1

```

Add the less than zero total to the not less than zero total.

```
^(\D)?(1*)
$1$.2

```

Convert to decimal.

Adding nonnegative integers is much easier of course.

```
\d\d*
$*
1

```

Try it online! Explanation: Each integer is converted into unary and then the total is converted into decimal.
> 0 votes

# Answer
# Charcoal, 3 bytes

```
ＩΣＡ

```

Try it online! Link is to verbose version of code. Explanation:

```
  Ａ Input as an array
 Σ  Take the sum
Ｉ   Cast to string
    Implicitly print

```
> 0 votes

# Answer
# Ruby, 18 bytes

```
def f(*a)a.sum end

```

Try it online!
> 0 votes

# Answer
# Pushy, 2 bytes

```
S#

```

Try it online!

As you can probably guess, `S` sums all values on the stack and `#` outputs this as a number.
> 0 votes

# Answer
### Javascript (40 characters)

`x=>eval(x.join(String.fromCharCode(43)))`

The boring and obvious way to do this, I guess.

### Javascript (48 characters)

`x=>x.reduce((a,v)=>[...a,...Array(v)],[]).length`

A bit lame, but my first attempt. Concatenates arrays of the length of each number, then finds the total length of that array.
> 0 votes

# Answer
# Burlesque, 6 bytes

```
ps{}ms

```

Try it online!

Takes input as a space separated string from stdin. Explanation:

```
ps      # Parse input as block
    ms  # Map and sum result
  {}    # Empty mapping function

```
> 0 votes

# Answer
# C++ (clang), ~~81~~ 75 bytes

```
[](auto x){decltype(x)r;for(int a:x)r.insert(r.end(),a,0);return r.size();}

```

I used a generic lambda to avoid the need for `#include`.

It uses a temporary container, to which it appends lists of zeros of needed lengths. The output is the length of the resulting list.

Thanks to S.S. Anne for the idea of using `decltype`! I used `auto` earlier, and it was worse because I had to `clear` the list before working with it.

Try it online!
> 0 votes

# Answer
# SNOBOL4 (CSNOBOL4), 59 bytes

```
N S =S ' ' CHAR(43) ' ' INPUT :S(N)
O OUTPUT =EVAL(0 S)
END

```

Try it online!
> 0 votes

# Answer
# Rockstar, 66 bytes

```
listen to N
R's0
while N
cast N
let R be with N
listen to N

say R

```

Try it here (Code will need to be pasted in, with each input integer on an individual line)
> 0 votes

# Answer
# \>\<\> (Fish), 23 bytes

Takes input in unary, separated by NULL bytes. A bit cheaty, let me know if you think this is valid or no.

```
i:0=?~:0(?v
       ;nl/

```

Try it

# \>\<\> (Fish), 34 bytes

Input must be length prefixed. Uses `p` to modify the source code at runtime to insert `+` and `-` instructions.

```
'V'2,61p0iv
:?!v$i $1 >59*91p
;n$/

```

Try it
> 0 votes

# Answer
# minigolf, 39 bytes

```
1i,ny*_:1<sv,1s/_:,:ny=!ns,,___s,_s,T*_

```

Attempt This Online!
> 0 votes

# Answer
# Regex, 1 byte

```
x

```

Try it online! Takes input as space-delimited unary, outputs using the number of matches. This is  standard I/O format for regex that just happens to trivialise this challenge.
> 0 votes

# Answer
# Swift, 87 bytes

The xor & carry based approach. The return type of a function in Swift is defined using the arrow like `f() -> Int` with a "minus" character, so my function needs to print the value and not return it :-) (that way actually 5 bytes shorter than returning the result)

```
func s(_ a:[Int]){var r=0;for var c in a{while 0 != c{(r,c)=(r^c,(r&c)<<1)}};print(r)}

```
> 0 votes

# Answer
# Gema, 35 characters

```
<N>=@set{s;@add{${s;};$0}}
?=
\Z=$s

```

Takes an input string with anything separated numbers.

Sample run:

```
bash-5.2$ gema '<N>=@set{s;@add{${s;};$0}};?=;\Z=$s' <<< '-64, -64, 16'
-112

```

Try it online! / Try all test cases online!
> 0 votes

# Answer
# jq, 3 characters

```
add

```

Takes the input as array.

Sample run:

```
bash-5.2$ jq 'add' <<< '[-64, -64, 16]'
-112

```

Try it online! / Try all test cases online!
> 0 votes

# Answer
## Java, 15 bytes

```
Math.addExact()

```

You give it your two variables as parameters
> -1 votes

---
Tags: code-golf, restricted-source
---


title: Bloons TD 6 Upgrade Paths

text:
# Question
Title: Bloons TD 6 Upgrade Paths
# Background

The monkeys need help organizing their defense and have asked you, Benjamin the code monkey, to create a program that will list all tower upgrade options. Each tower has three unique upgrade "paths", each having a tier represented by a number between 0 and 5 inclusive, 0 meaning no upgrade. Up to two paths may be chosen for upgrading, that is contain an upgrade tier 1 or greater. Additionally, only one path can can contain a tier 3 or greater.

# Task

Output in some reasonable format all valid upgrade path triples in *any order* (the triples themselves are ordered). Triples can be represented in any reasonable way, such as 025 or 0-2-5. The triples must be distinguishable from each other in some way, so a flat list of numbers without triple delimiters is not allowed.

Here is an example list of all 64 possible triples, as they appear in-game for your insta-monkey collection:

```
5-2-0
5-0-2
5-1-0
5-0-1
5-0-0
2-5-0
0-5-2
1-5-0
0-5-1
0-5-0
2-0-5
0-2-5
1-0-5
0-1-5
0-0-5
4-2-0
4-0-2
4-1-0
4-0-1
4-0-0
2-4-0
0-4-2
1-4-0
0-4-1
0-4-0
2-0-4
0-2-4
1-0-4
0-1-4
0-0-4
3-2-0
3-0-2
3-1-0
3-0-1
3-0-0
2-3-0
0-3-2
1-3-0
0-3-1
0-3-0
2-0-3
0-2-3
1-0-3
0-1-3
0-0-3
2-2-0
2-0-2
2-1-0
2-0-1
2-0-0
0-2-2
1-2-0
0-2-1
0-2-0
1-0-2
0-1-2
0-0-2
1-1-0
1-0-1
1-0-0
0-1-1
0-1-0
0-0-1
0-0-0

```

# Answer
# K (ngn/k), ~~20~~ 18 bytes

```
?,/+'!'1|3*<'+!3#3

```

Try it online!

`+!3#3` All triples with values in `0 1 2`.
`<'` Grade up each triple. This results in all permutations of `0 1 2` with some duplicates.
`1|3*` Multiply by 3 and take maximum with 1 to generate all permutations of `6 3 1`.
`+'!'` For each permutation, generate all triples where the each entry is a non-negative integer less than the number in the permutation at the same index.
`?,/` Flatten into a matrix with three columns and take the unique rows.
> 6 votes

# Answer
# Factor \+ `math.combinatorics`, ~~59~~ 58 bytes

```
6 iota 3 selections [ natural-sort "\0"before? ] filter .

```

Try it online!

-1 byte from a tip by @ovs.

Note the string `"\0"` has literal control character `3` embedded as well as the `0`; you can see it on TIO. This string is equivalent to the longer (but clearer) sequence `{ 0 3 }`.

* `6 iota 3 selections`

Generate all 3-selections of \\$\[0..5\]\\$: `{ { 0 0 0 } { 0 0 1 } ... { 5 5 5 } }`
* `[ natural-sort { 0 3 } before? ] filter`

Select those that when sorted are less than `{ 0 3 }`.
* `.`

Print them.
> 5 votes

# Answer
# Python 2, ~~82~~ 80 bytes

```
from itertools import*
print[k for k in product(*[range(6)]*3)if[0,3]>sorted(k)]

```

-2 bytes thanks to *@ovs*.

Try it online.

**Explanation:**

* `from itertools import*`: Import `itertools` for the cartesian `product` builtin
* `range(6)`: Push list `[0,1,2,3,4,5]`
* `[^]*3`: Repeat it three times: `[[0,1,2,3,4,5],[0,1,2,3,4,5],[0,1,2,3,4,5]]`
* `product(*^)`: Use the cartesian product builtin to get all triplets
* `k for k in ^`: Loop over these triplets
* `^if`: And filter to only keep the triple-tuplets `k` that are:
    + `sorted(k)`: When sorted and converted to an array
    + `[0,3]>^`: are smaller than `[0,3]`
* `[^]`: Wrap all these tuplets into an array
* `print^`: And print it as result
> 4 votes

# Answer
# Python, 71 bytes

```
for x in range(521):max(s:='%03d'%x)<'6'!=['0','3']>sorted(s)==print(s)
```

Attempt This Online!

I took the `['0','3']>sorted(s)` idea from ovs.
> 4 votes

# Answer
# JavaScript (V8),  ~~75~~  67 bytes

*Saved 8 bytes thanks to @tsh*

Prints one comma-separated triplet per line.

```
for(i=216;i--;)[...a=[i/36%6|0,i/6%6|0,i%6]].sort()<'0,3'&&print(a)

```

Try it online!
> 3 votes

# Answer
# Husk, 10 bytes

```
uΣmPΠmŀ∫ḣ3

```

Try it online!

Similar to my K answer.

```
       ∫ḣ3  -- cumulative sums of [1..3] -> [1,3,6]
     mŀ     -- lowered range of each     -> [[0],[0,1,2],[0,1,2,3,4,5]]
    Π       -- cartesian product of the three lists
  mP        -- for each triplet, get all permutations
 Σ          -- flatten into a list of triplets
u           -- get the unique ones

```
> 3 votes

# Answer
# 05AB1E, ~~13~~ 11 bytes

```
5Ý3ãʒ{₆1š‹P

```

-2 bytes thanks to a tip of *@ovs* using `136`.

Outputs as a list of triplets.

Try it online.

**Explanation:**

```
5Ý           # Push a list in the range [0,5]
  3ã         # Cartesian power of 3: get all triplets using these [0,1,2,3,4,5]
    ʒ        # Filter this list by:
     {       #  Sort the triplet from lowest to highest
      ƵZ     #  Push compressed integer 136
        S    #  Convert it to a list of digits: [1,3,6]
         ‹   #  Check for sorted triplet [a,b,c] whether [a<1,b<3,c<6]
          P  #  Check if all three are truthy
             # (after which the filtered list of 64 triplets is output implicitly)

```

`ƵZS` could alternatively be `₆1š` for the same byte-count: try it online.

```
      ₆      #  Push 36
       1š    #  Convert it to a list of digits, and prepend 1

```

See this 05AB1E tip of mine (section *How to compress large integers?*) to understand why `ƵZ` is `136`.
> 2 votes

# Answer
# Retina 0.8.2, 50 bytes

```

520$*¶

00$.`
.+(...)
$1
G`0
A`[3-5].*[3-5]|[6-9]

```

Try it online! Link includes footer that prettifies the output. Explanation:

```

520$*¶

00$.`
.+(...)
$1

```

List all the integers from `0` to `520` inclusive, padded to 3 digits.

```
G`0

```

Only keep those integers with at least one `0` digit.

```
A`[3-5].*[3-5]|[6-9]

```

Discard those with more than one digit greater than `2` or with a digit greater than `5`.
> 2 votes

# Answer
# Python 3, 75 bytes

```
print([r for r in[(x//36,x//6%6,x%6)for x in range(216)]if[0,3]>sorted(r)])

```

Try it online!
> 2 votes

# Answer
# Python 3, ~~161~~ ~~146~~ ~~141~~ 135 bytes

```
from itertools import*
for u in product(*[range(6)]*3):
 i,j,k=u
 if 0not in u or i>2and j>2or j>2and k>2or k>2and i>2:1
 else:print(u)

```

Try it online!

-5 thanks to qwr
> 1 votes

# Answer
# Charcoal, 26 bytes

```
ΦＥφ﹪%03dι∧№ι0∧›6⌈ι›²ΣＥι‹2λ

```

Try it online! Link is to verbose version of code. Explanation:

```
  φ                         Predefined variable `1000`
 Ｅ                          Map over implicit range
        ι                   Current value
   ﹪%03d                    Formatted to 3 0-filled digits
Φ                           Filtered where
           ι                Current value
          №                 Contains
            0               Literal string `0`
         ∧                  Logical And
               6            Literal string `6`
              ›             Is greater than
                 ι          Current value
                ⌈           Maximum character
             ∧              Logical And
                   ²        Literal integer `2`
                  ›         Is greater than
                      ι     Current value
                     Ｅ      Map over digits
                        2   Literal string `2`
                       ‹    Is less than
                         λ  Current digit
                    Σ       Take the sum
                            Implicitly print

```

28 bytes for the prettier version:

```
ΦＥφ⪫﹪%03dι-∧№ι0∧›6⌈ι›²ΣＥι‹2λ

```

Try it online! Link is to verbose version of code.
> 1 votes

# Answer
# Ruby, 62 bytes

```
p (z=*0..5).product(z,z).select{|x|x.min<1&&(x-[3,4,5])[1]}|[]

```

Try it online!
> 1 votes

# Answer
# Rust, 106 bytes

```
for i in 0..6{for j in 0..6{for k in 0..6{let mut t=[i,j,k];t.sort();if t<[0,3,6]{print!("{i}{j}{k}
")}}}}

```

Actually using nested loops is barely shorter than my attempt using itertoools.

Attempt This Online!
> 1 votes

# Answer
# Pyth, 12 bytes

```
f>,Z3ST^U6 3

```

Try it online!

Port of Kevin Cruijssen's Python answer

```
f>,Z3ST^U6 3
        U6    Range up to 6 = [0,1,2,3,4,5]
       ^   3  Cartesian product with itself 3 times = [0,1,2,3,4,5] * [0,1,2,3,4,5] * [0,1,2,3,4,5]
f             Filter for elements T such that:
 >,Z3ST       [0,3] > sorted(T)

```
> 1 votes

# Answer
# Regenerate `-a`, ~~73~~ 64 bytes

```
[345]([12]0|0[012])|[12]([1-5]0|0[0-5])|0([012][0-5]|[345][012])
```

Attempt This Online!

Surprised nopony did this yet. Probably golfable!

EDIT: -9 thanks to math junkie for reminding me of the shorter output format. Now it's 1 byte per combination :P I still think it can be golfed further, possibly with a new approach :-)c
> 1 votes

# Answer
# Jelly, 11 bytes

```
6p3’Ż€Œ!€ẎQ

```

Try it online!

A niladic link that returns the 64 triples. This is my answer to the follow-up question but with the sorting code removed.
> 1 votes

# Answer
# Batch, 271 bytes

```
@!! 2>nul||cmd/q/v/c%0&&exit/b&for /l %%i in (0,1,5)do @(for /l %%j in (0,1,5)do @(for /l %%k in (0,1,5)do @(set s=%%i%%j%%k&set p=!s:0=!&if !p:~!==~ set p=0
if !p!. neq !s!. set/af=!p!/10&set/al=!p!%%10&if !f! lss !l! (if !f! leq 2 echo !s!)else if !l! leq 2 echo !s!)))

```
> 0 votes

---
Tags: code-golf, number, kolmogorov-complexity
---


title: Non-palindromic numbers

text:
# Question
Title: Non-palindromic numbers
**A strictly non-palindromic number N is a number that isn't a palindrome in *any* base (in bases 2 to N-2).** These numbers are listed on OEIS

For example, the number `19` in base 2,3,4,5,6,...17 is: `10011`,`201`,`103`,`34`,`31`,...`12`. None of these representations is palindromic, so the number is strictly non-palindromic.

For this challenge, you need to **return a truthy value if the number is non-palindromic, otherwise a falsy value**.

* You may assume the number passed to you is greater than or equal to 0.
* Your program should work for values up to your languages' integer size.

# Test cases:

Truthy:

```
0
1
2
3
4
6
11
19
47
53
79
103
389
997
1459

```

Falsy:

```
5
7
8
9
10
13
16
43
48
61
62
101
113
211
1361

```

This is a , so make your answers as short as possible!

# Answer
# C, 82 bytes

```
p(n,a,b,c,r){c=0;for(b=1;++b<n-2;c+=r==n)for(a=n,r=0;a>0;a/=b)r=r*b+a%b;return!c;}

```

Ideone it!

## Explanation

This code reverses `n` in base `b` and stores in `r`:

```
for(a=n,r=0;a>0;a/=b)r=r*b+a%b;

```

The outer loop counts the number of bases from `2` to `n-1` in which `n` is a palindrome.

If `n` is non-palindromic, the count would be `1` (`n` must be a palindrome in base `n-1`).
> 6 votes

# Answer
# Python 2, 71 bytes

```
n=input();b=1
while b<n-2:
 m=n;r=0;b+=1
 while m/(r!=n):r=r*b+m%b;m/=b

```

Output is via exit code, where **0** is truthy and **1** is falsy. Test it on Ideone.
> 5 votes

# Answer
# S.I.L.O.S, 206 bytes

```
GOTO e
lbld
c - 1
GOTO c
lble
readIO
n = i
i - 3
b = i
b + 1
GOTO f
lbla
a = n
r = 0
lblb
m = a
m % b
r * b
r + m
a / b
if a b
r - n
r |
if r d
lblc
c + 1
i - 1
b - 1
lblf
if i a
c / c
c - 1
c |
printInt c

```

Try it online!

Port of my answer in C.
> 5 votes

# Answer
# Haskell, ~~75~~ 68 bytes

```
(a!c)b|a<1=c|x<-c*b+mod a b=div a b!x$b
f n=all((/=n).(n!0))[2..n-2]

```
> 4 votes

# Answer
# Jelly, 9 bytes

```
bRµ⁼"US<3

```

Try it online! or verify all test cases.

### How it works

```
bRµ⁼"US<3  Main link. Argument: n

 R         Range; yield [1, ..., n].
b          Convert n to all bases between 1 and n, yielding a 2D array A>
  µ        Begin a new, monadic chain. Argument: A
     U     Upend; reverse the 1D arrays in A.
   ⁼"      Zipwith equal; yield 1 for each array that matches its inverse.
      S    Sum; add the resulting Booleans.
           If n > 1, the sum will be 2 if n is strictly non-palindromic (it is only
           a palindrome in bases 1 and n - 1), and greater than 2 otherwise.
           For 0 and 1, the sum will be 0 (sum of the empty array) and 1 (only a
           palindrome in base 1); both are less than 2.
       <3  Compare the sum with 3, yielding the desired Boolean.

```
> 3 votes

# Answer
# Pyth, ~~12~~ 10 bytes

Saved two bytes with Dennis' trick.

```
>3sm_IjQdS

```

Try it online!

Explanation:

```
         S (Q)   Get all the bases we need by building a list from 1 to Q
   m               For all bases d in the bases list:
      jQd           cast Q to base d as a list
    _I              and check to see if the list is palindromic (invariant on reversal)
                  Compile all the results back into a list
  s                Sum the results (a shorter form of any), gives 3 or more for palindromics
                    (2 is the usual because of bases 1 and Q-1)
>3                 And verify that the sum is greater than three to get non-palindromics

```
> 2 votes

# Answer
# Mathematica, ~~58~~ 43 bytes

```
!Or@@Table[#==#~IntegerReverse~i,{i,2,#-2}]&

```

TIL that `#~IntegerReverse~i` reverses the digits of the input when written in base i.
> 2 votes

# Answer
## Perl6, ~~110~~ ~~72~~ 65

```
my &f={?all(map {{.reverse ne$_}(@(.polymod: $^a xx*))},2..$_-2)}

```

Couldn't use base since that's broken for any base above 36.

### Previous attempts

```
my &a={$^a??flat($a%$^b,a($a div$b,$b))!!()};my &f=-> $n {?all(map {.reverse ne$_ given @(a($n,$_))},2..$n-2)}
my &f=->\n {?all(map {.reverse ne$_ given @(n.polymod: $_ xx*)},2..n-2)}

```
> 1 votes

# Answer
## JavaScript (ES6), 83 bytes

```
f=(n,i=n-2,g=n=>n<i?[n]:[...g(n/i|0),n%i])=>i<2||`${a=g(n)}`!=a.reverse()&&f(n,i-1)
```

```
<input type=number oninput=o.textContent=f(this.value);><pre id=o>
```
> 1 votes

# Answer
# Brachylog, 14 bytes

```
¬{⟦₆bk∋;?ḃ₍.↔}

```

Try it online!

Outputs through predicate success or failure, which prints `true.` or `false.` if run as a program.

```
¬{           }    It cannot be shown that
        ?         the input
       ; ḃ₍       in a base
      ∋           which is an element of
  ⟦₆              the range from 1 to the input - 1
    b             without its first element
     k            or its last element
           .      can be unified with both the output variable
            ↔     and its reverse.

```
> 1 votes

# Answer
# Vyxal `GRr`, 58 bitsv2, 7.25 bytes

```
⇩Ḣƛ?τḂ⁼;a

```

Try it Online!

Bitstring:

```
1101010001101111001011011000000100110010001101101010011011

```
> 1 votes

# Answer
# C, 129 bytes

```
f(n,b,k,j){int a[99];for(b=2;b+2<n;++b){for(j=0,k=n;a[j]=k%b,k/=b;++j);for(;k<j&&a[k]==a[j];++k,--j);if(k>=j)return 0;}return 1;}

```
> 0 votes

# Answer
**C, 77 bytes**

```
h(n,b,k,z){for(z=0,k=n;z+=k%b,k/=b;z*=b);return b+3>n?1:z==n?0:h(n,++b,0,0);}

```

recursive exercise...i change (b+2\>=n) with (b+3\>n) whithout debugging...

```
main()
{int  v[]={0,1,2,3, 4, 6,11,19,47,53,79,103,389,997,1459},
  n[]={5,7,8,9,10,13,16,43,48,61,62,101,113,211,1361}, m;
    // 0 1 2 3  4  5  6  7  8  9 10  11  12  13   14
 for(m=0; m<15; ++m)
    printf("%u=%u\n", v[m], h(v[m],2,0,0));
 for(m=0; m<15; ++m)
    printf("%u=%u\n", n[m], h(n[m],2,0,0));
}

/*
 77
 0=1
 1=1
 2=1
 3=1
 4=1
 6=1
 11=1
 19=1
 47=1
 53=1
 79=1
 103=1
 389=1
 997=1
 1459=1
 5=0
 7=0
 8=0
 9=0
 10=0
 13=0
 16=0
 43=0
 48=0
 61=0
 62=0
 101=0
 113=0
 211=0
 1361=0
*/

```
> 0 votes

# Answer
# PHP, 68 bytes

```
for($b=$argn;--$b;)strrev($c=base_convert($argn,10,$b))!=$c?:die(1);

```

takes input from STDIN, exits with `1` for falsy, `0` for truthy. Run with `-R`.
> 0 votes

# Answer
# APL(NARS), chars 47, bytes 94

```
{⍵≤4:1⋄∼∨/{⍵≡⌽⍵}¨{⍵{(⍺⍴⍨⌊1+⍺⍟⍵)⊤⍵}w}¨2..¯2+w←⍵}

```

where `{(⍺⍴⍨⌊1+⍺⍟⍵)⊤⍵}` would be the function conversion one positive omega in digits number base alpha, and `{⍵≡⌽⍵}` would be the function check palindrome... test:

```
  f←{⍵≤4:1⋄∼∨/{⍵≡⌽⍵}¨{⍵{(⍺⍴⍨⌊1+⍺⍟⍵)⊤⍵}w}¨2..¯2+w←⍵}
  f¨0 1 2 3 4 6 11 19 47 53 79 103 389 997 1459
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
  f¨5 7 8 9 10 13 16 43 48 61 62 101 113 211 1361
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

```
> 0 votes

---
Tags: code-golf, base-conversion, decision-problem, palindrome
---


title: Am I vaccinated?

text:
# Question
Title: Am I vaccinated?
**Disclaimer: the content of this post *is not medical information* and should not be used for any medical purpose, as it is deliberately oversimplified for the purpose of the challenge.**

There are several different strains of *Neisseria meningitidis*, the bacterium that causes meningococcal meningitis. Vaccines are available for strains A, B, C, W, and Y. They are available in three combinations.

The first is the quadrivalent meningococcal ACWY vaccine. As the name implies, this protects against strains A, C, W, and Y, but not B.

The second is the meningococcal B vaccine, which protects only against strain B.

The third is the pentavalent meningococcal ABCWY vaccine, which combines ACWY and B to protect against all five strains. Receiving the ABCWY vaccine is equivalent to receiving ACWY and B simultaneously.

However, while only one dose of ACWY is needed for full vaccination (we're ignoring boosters), two doses of B are needed. ABCWY counts as one dose of ACWY and one dose of B.

Write a program or function that accepts either an array of strings, or several strings delimited by a string of your choice. (The empty string is an acceptable delimiter; i.e., you may accept the strings run together.) These strings will be from the set `ACWY`, `B`, and `ABCWY`. Return or print `ACWY` if at least one dose of ACWY has been given but zero or one doses of B have been given, `B` if at least two doses of B but no doses of ACWY have been given, and `ABCWY` if at least one dose of ACWY and at least two doses of B have been given. If neither vaccine has been fully received, output the empty string. "Overvaccination" is allowed; `ABCWY ABCWY ACWY` should become `ABCWY`. You do not have to support invalid inputs.

| Input | Output |
| --- | --- |
| `ABCWY B` | `ABCWY` |
| `ABCWY` | `ACWY` |
| `B` | \[empty string\] |
| `B B` | `B` |
| `ACWY B B` | `ABCWY` |
| `ACWY B` | `ACWY` |

# Answer
# Google Sheets, 64 bytes

```
=join(,ifna(filter({"A","B","CWY"},search({"A","B*B","A"},A1))))

```

Put the input in cell `A1` and the formula in cell `B1`.

Uses the `search()` with `*` wildcard method of JvdV's Excel answer.

The same can be done without arrays using simple string concatenation and regexes (**81 bytes**):

```
=let(a,regexmatch(A1,"A"),if(a,"A",)&if(regexmatch(A1,"B.*B"),"B",)&if(a,"CWY",)

```

Implementation of the same in JavaScript (**62 bytes**):

```
t=>(a=/A/.test(t)?'A':'')+(/B.*B/.test(t)?'B':'')+(a?'CWY':'')

```

(-4 bytes thanks to noodle man)
> 7 votes

# Answer
# Perl 5 `-p`, 28 bytes

```
$_=A x/A/.B x/B.*B/.CWY x/A/

```

Try it online!
> 7 votes

# Answer
# Jelly, 6 bytes

```
œ-”BQṢ

```

Try it online!

A monadic link taking a string with no delimiter and returning a string.

## Explanation

```
œ-”B   | Set difference with "B"
    Q  | Uniquify
     Ṣ | Sort

```
> 6 votes

# Answer
# Python 3.8 (pre-release), 54 bytes

```
lambda s:"A"*(x:="C"in s)+"B"*(s.count("B")>1)+"CWY"*x

```

Try it online!

# Python 3, 59 bytes

```
def f(s):x="C"in s;return"A"*x+"B"*(s.count("B")>1)+"CWY"*x

```

Try it online!
> 4 votes

# Answer
# JavaScript (ES6), 55 / 48 / 41 bytes

Expects a space-separated string.

```
s=>[...new Set(s.replace("B",""))].sort().join``.trim()

```

Try it online!

Or **48 bytes** if we take a string with no delimiter.

Or **41 bytes** if we return an array.

## Method

Given the input string, e.g. `"ABCWY ACWY B"`:

* remove the first "B" → `"ACWY ACWY B"`
* turn the string into a set → `Set { 'A','C','W','Y',' ','B' }`
* turn the set into an array → `[ 'A','C','W','Y',' ','B' ]`
* sort it in lexicographical order → `[ ' ','A','B','C','W','Y' ]`
* turn it back into a string → `" ABCWY"`
* remove the leading space, if any → `"ABCWY"`
> 4 votes

# Answer
# Nekomata, 6 bytes

```
"B"∕uo

```

Attempt This Online!

A port of @Nick Kennedy's Jelly answer.

```
"B"∕uo
"B"∕    Set difference with "B"
    u   Uniquify
     o  Sort

```
> 4 votes

# Answer
# Retina 0.8.2, 16 bytes

```
\W

1`B

O`.
D`.

```

Try it online! Link includes test cases. Accepts any non-`\w` characters as a delimiter. Explanation:

```
\W

```

Join the words together.

```
1`B

```

Delete the first `B`, if any.

```
O`.

```

Sort the letters.

```
D`.

```

Deduplicate the letters.
> 3 votes

# Answer
# Bash \+ core utilities, 37 bytes

```
sed s/B//|grep -o .|sort -u|tr -d \\n

```

### Explanation

```
sed s/B// | # remove the first occurrence of B
grep -o . | # insert a newline after every character
sort -u   | # sort lines and remove duplicates
tr -d \\n | # remove newlines inserted for sorting

```
> 3 votes

# Answer
# Jelly,  ~~8~~  7 bytes

Note while I did eventually think of using `œ-` to avoid a byte, I now see that Nick Kennedy actually got there first!

```
Fœ-”BQṢ

```

A monadic Link that accepts a list of lists of characters (the vaccines) and yields a list of characters (the fully vaccinated).

**Try it online!** Or see the test-suite.

### How?

```
Fœ-”BQṢ - Link: list of strings (from "B", "ACWY", "ABCWY"), Vaccinations
F       - flatten
 œ-”B   - multiset difference with 'B'
     Q  - deduplicate
      Ṣ - sort

```

---

Alternative TIO:

Taking a non `[A-Z]` separating string (like `" "` or `", "`, etc):

```
œ-”BØAf
œ-”B     - multiset difference with 'B'
    ØAf  - "ABC...XYZ" filter keep

```
> 2 votes

# Answer
# JavaScript (Node.js), 44 bytes

```
s=>s.sort().filter(x=>!~(s[x]=~-s[x]),s.B=1)

```

Try it online!

# JavaScript (Node.js), 49 bytes

```
s=>[...'ABCWY'].filter(x=>s.split(x)[x=='B'?2:1])

```

Try it online!

+4 bytes if a trailing delimited is not allowed.

Worse than Arnauld's solution (41, if it use no delimit and output array)
> 2 votes

# Answer
# 05AB1E, 6 bytes

```
'Bõ.;ê

```

Port of *@NickKennedy*'s Jelly answer.

Try it online or verify all test cases.

**Explanation:**

```
   .;   # In the (implicit) input-string, replace the first
'B     '# "B"
  õ     # with an empty string ""
     ê  # Then sort and uniquify the characters of the string
        # (which is output implicitly)

```
> 2 votes

# Answer
# Excel ms365, ~~64~~63 bytes

New:

```
=CONCAT(IFERROR(MID(A1,SEARCH({"A","B*B","C"},A1),{1,1,3}),""))

```

Old:

```
=CONCAT(REPT({"A","B","CWY"},COUNTIF(A1,{"*A*","*B*B*","*A*"})))

```
> 2 votes

# Answer
# Python, 50 bytes

```
lambda s:''.join(sorted(set(s.replace('B','',1))))

```

Another port of @NickKennedy's answer, approximately. Python doesn't have a built-in multiset or corresponding set-difference operator; it does have `collections.Counter`, but that takes way too much setup. Instead, I just remove up to one `B` from the input before uniquifying and sorting (and producing a string from the resulting list). This works in both Python 2 and Python 3. The `count` argument for the `replace` method of strings is not commonly discussed, but it's clearly documented.
> 2 votes

# Answer
# Ruby, 26 bytes

```
->s{s.sub(?B,'').chars|[]}

```

Try it online!
> 2 votes

# Answer
# APL(Dyalog Unicode), ~~17~~15 bytes SBCS

```
⎕A∩⊢(/⍨)≠⍲'B'=⊢

```

Try it on APLgolf!

A tacit function which takes a string on the right using no delimiter or any delimiter that is not a capital letter. The test cases use spaces. (The test case `B` is written as `(⍬,'B')` because single characters in quotes are not treated as strings in APL)

```
⎕A∩⊢(/⍨)≠⍲'B'=⊢
          'B'=⊢  # Boolean mask for all Bs
         ⍲       # NAND
        ≠        # Boolean mask for all first instances
   ⊢(/⍨)         # apply Boolean mask (removes first B)
  ∩              # intersection
⎕A               # capital letter alphabet

```

Created with the help of Luminespire.

Taking the intersection with the alphabet helpfully removes any delimiters and sorts alphabetically.

This solution doesn't work on any of the APL versions on TIO, as @att describes.
> 1 votes

# Answer
# Charcoal, 9 bytes

```
Φα›№θι⁼κ¹

```

Try it online! Link is to verbose version of code. Accepts any character that's not an uppercase letter as a delimiter (some characters may need extra quoting). Explanation:

```
 α          Predefined variable uppercase alphabet
Φ           Filtered where
   №        Count of
     ι      Current letter
    θ       In input string
  ›         Is greater than
       κ    Current index
      ⁼     Equals
        ¹   Literal integer `1`
            Implicitly print

```
> 1 votes

# Answer
# Uiua 0.8.0, 13 bytes SBCS

```
⊏⍏.⊝▽≠⇡⧻,⊗@B.

```

Try on Uiua Pad!
> 1 votes

# Answer
# Scala, 115 bytes

A Port of @spooky\_simon's Python answer in Scala.

---

Golfed version. Attempt This Online!

```
def g(x:Boolean)=if(x)1 else 0
def f(s:String)={val x=s.contains("C");"A"*g(x)+"B"*g(s.count(_=='B')>1)+"CWY"*g(x)}

```

Ungolfed version. Attempt This Online!

```
object Main {
  def main(args: Array[String]): Unit = {
    def f(s: String): String = {
      val hasC = s.contains("C")
      val bCount = s.count(_ == 'B') > 1

      ("A" * (if (hasC) 1 else 0)) +
      ("B" * (if (bCount) 1 else 0)) +
      ("CWY" * (if (hasC) 1 else 0))
    }

    println(f("ABCWY B"))
    println(f("ABCWY"))
    println(f("B"))
    println(f("B B"))
    println(f("ACWY B B"))
    println(f("ACWY B"))
  }
}

```
> 0 votes

---
Tags: code-golf, string
---


title: Hello ASCII World!

text:
# Question
Title: Hello ASCII World!
Construct a full program which outputs `Hello, World!`. The score of your submission will be equal to the sum of all of the ASCII values of the *distinct* characters. The lowest score wins!

## Rules

* It must be a full program which takes no input
* It must only print to STDOUT, nothing else
* It must be strictly less than 1000 bytes long
* It may only include printable ASCII (meaning no `\n` allowed)
* The objective is to find the lowest score for every language, so no answer will be marked "accepted"

## Example

Here is an example submission in Python, which has a score of *1279*:

```
print"Hello, World!"

```

Finally, here is a TIO link to score your submission.

# Answer
> 14 votes
# C (gcc) `-zexecstack` `-Wl,-e$` `-nostartfiles` on Linux x86-64, ~~876~~ 914 bytes, score ~~798~~ 293

```
$=1111+1111+1111+111+111-11-11-11-11+1+1+1;$$=1111111111+111111111-11111111+1111111+1111111-111111+1111+1111+111+111+111+111+111-11-11-11-11+1+1+1+1+1;$$$=111111+111111-11111-1111+111+111+111-11-1-1-1-1-1;$$$$=111111111+111111111+11111111+11111111+11111111+1111111+1111111+111111-1111-1111-1111-1111-111-111-111+11+11+11+11+1+1+1+1+1;$$$$$=1111111111+1111111111-111111111-111111111-111111111-111111111+11111111+11111111+11111111+11111111-1111111-1111111-1111111-111111-111111-111111+11111+11111-1111+111+111+11+1;$$$$$$=111111111+111111111+111111111+111111111+111111111-11111111-1111111-1111111-1111111-1111111-111111-111111+1111+1111+1111+1111+1111-111-111-111+11+11-1-1;$$$$$$$=1111111111+1111111111-111111111-111111111-111111111-111111111+11111111+11111111+11111111+11111111-1111111-1111111-111111-111111-111111-111111-111111-1111-1111-1111-1111-1111+11+11+11+11+1;$$$$$$$$=11111-1111-1111-111-111-111-11+1+1+1;

```

Try it online!

Charset: ~~`A[]={+,-1};`~~ `1+-$=;`

Same method as the previous answer, with even more hacking to supply a custom entry point named `$` (which has the smallest ASCII value among `a-zA-Z_$`). Credit to this SO answer for identifying the flags and assembly setup to make this work. Also got a hint from ceilingcat's awesome linker hack to remove `[]{}` from the code.

Assembly: (NASM syntax)

```
bits 64
global _start
_start:
  mov edx, 13
  pop rax
  push rax
  lea rsi, [rel s]
  pop rdi
  syscall
s: db "Hello, World!"

```

Uses the `argc=1` set up on the stack to load the value 1 to `rax` and `rdi`. The instructions are slightly mixed up in order to get the minimal code length in C.

Here is the Python script that generates the "ones decomposition" from the `xxd -i` output (C include-style hex output) of the compiled binary.

---

# C (gcc) `-zexecstack` on Linux x86-64, 891 bytes, score 1154

```
main[]={1111+1111+1111+111+111-11-11-11-11+1+1+1,1111111111-111111111-111111111+11111111-1111111-111111-111111-111111-111111+11111-1111-1111-1111-1111+111+111+111+11,1+1+1+1,111111111-11111111-11111111-1111111-1111111-1111111-1111111+111111+111111+111111+111111+11111+11111+11111+11111-111-111-111-111-111-11-11-11,1111111111+1111111111-111111111-111111111-111111111-111111111+11111111+11111111+11111111+11111111-1111111-1111111-1111111+111111+11111+11111+11111+11111-1111-111-111+11+11+11,1111111111+111111111+111111111+111111111+11111111+11111111-1111111-1111111-1111111-1111111-111111-111111-111111-111111-11111-11111-11111-11111-11111+1111+1111+1111+1111-111-111-111-11-1-1-1-1,1111111111+111111111+111111111+111111111+111111111+111111111+11111111+11111111-1111111-1111111-1111111-1111111+111111+111111+111111+11111+11111+11111+11111+11111-1111-1111-1111-1111-111+11-1-1-1-1-1,11+11+11};

```

Try it online!

Uses ceilingcat's minimal Turing-complete charset `main[]={1+,};`, plus `-` to meet the code length limit.

Assembly: (NASM syntax)

```
bits 64
global _start
_start:
  mov edx, 13
  lea rsi, [rel s]
  mov eax, edi
  syscall
s: db "Hello, World!"

```

Essentially calls `write` syscall once, and goes into arbitrary instructions formed by the string literal, causing segfault.

# Answer
> 6 votes
# CJam, 652 bytes, score 120

```
'))))))))))))))))))))))))))))))))')))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))')))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'))))''(((((((')))))))))))))))))))))))))))))))))))))))))))))))')))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))''((((((

```

Try it online!

Uses `')(`.

# Answer
> 5 votes
# Stuck, 0 bytes, score 0

An empty program prints "Hello, World!"

Just as suggested in the comments, Stuck wins!

# Answer
> 5 votes
# HQ9+, 1 byte, score 72

```
H

```

There is no TIO implementation for `HQ9+`.

# Answer
> 5 votes
# Malbolge, 71 bytes, 3963 points

```
(=<`#9]=}5YXy1Uvv-Q+q)Mn&Jk#j!EC$dc.?}_<)L'8%oXW2qj|Q@yx+iba'Hd]\E!YX|z

```

Try it online!

Uses the following unique characters

```
!#$%&'()+-.12589<=?@CEHJLMQUWXY\]_`abcdijknoqvxyz|}

```

# Answer
> 4 votes
# Wolfram Language (Mathematica), 321 bytes, score 399

charset: `\013456`

```
\043\1333311\05313311\0531133\135\133\043\13311\0534011\0534031\135\133\043\1331343\05311354\135\13331\05341\054101\0544\053104\0544\053104\054111\05444\0541\05331\05443\05344\054111\054114\0544\053104\054100\05433\135\135\135\046\1330\133\1330\0540\135\135\133\116\141\155\145\163\133\135\133\133\043\135\135\135\046\135

```

Try it online!

I feel it's best to try to explain this one. First, Mathematica allows character inputs with octal triplets (From this point on, I'll be using my local copy), after decoding, looks like so

```
#[1000+31111][#[3304+11135][#[10000+13003][31+41,101,4+104,4+104,111,44,1+31,43+44,111,114,4+104,100,33]]]&[0[[0,0]][Names[][[#]]]&]

```

All of the addition is just to avoid getting a 2, 7, 8, or 9, which in octal have 2s and 7s, which are trivially avoidable, all the other characters are the minimum needed to get `Names[]`. When the actual functions are shown,

```
Print[FromCharacterCode[List[72,101,108,108,111,44,32,87,111,114,108,100,33]]]

```

Where all the functions are hidden inside a `Names[][[1234]]` so that they can all be numerically decided, but `Names[]`, at minimum, needs `\13456` to derive everything else, the 0 is needed to turn Names's string output into Functions, as `0[[0,0]]` returns `Symbol`.

I know that after making this whole thing it can be golfed to do without 0, as the only time it comes up is in addition, inside the octal for the `+` symbol, and getting the symbol header, meaning that if 0 can be derived elsewhere then in the charset 0 can be switched to +, lowering the score by 5. All it would need is to not use commas inside list. The only function that I recall that can do this is the Append family, but calling Append instead of each comma makes the program over 2k in size.

In case you want to see how it was generated, I will put most of my code here

# Answer
> 4 votes
# Knight, ~~460~~ ~~383~~ 442 bytes, score ~~268~~ ~~236~~ 226

*-32 score thanks to @Adam by utilizing `A1`*

*-10 score thanks to @emanresu A and @UnrelatedString by using `E` to EVAL `O"Hello, World"` instead of using `O` directly*

```
E+++++++++++++++A+11+11+11+11+11+11+11+1+1A1A+11+11+11+1A1A+11+11+11+11+11+11+1+1+1+1+1+1A1A+11+11+11+11+11+11+11+11+11+1+1A1A+11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1A1A+11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1A1A+111A1A+11+11+11+11A1A+11+11+1+1+1+1+1+1+1+1+1+1A1A+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1A1A+111A1A+111+1+1+1A1A+11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1A1A+11+11+11+11+11+11+11+11+11+1A1A+11+11+11A1A+11+11+11+1A1

```

Characters used: `E+A1`

Try It Online!

(Code used to generate this Knight code: Try It Online!)

# Answer
> 3 votes
# dc, ~~106~~ ~~652~~ ~~192~~ 428 bytes, score ~~332~~ ~~272~~ ~~272~~ 204

```
11 11+11+11+11+11+1+1+1+1+1+1+P11 11+11+11+11+11+11+11+11+1+1+P11 11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+P11 11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+P11 11+11+11+11+11+11+11+11+11+1+P11 11+11+11+P11 11+1+1+1+1+1+1+1+1+1+1+P11 11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1+P11 11+11+11+11+11+11+11+11+11+1+P11 11+11+11+11+11+11+11+11+11+1+1+1+1+P11 11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+P11 11+11+11+11+11+11+11+11+1+P11 11+11+P

```

Try it online!

4 characters used: `+1P` and the space character.

# Answer
> 3 votes
# brainfuck, 134 score

```
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++.+++++++..+++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++.+++.------.--------.-------------------------------------------------------------------.

```

Try it online!

Alas, could have scored 89 if not for the 1000 character limit.

# Boolfuck, 102 score

```
;;;+;+;;+;+;+;+;+;+;;+;;+;;;+;;+;+;;+;;;+;;+;+;;+;+;;;;+;+;;+;;;+;;+;+;+;;;;;;;+;+;;+;;;+;+;+;+;+;+;;;;+;+;;+;;+;+;;+;;;+;;;+;;+;+;;+;;;+;+;;+;;+;+;+;;;;+;

```

Try it online!

"Standard".

# Answer
> 3 votes
# C (gcc), ~~344~~ \\$\cdots\\$ ~~254~~ 242 bytes, score ~~1624~~ 1575

Lowered score by 49 thanks to Arnauld!!!

Saved 12 bytes thanks to ceilingcat!!!

```
h;t;u;i;a;main(c){u+=u=i+=i=a=c+c+c;t=u+u+u;putchar(putchar(t+t)+u+u+a+c+c);putchar(putchar(putchar(h=t+t+t))+a);putchar(t+i+c+c);putchar(u+u+i+c+c);putchar(t+t+u+a);putchar(h+a);putchar(h+i);putchar(h);putchar(t+t+u+u+a+c);putchar(u+u+i+a);}

```

Try it online!

Uses characters: `()+;=achimnprtu{}`

# Answer
> 3 votes
# Grass, score 324, 623 bytes

```
wvwwWWwWWWwvWwwwwWWwWWWwWWWWwWWWWWwWWWWWWwWWWWWWWwWwwwwwwwwwwwwWWWWwWWWWWWWwWWWWWWWWWWWWWWwWWWWWWWWWWWwwWWWWWWWWWWwwWWWWWWWWWWWWwWWWWWWWWWWwwWWWWWWWWWWwwwwwwwWWWWWWWWWWWWWWwWWWWWWWWWWWWWWWWwWWWWWWWWWWWWWWWWWWWWWWwWWWWWWWWWWWWWWWWWWWwwWWWWWWWWWWWWWWWWWWwwWWWWWWWWWWWWWWWWWWwwwwwWWWWWWWWWWWWWWWWWWWWWwwWWWWWWWWWWWWWWWWWWWWWWWwWWWWWWWWWWWWWWWWWWWWWWWWWWwwwwwwwwwwwwwwwwwwwwwwwwwwwWwwwwwwwwwwwWWwwwwwwwWWWwwwwwwwWWWWwWWWWWwwwwwwwwWWWWWWwwwwwwwwwwwwwwwwwWWWWWWWwwwwwwwwwwwwwwwwwwwwwWWWWWWWWwwwwwwwwwwwwwwwwwWWWWWWWWWwwwwWWWWWWWWWWwwwwwwwwwwwWWWWWWWWWWWwwwwwwwWWWWWWWWWWWWwwwwwwwwwwwwwwwwwwWWWWWWWWWWWWWwwwwwwwwwwwwwwwwwwwwwwwwww

```

# Answer
> 2 votes
# Brain-Flak, 618 bytes, score 265

```
((((((()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())()()()()()()()())()()()()()())[()()()])[()()()()()()()()()()()()()()()()()()()()()()()()])(((((((()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())()()()()()()()()()()()())()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()())[()()()]))[()()()()()()()])[()()()()()()()()()()()()()()()()()()()()()()()()()()()()()])

```

Try it online!

Used characters: `()[]`

Uses `()` (one), `(...)` (sum and push), `[...]` (negate). Can definitely be shorter by using `[]` (stack height) but it's not the point of the challenge (as long as the code is under 1000 bytes). Looks like the program can't fit into 1000 bytes using only `()` and `(...)`.

# Answer
> 2 votes
# Python 2, 574 bytes, score 564

```
exec"%c"%(111+1)+"%c"%(111+1+1+1)+"%c"%(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1)+"%c"%(11+11+11+11+11+11+11+11+11+11)+"%c"%(111+1+1+1+1+1)+"%c"%(11+11+11+1+1+1+1+1+1)+"%c"%(11+11+11+11+11+11+1+1+1+1+1+1)+"e%c"%(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1)+"%c"%(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1)+"%c"%111+"%c"%(11+11+11+11)+"%c"%(11+11+1+1+1+1+1+1+1+1+1+1)+"%c"%(11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1)+"%c"%111+"%c"%(111+1+1+1)+"%c"%(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1)+"%c"%(11+11+11+11+11+11+11+11+11+1)+"%c"%(11+11+11)+"%c"%(11+11+11+1+1+1+1+1+1)

```

Try it online!

Used characters: `exc"%(1+)`

Constructs the string `print'Hello, World!'` using the characters `"%c(1+)`, then `exec`s it. Using the raw `print` with any single extra character costs more than this.

# Answer
> 2 votes
# 05AB1E, score: 282 (251 bytes)

```
0>>>0>>>>>>>>>0>0>>>0>>>>>>>>0>>>>>0>>>0 0>>>>>>0>>>>>>>>0>>>>>>>>0>>>>0>>>>>>>0>>0 0>>>>>>>0>>>0 0>>>>>0>>>>>>>>>0>>0>>>0>0>>>>>>0 0>>>>>>>J 0>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>B

```

Try it online.

Five characters used: `0> JB`

**Explanation:**

1. First we construct the number `39138530688472073059231607`. We do this per digit, by pushing a `0` and increasing it by 1 per `>`, after which the entire stack of digits is joined together with `J`.
2. Then it pushes another `0` with 107 `>`s to get the number `107`.
3. After which it will convert `39138530688472073059231607` to base-107 with `B`, which is `"Hello, World!"`.

# Answer
> 2 votes
# Help, WarDoq!, 1 byte, Score: 72

```
H

```

Try It Online!

# Answer
> 2 votes
# , 2 bytes, score 223

```
hw

```

Try it online!

# Answer
> 2 votes
# Bits, score: 97

There are only 2 distinct characters in Bits, `0` and `1`. These have ASCII values of \\$48\\$ and \\$49\\$, so the score is \\$97\\$.

If you're interested, this is actually only 10 bytes (80 bits).

```
10010000001010011000011000011110111000111111010111001111010010001100000100011101

```

### Explanation

```
1001000 // H
000101  // e
001100  // l
001100  // l
001111  // o
011100  // ,
011111  //
1010111 // W
001111  // o
010010  // r
001100  // l
000100  // d
011101  // !
        // [implicitly joined and output]

```

# Answer
> 1 votes
# Gol\>\<\>, 234 bytes, score 259

```
llllllll+++l+++++lllllllllllll+++++l++++++++llllllllllll+++++l+l+++++++llllllllllll+++l+++++++++lllllllllll+++l++++++++lllllll++ll++l+++++llll+++l+l+lll++l+$llllllll++++++l++l+llllll+++lll+++++llllllll+++++++lll++l+l+l+llllll++++l++$H

```

Try it online!

Used characters: `l` (length of stack), `+` (add top two numbers), `$` (swap top two numbers), `H`.

`$` was needed because some characters (space, H) were impossible to create at that specific stack height; it is cheaper than any number literal (minimum being 0).

---

# Gol\>\<\>, 182 bytes, score 315

```
ssP0ssssssPPPP0ssssssPPPPPPPPPPPP0sssssssPP0ssssssPPPPPPPPPPPPPPP0sssssPPPPPPP0ss0ssPPPPPPPPPPPP0ssssssPPPPPPPPPPPPPPP0ssssssPPPPPPPPPPPP0ssssssPPPPPPPPPPPP0ssssssPPPPP0ssssPPPPPPPPH

```

Try it online!

Used characters: `0` (push zero to the stack), `s` (add 16 to top), `P` (increment top), `H` (halt and print everything on the stack as characters).

# Answer
> 1 votes
# C (gcc), 540 bytes, score 1563

```
main(){putchar(11+11+11+11+11+11+1+1+1+1+1+1);putchar(11+11+11+11+11+11+11+11+11+1+1);putchar(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1);putchar(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1);putchar(11+11+11+11+11+11+11+11+11+11+1);putchar(11+11+11+11);putchar(11+11+1+1+1+1+1+1+1+1+1+1);putchar(11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1);putchar(11+11+11+11+11+11+11+11+11+11+1);putchar(11+11+11+11+11+11+11+11+11+11+1+1+1+1);putchar(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1);putchar(11+11+11+11+11+11+11+11+11+1);putchar(11+11+11);}

```

Try it online!

This is just a straightforward solution that prints the ASCII code of each character in turn, like some of the other solutions here. I'm not aware of any tricky way to reduce the score in C.

# Answer
> 1 votes
# Rust, 35 bytes, Score: 1916

```
fn main(){print!("Hello, World!")}

```

I don't know if you can get any shorter in Rust.

# Answer
> 1 votes
# Bash, 18 bytes, score 1005

```
echo Hello, World!

```

Try it online!

# Answer
> 1 votes
# PHP, 13 bytes, score 802

```
Hello, World!

```

Try it online!

# Answer
> 1 votes
# naz, 732 bytes, score 372

```
1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1o1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1o1a1a1a1a1a1a1a1o1o1a1a1a1o1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1o1s1s1s1s1s1s1s1s1s1s1s1s1o1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1o1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1o1a1a1a1o1s1s1s1s1s1s1o1s1s1s1s1s1s1s1s1o1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1s1o

```

Uses `1`, `a`, `s` and `o`.

Without the size restriction, naz `-u` could achieve a theoretical score of 257 by foregoing `s`.

# Answer
> 1 votes
# G\*, 15 bytes, score = 914

```
p Hello, World!

```

# Answer
> 1 votes
# 2/9 of an esolang, 1 byte, score = 64

```
@

```

# Answer
> 1 votes
# Perl 5, 386 bytes, score = 818

```
say chr 11+11+11+11+11+11+1+1+1+1+1+1,chr 11+11+11+11+11+11+11+11+11+1+1,chr 11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1,chr 11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1,chr 111,chr 11+11+11+11,chr 1+1+1+1+1+1+1+1+1+1+11+11,chr 11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1,chr 111,chr 111+1+1+1,chr 11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1,chr 11+11+11+11+11+11+11+11+11+1,chr 11+11+11

```

Try it online!

# Answer
> 1 votes
# Nim, 387 bytes, score 601

```
ecHO cHR 11+11+11+11+11+11+1+1+1+1+1+1,cHR 11+11+11+11+11+11+11+11+11+1+1,cHR 11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1,cHR 11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1,cHR 111,cHR 11+11+11+11,cHR 11+11+1+1+1+1+1+1+1+1+1+1,cHR 11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1,cHR 111,cHR 111+1+1+1,cHR 11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1,cHR 11+11+11+11+11+11+11+11+11+1,cHR 11+11+11

```

Try it online!

Chars: `ecHRO, +1`

# Answer
> 1 votes
# Pyth, 430 bytes, score 191

```
++++++++++++C+++++++++++11 11 11 11 11 11 1 1 1 1 1 1C++++++++++11 11 11 11 11 11 11 11 11 1 1C+++++++++++++++++11 11 11 11 11 11 11 11 11 1 1 1 1 1 1 1 1 1C+++++++++++++++++11 11 11 11 11 11 11 11 11 1 1 1 1 1 1 1 1 1C111C+++11 11 11 11C+++++++++++11 11 1 1 1 1 1 1 1 1 1 1C++++++++111 1 1 1 1 1 1 1 1C111C+++111 1 1 1C+++++++++++++++++11 11 11 11 11 11 11 11 11 1 1 1 1 1 1 1 1 1C+++++++++11 11 11 11 11 11 11 11 11 1C++11 11 11

```

Try it online!

# Answer
> 1 votes
# Deadfish~, 1 byte, score 119

```
w

```

Try it online!

Not so interesting

# Answer
> 1 votes
# Excel, 409 bytes, score 558

```
=CHAR(11+11+11+11+11+11+1+1+1+1+1+1)&CHAR(11+11+11+11+11+11+11+11+11+1+1)&CHAR(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1)&CHAR(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1)&CHAR(111)&CHAR(11+11+11+11)&CHAR(11+11+1+1+1+1+1+1+1+1+1+1)&CHAR(11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1)&CHAR(111)&CHAR(111+1+1+1)&CHAR(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1)&CHAR(11+11+11+11+11+11+11+11+11+1)&CHAR(11+11+11)

```

Link to Spreadsheet

# Answer
> 1 votes
# Excel VBA (Immediate Window), 396 bytes, score 457

```
?CHR(11+11+11+11+11+11+1+1+1+1+1+1)+CHR(11+11+11+11+11+11+11+11+11+1+1)+CHR(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1)+CHR(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1)+CHR(111)+CHR(11+11+11+11)+CHR(11+11+1+1+1+1+1+1+1+1+1+1)+CHR(11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1)+CHR(111)+CHR(111+1+1+1)+CHR(11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1)+CHR(11+11+11+11+11+11+11+11+11+1)+CHR(11+11+11)

```

Similar to the Excel answer. Uses 2 fewer unique characters.

# Answer
> 1 votes
# Go, 61 bytes, score 2527

```
package main;import."fmt";func main(){Print("Hello, World!")}

```

Attempt This Online!

The boilerplate hello world, compressed onto 1 line.

# Answer
> 1 votes
# Vyxal, 4528 bytes, score 156

```
..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C+..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C+..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C+..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C+..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C+..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C+..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C+..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C+..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C+..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C+..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C+..+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+C+

```

Try it Online!

`.` on its own represents 0.5, so this adds up a bunch of 0.5s, converts them to characters, then concatenates them together. This actually does better than using the builtin `kH`, which has a score of 179.

# Answer
> 0 votes
# Erlang (escript), 439 bytes, score: 1706

Port of the 540 byte C answer. Unique characters:

```

main([])->o:fwrte1+,.

```

Which is of length 23, sum 1706.

```

main([])->io:fwrite([11+11+11+11+11+11+1+1+1+1+1+1,11+11+11+11+11+11+11+11+11+1+1,11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1,11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1,11+11+11+11+11+11+11+11+11+11+1,11+11+11+11,11+11+1+1+1+1+1+1+1+1+1+1,11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1,11+11+11+11+11+11+11+11+11+11+1,11+11+11+11+11+11+11+11+11+11+1+1+1+1,11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1,11+11+11+11+11+11+11+11+11+1,11+11+11]).

```

Try it online!

# Answer
> 0 votes
# Java (JDK), 468 bytes, score 1234

```
\u0063\u006c\u0061\u0073\u0073\u0020\u0041\u007b\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0076\u006f\u0069\u0064\u0020\u006d\u0061\u0069\u006e\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u005b\u005d\u0061\u0029\u007b\u0053\u0079\u0073\u0074\u0065\u006d\u002e\u006f\u0075\u0074\u002e\u0070\u0072\u0069\u006e\u0074\u0028\u0022\u0048\u0065\u006c\u006c\u006f\u0020\u0057\u006f\u0072\u006c\u0064\u0021\u0022\u0029\u003b\u007d\u007d

```

Try it online!

Note: I'm stumped on how to make it have less score. Oracle really does make it hard to golf. Thanks to @ceilingcat for and halfing the score.

# Answer
> 0 votes
# Zsh, 464 bytes, score 552

Try it Online! charset: `<${(#)1+}`

```
<<<${(#)$((11+11+11+11+11+11+1+1+1+1+1+1))}${(#)$((11+11+11+11+11+11+11+11+11+1+1))}${(#)$((11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1))}${(#)$((11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1))}${(#)$((111))}${(#)$((11+11+11+11))}${(#)$((11+11+1+1+1+1+1+1+1+1+1+1))}${(#)$((11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1+1))}${(#)$((111))}${(#)$((111+1+1+1))}${(#)$((11+11+11+11+11+11+11+11+11+1+1+1+1+1+1+1+1+1))}${(#)$((11+11+11+11+11+11+11+11+11+1))}${(#)$((11+11+11))}

```

# Answer
> 0 votes
# Julia, 107 bytes, score 815

```
print('i'-11-11-11,'p'-11,'n'-1-1,'n'-1-1,'p'-1,',',','-11-1,'n'-11-11-1,'p'-1,'r','n'-1-1,'p'-11-1,','-11)

```

characters used `print('-1,)`

Try it online!

# Answer
> 0 votes
# AWK, 57 bytes, score 1632

Escape sequences are in octal.

```
BEGIN{print"\110\145\154\154\157\54\40W\157r\154\144\41"}

```

Try it online!

Score count

# Answer
> 0 votes
# KonamiCode, 168 bytes (score 415)

```
v(^^^^^^^>^^)<<v(^>>^)<<v(^>>^^^^^^^^)<<v(^>>^^^^^^^^)<<v(^>^>^)<<v(^^^^>^^^^)<<v(^^^>^^)<<v(^>^>^^^^^^^^^)<<v(^>^>^)<<v(^>^>^^^^)<<v(^>>^^^^^^^^)<<v(^>>)<<v(^^^>^^^)<<

```

Characters used: `^v<>()`

# Answer
> 0 votes
# Ly, 378 bytes (score 309)

````````````````````````````````````````````````````````````````````````:o`````````````````````````````:o```````::oo```:o,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:o,,,,,,,,,,,,:o```````````````````````````````````````````````````````:o````````````````````````:o```:o,,,,,,:o,,,,,,,,:o,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,o
</code></pre>

Try it online!

Uses four instructions, increment top of stack, duplicate top of stack, decrement top of stack, and print as a character.

```
 :,o`

```

# Answer
> 0 votes
# MATLAB, 15 Bytes (score 802)

```
'Hello, World!'

```

# Answer
> 0 votes
## Pascal, 1449

1. **2189**: The boilerplate Hello World reads:
```
program p(output); begin writeLn('Hello, World!') end.

```
2. **2080**: Since Pascal is case-insensitive we can capitalize keywords and identifiers. This lowers the score because capital letters come before lower-case letters:
```
PROGRAM P(OUTPUT); BEGIN WRITELN('Hello, World!') END.

```
3. **1706**: Now, as some keywords are non-optional and our program needs definitely needs at least one string or `char` literal in conjunction with some `write`, we can reuse the preexisting letters in our `Hello, World!` string.
```
ProGrAM P(oUTPUT); BeGIN WrITe('Hello, World!') eNd.

```
The now lower-cased letters already appear as part of `Hello, World!`. Only `H``l``,` and `!` are “new” letters which aren’t found in the rest of the `program`.
4. **1449**: Let’s avoid any characters from set of `['H', 'l', ',', '!']` by using “preexisting” letters and the built-ins we can use with them. If we are running this `program` on a system using the ASCII character set as its base, we can use `pred('I')` to retrieve the value `'H'` *without* writing a `char` literal `'H'`:
```
ProGrAM P(oUTPUT); BeGIN WrITe(Pred('I')); WrITe('e'); WrITe(Pred(Pred(Pred('o')))); WrITe(Pred(Pred(Pred('o')))); WrITe('o'); WrITe(Pred(Pred('.'))); WrITe(' Wor'); WrITe(Pred(Pred(Pred('o')))); WrITe('d'); WrITe(Pred(Pred(Pred(Pred(Pred(Pred(''''))))))) eNd.

```
This `program` merely requires an ISO standard 7185 “Standard Pascal” processor (level 0 sufficient). It has a total size of **216 bytes** thus below the eight, uhh… whoops, *one thousand* byte limit.

# Answer
> 0 votes
# C# (.NET Core), 71 bytes (score 2563)

```
class a{static void Main(){System.Console.WriteLine("Hello, World!");}}

```

Try it online!

I'm just starting with C#, so maybe there's a way to do it even shorter

# Answer
> 0 votes
# Gema, 59 characters, score 858

```
\A=\110\145\154\154\157\054\040\127\157\162\154\144\041@END

```

(Doh. After all these years, now I discovered that Gema function names are case insensitive.)

Sample run:

```
bash-5.2$ gema '\A=\110\145\154\154\157\054\040\127\157\162\154\144\041@END'
Hello, World!

```

Try it online!

---
Tags: code-challenge, restricted-source, hello-world
---