g | x | w | all
Bytes Lang Time Link
064Lua250428T000616ZjanMakos
090Tcl180531T210755Zsergiol
002Thunno 2 Ṡ230812T195032ZThe Thon
015CJam180601T082249Zmaxb
094Lua 5.3180623T212021ZIDid
097Ruby180623T172136ZAlex All
117Whitespace180531T114545ZKevin Cr
041Ruby180531T184855ZAsone Tu
063Haskell180622T064642ZEsolangi
069[C gcc]180601T053906ZErikF
228ABAP180607T093328ZMaz
009Stax180531T131220Zwastl
061PHP180602T100141ZTitus
013APL Dyalog Unicode180531T142910ZGalen Iv
105PHP 105 Bytes180531T194732ZFrancisc
062Java 8180531T111920ZKevin Cr
045jq180601T053145ZNaï
nan180531T200746ZBrad Gil
067C gcc180531T191937Zvazt
009Japt 2.0 S180531T182733ZOliver
035Perl 5 p180531T183906ZXcali
070PHP180531T123157Zuser2803
010Pyth180531T145836ZDave
047Perl 5180531T163712Zfockjef
035x86 opcode180531T142939Zl4m2
054JavaScript Node.js180531T093418ZMuhammad
050R180531T091556ZGiuseppe
133MSSQL180531T141853ZBradC
093Red180531T132015ZGalen Iv
063PowerShell180531T124444ZAdmBorkB
049Python 3180531T094233Zovs
021Charcoal180531T121224ZNeil
4555Python 2180531T112623ZJonathan
010Japt v2.0a0 S180531T105348ZShaggy
078Jelly180531T110145ZJonathan
05705AB1E180531T111411ZJonathan
01405AB1E180531T092747ZEmigna
104Python 2180531T092504ZTheo C
00805AB1E180531T093425ZOkx
084Python 3180531T094126ZJo King

Lua, 64 bytes

(...):upper():gsub('%a',function(a)io.write(a:byte()-64,' ')end)

Try it online!

Explanation

Uiua, 14 bytes

/$"_ _"-@@▽⊸±⌵

Try it in the pad!

Explanation

             ⌵ # Normalize to uppercase
          ▽⊸±  # Filter alphabetic characters
       -@@     # Convert to alphabetic positions
/$"_ _"        # Join with spaces

Tcl, 90 bytes

puts [lmap c [split $argv ""] {expr {[string is alp $c]?([scan $c %c]-64)%32:[continue]}}]

Try it online!

Thunno 2 , 2 bytes

ỊÄ

Try it online!

Explanation

    # Implicit input
Ị   # Keep only alphabetic characters
 Ä  # And get the 1-based indices in the alphabet
    # Implicit output, joined by spaces

CJam, 23 15 bytes

qel_eu-{i32%S}/

Try it online!

Saved 8 bytes thanks to Esolanging Fruit

Lua (5.3), 94 bytes

x=...y=""for i=1,#x do z=x:sub(i,i)y=y..(z:find"%a"and(z:byte()&~32)-64 .." "or"")end print(y)

Try it online!

Ruby, 97 bytes

n=[];gets.chomp.gsub(/[^a-zA-Z]/,'').upcase.bytes.each{|i|n.push i-64};puts n.map(&:to_i).join" "

Try it online!

Whitespace, 152 117 bytes

-35 bytes thanks to @Lynn.

[N
S S N
_Create_Label_LOOP][S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   S _Read_STDIN_as_character][T   T   T   _Retrieve][S N
S _Duplicate_input][S S S T S S S S S N
_Push_32][T S T T   _Modulo][S N
T   _Swap_top_two][S S S T  T   T   T   T   T   N
_Push_63][T S T S _Integer_divide][T    S S N
_Multiply][S N
S _Duplicate][S S S T   T   S T T   N
_Push_27][S T   S S T   N
_Copy_1st][S S S T  N
_Push_1][T  S S S _Add][T   S T S _Integer_divide][T    S S N
_Mulitply][N
T   S N
_If_0_Jump_to_Label_LOOP][T N
S T _Print_as_number][S S S T   S S S S S N
_Push_32_space][T   N
S S _Print_as_character][N
S N
N
_Jump_to_Label_LOOP]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online (with raw spaces, tabs and new-lines only).

Explanation in pseudo-code:

Start LOOP:
  Character c = STDIN as character
  Integer n = (c modulo-32) * (c integer-divided by 63)
  Integer m = 27 integer-divided by (n + 1) * n;
  If(m == 0):
    Go to next iteration of LOOP
  Else:
    Print n as integer to STDOUT
    Print a space to STDOUT
    Go to next iteration of LOOP

Ruby, 41 bytes

->s{s.scan(/\p{L}/).map{|i|i.ord%32}*' '}

Try it online!

Haskell, 63 bytes

import Data.Char
unwords.map(show.(`mod`32).ord).filter isAlpha

Try it online!

[C (gcc)], 57 56 bytes (printing), 70 69 bytes (printing w/optional), 146 bytes (string)

Thanks to ceilingcat for the && optimization.

f(char*s){for(;*s;s++)isalpha(*s)&&printf("%d ",*s&31);}

Try it online!

This version takes alphanumeric text per the additional challenge:

f(char*s){for(;*s;s++)isalnum(*s)&&printf("%d ",(*s<65)*10+(*s&31));}

Try it online!

If returning a string is required for this challenge:

char*f(s,t,u,i)char*s,*t,*u;{for(i=strlen(s)*4,t=calloc(i,2),u=t+i;*s;s++)isalnum(*s)?sprintf(u,"%d ",(*s<65)*10+(*s&31)),strcat(t,u):0;return t;}

Try it online!

ABAP, 228 bytes, letters only

I wrote a FORM subroutine for an ABAP report. i is input, o is output.

FORM h USING i o.TRANSLATE i TO UPPER CASE.DO strlen( i ) TIMES.data c(2).c = sy-index - 1.FIND i+c(1) IN 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' RESULTS data(r).CHECK sy-subrc = 0.c = r-offset + 1.CONCATENATE o c ` ` INTO o.ENDDO.ENDFORM.

Verbose code:
Look at it on Pastebin.com for syntax highlighting. (Not that it looks much better)

"This stuff is used to actually run the program, call the form and output the results.
REPORT z.
PARAMETERS se_input TYPE string.
START-OF-SELECTION.
    DATA ret type string.
    PERFORM h USING se_input ret.
    WRITE ret.

"---- CODE STARTS HERE ----
FORM f USING i o.              "Two parameters: i for input, o for output.
    TRANSLATE i TO UPPER CASE. "All to uppercase
    DO strlen( i ) TIMES.      "Do for each character
        data c(2).             "A char field, length of 2
        c = sy-index - 1.      "Current loop index - 1 = index in string. Loop index starts at 1.
        FIND i+c(1)            "Find substring: input at position index, length 1...
         IN 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' RESULTS data(r). "...in the alphabet, save to "r"
        CHECK sy-subrc = 0.    "sy-subrc <> 0 => not in the alphabet, skips the rest of this loop (same as CONTINUE)
        c = r-offset + 1.      "r-offset is the index in the string, add one for alphabet position
        CONCATENATE o c ` ` INTO o. "Concatenate it all into the output chars, including the literal space.
                  "      ^- had I used ' ' here, CONCATENATE would remove blank space, but ` ` stays untouched.
    ENDDO. "Loop end
ENDFORM.   "FORM end

Notes, thoughts, background stuff

First of all, no, I did not miss spaces in my code. ABAP wants them and will not run without them...

The USING parameters i and o are of unknown type, so the program calling the FORM must use a string (or char field with at least length of input * 3: 2 characters + space per letter) for o, otherwise results can be cut off or it all just dumps right away if it's a numeric value for example.

I saved a few bytes here by re-using the same character field over and over again, abusing the fact that ABAP implicitly converts numbers to chars and vice versa without any issues. This is especially better than using the CONDENSE <var> statement, which was initially necessary to not have my integers padded to 26 characters width.

Getting substrings in ABAP is super quick and easy once you get used to it:
substring = string+offset(length).
Thanks to the implicit conversion, offset can be even a character field. Nasty, but great for us in this case. But be careful: While string+5 gives you the substring starting from index 5, string + 5 will try to cast your string to a number and add 5. Spaces matter!

There's also an easy way to convert the character to a byte value, giving me the ASCII code and removing the need to do the lengthy FIND IN ... stuff, but on a Unicode SAP system there's no quick and dirty way to convert that byte value into a "readable" number that I know of, so it's kind of a red herring.

By the way: TRANSLATE i TO UPPER CASE. is exactly 26 bytes long, so at first glance it looks like we don't even need it and can just add the lowercase letters to the alphabet string instead. But you probably realized right away why we can't do that. ;-)


Bonus:

ABAP, 238 bytes, alphanumeric

For the alphanumeric version we just add 0123456789 to the alphabet string, hence increasing the length of the code by 10 bytes. Not very interesting, but any other approach would just be longer thanks to the very, uhm, verbose language that ABAP is.

FORM h USING i o.TRANSLATE i TO UPPER CASE.DO strlen( i ) TIMES.data c(2).c = sy-index - 1.FIND i+c(1) IN 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' RESULTS data(r).CHECK sy-subrc = 0.c = r-offset + 1.CONCATENATE o c ` ` INTO o.ENDDO.ENDFORM.

I hope my explanation is somewhat interesting. Thanks for the challenge!

Stax, 9 10 9 bytes

üpÉÿ%}},√

Run and debug it

-1 byte thanks to @recursive

Explanation:

v{VaIvm0-J Full program, unpacked, implicit input
v          Lowercase
 {    m    Map:
  VaI        Index in lowercase alphabet (0-based, -1 for not found)
     ^       Increment
       0-  Remove zeroes
         J Join by space
           Implicit output

Stax, 7 bytes

É▌Xl»↔"

Run and debug it

This one outputs newline-separated. Unpacked: vmVaI^|c. Similar, but with map, which implicitly outputs with trailing newline.

PHP, 61 bytes

works in any PHP version from 4.0.4 to 7.2 (but might cease to work in 7.3)

while(~$c=$argn[$i++])ctype_alpha($c)&&print(ord($c)&31)." ";

Run as pipe with -nr or try it online.

APL (Dyalog Unicode), 24, 20, 14 13 bytes

-4 bytes thanks to Zacharý (and Mr. Xcoder)!

-6 bytes thanks to Adám!

-1 byte thanks to ngn!

⎕A⍳⎕A∩⍨≡819⌶⊢

Try it online!

Explanation:

        ≡819⌶⊢  - to uppercase
   ⎕A∩⍨         - intersect with the letters A-Z (args swapped to preserve the order)
   ⍳              - index in
⎕A               - the A-Z letters list

My initial solution:

APL (Dyalog Unicode), 24 20 bytes

{⍵/⍨27>⍵}⎕A⍳1(819⌶)⊢

Try it online!

Explanation:

             ⍳           indices of     
              1(819⌶)⊢  the right argument (⊢) changed to uppercase
          ⎕A            in the list of uppercase letters
{⍵/⍨     }              copy (filter) those items from the list of indeces
     27>⍵               which are smaller than 27 (all non A-Z chars will have index 27)

Don't laugh at me, I'm new to APL :)

PHP 108 105 Bytes

Try it online (108 Bytes)

Tri it online (105 Bytes)

-3 Bytes, thanks to @manassehkatz (Change the level of strtolower and remove A-Z from regex)

Code, tried to avoid any loop

<?=strtr(implode(" ",str_split(preg_replace(
"/[^a-z]/",'',strtolower($argv)))),array_flip(range("`",z)));

Explanation

$string = preg_replace("/[^a-z]/",'',strtolower($argv))  
//the string only contains letters

$string = implode(" ",str_split($string)); 
//the string has a space after every letter

$string = strtr($string, array_flip(range("`",z)));  
//replace every letter   acording to the array

$replacementArray = array_flip(range("`",z));
//this array contains the ansi characters from "`" to the "z"
//array_flip to change the keys with the values
//final array ["`"=>0,"a"=>1, "b"=>2...."z"=>26]

Java 8, 82 78 72 69 62 bytes

s->{for(int c:s)System.out.print(c>64&~-c%32<26?c%32+" ":"");}

-13 bytes thanks to @OlivierGrégoire.

Try it online.

Explanation:

s->                    // Method with character-array parameter and no return-type
  for(int c:s)         //  Loop over its characters as integers
    System.out.print(  //   Print:
     c>64&~-c%32<26?   //    If the current character is a letter:
      c%32+" "         //     Print the position in the alphabet with a trailing space
     :                 //    Else:
      "");}            //     Print nothing

jq, 45 bytes

[gsub("\\W";"")|explode[]%32|@text]|join(" ")

 gsub("\\W";"")                                # remove non-alpha characters
               |explode[]                      # get decimal values of characters
                         %32                   # get positions in alphabet
                            |@text             # convert back to string
[                                 ]|join(" ")  # join with a space

Try it online

Perl 6, 32 bytes (alpha), 41 bytes (alpha+digit)

{~(.uc.comb(/<:L>/)».ord X-64)}

Try it (32 bytes alpha)

{~((.uc.comb(/<:L+:N>/)».ord X-64)X%43)}

Try it (41 bytes alpha + digit)

Expanded:

32 bytes alpha

{  # bare block lambda with implicit parameter $_

  ~( # coerce to string (space separated)

      .uc                      # uppercase
      .comb( / <:L > / )\      # get letters as a sequence
      ».ord                    # get the ordinal of each
      X- 64                    # subtract 64 from each
  )
}

41 bytes alpha + digit

{  # bare block lambda with implicit parameter $_

  ~( # coerce to string (space separated)
    (
      .uc                      # uppercase
      .comb( / <:L + :N > / )\ # get letters and numbers as a sequence
      ».ord                    # get the ordinal of each
      X- 64                    # subtract 64 from each
    ) X% 43                    # modulus 43 for each
  )
}

C (gcc), 67 bytes

c;f(char*s){for(;*s;)(c=tolower(*s++)-96)>0&c<27&&printf("%d ",c);}

Try it online!

Converts each char to lowercase, offsets its code by -96 and, if it falls in the range of the 1-indexed alphabet, prints the offset code

Japt 2.0 -S, 9 bytes

f\l ®c %H

Run it online

Explanation:

f\l ®c %H                                    Input: "Hello..."
f            Match:
 \l             [A-Za-z]                     ["H","e","l","l","o"]
    ®        Map Z over the results:
     c         char-code of Z                [72,101,108,108,111]
       %H      mod 32                        [8,5,12,12,15]
-S           Join the chars with a space     8 5 12 12 15

Perl 5 -p, 35 bytes

$_="@{[map{(-64+ord uc)%43}/\w/g]}"

Try it online!

Includes the extra portion about the digits.

PHP, 70 bytes

for(;$c=$argv[1][$i++];)if(($c=ord($c))>64&($c%=32)>0&$c<27)echo"$c ";

Try it online!

-5 bytes thanks to Kevin

Pyth, 10 bytes

jdfTmhxGr0

I'm pretty sure this can be golfed a little bit... -2 bytes if I can output as a list, some answers seem to but it's not in the spec

Try it online!

Perl 5, 47 bytes

With additional challenge of parsing digits:

print map{(ord(uc)-64)%43," "}<>=~/([A-Z\d])/gi

Try it online!

Reduced to 38 bytes by ignoring digits

print map{ord()%32," "}<>=~/([A-Z])/gi

x86 opcode, 35 bytes

0080h: AC 3C 24 75 04 88 45 FF C3 0C 20 2C 60 76 F1 D4
0090h: 0A 0D 30 30 86 E0 3C 30 74 01 AA 86 E0 AA B0 20
00a0h: AA EB DD                                       

f:  lodsb
    cmp al, '$'
    jnz @f
        mov [di-1], al
        ret
    @@:
    or al, 32
    sub al, 96
    jbe f
    aam
    or ax, 3030H
    xchg ah, al
    cmp al, 48
    jz @f
        stosb
    @@:
    xchg ah, al
    stosb
    mov al, 32
    stosb
    jmp f

Assuming the result contain at least one letter, and no {|}~

40 bytes, allowing all ASCII chars

0080h: AC 3C 24 75 04 88 45 FF C3 0C 20 2C 60 76 F1 3C
0090h: 1A 77 ED D4 0A 0D 30 30 86 E0 3C 30 74 01 AA 86
00a0h: E0 AA B0 20 AA EB D9                           

JavaScript (Node.js), 69 55 54 bytes

t=>t.match(/[a-z]/gi).map(i=>parseInt(i,36)-9).join` `

Try it online!

Explanation :

t =>                       // lambda function accepting a string as input
    t.match(/a-z/gi).      // returns all parts of string that match as an array 
        map(i=>            // map over that array with argument i 
            parseInt(i,36) // convert to base 36 
                - 9        // and subtract 9 from it
        ).                 // end map
        join` `            // convert to space separated string

11 bytes saved thanks to @Kevin

1 more bytes thanks to @Neil


You can add support for numericals for some additional bytes (thanks to @neil)

JavaScript (Node.js), 62 bytes

t=>t.match(/[^_\W]/g).map(i=>(parseInt(i,36)+26)%36+1).join` `

Try it online!

R, 55 50 bytes

cat(utf8ToInt(gsub("[^A-Za-z]","",scan(,"")))%%32)

Try it online!

Reads input from stdin, converts to uppercase, removes non-uppercase alphabetic letters, converts to code points, subtracts to 64 mods by 32, and prints to stdout, separated by spaces.

Thanks to Kevin Cruijssen for the golf!

MS-SQL, 133 bytes

SELECT STRING_AGG(ASCII(substring(upper(s),number+1,1))-64,' ')FROM
spt_values,t WHERE type='P'AND substring(s,number+1,1)LIKE'[a-z]'

Per our IO rules, input is taken via a pre-existing table t with varchar field s.

SQL 2017 or later is required. Must also be run in the master database, because I'm taking advantage of a system table called spt_values, which (when filtered by type='P') contains counting numbers from 0 to 2047.

Basically I'm joining a number table with the input string using SUBSTRING(), which returns a separate row for each individual character. This is filtered for only letters using LIKE'[a-z]', then we get their ASCII value and subtract 64. These numbers are joined back into a string using the (new to SQL 2017) function STRING_AGG.

Red, 93 bytes

func[s][a: charset[#"a"-#"z"]parse lowercase s[any[copy c a(prin[-96 + to-char c""])| skip]]]

Try it online!

PowerShell, 63 bytes

"$(([char[]]"$args".ToUpper()|%{$_-($_,64)[$_-in65..90]})-ne0)"

Try it online!

(Seems long ...)

Takes input $args, converts it .ToUppercase, casts it as a char-array, feeds that into a for each loop. Inside the loop, we subtract either itself or 64 from the (ASCII int) value, based on whether or not the current value is -in the range 65 to 90 (i.e., it's an ASCII capital letter). Those values are left on the pipeline, and we use a -notequal to eliminate the non-letter values (because they're all zero). Those numbers are encapsulated in a string as the default stringification of an array is to space-separate it, so we get that pretty cheaply. That string is left on the pipeline and output is implicit.

Python 3, 62 60 49 bytes

-5 bytes thanks to Jo King.
-8 bytes thanks to pLOPeGG.

After these improvements, this answer is now similar to Jonathan Allan's answer.

print(*[ord(c)%32for c in input()if c.isalpha()])

Try it online!

Charcoal, 21 bytes

≔⁺β⭆χιβF↧S¿№βι«I⊕⌕βι→

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

≔⁺β⭆χιβ

Append the digits to the predefined lowercase letters variable.

F↧S

Loop over the lowercased input.

¿№βι«

If the current character is a letter or digit,

I⊕⌕βι

print its 1-indexed index,

and leave a space for the next value.

Python 2, (45?) 55 bytes

11 bytes added to format the output, which also makes this incompatible with Python 3)

lambda s:' '.join(`ord(c)%32`for c in s if c.isalpha())

Another port of my Jelly answer.

Try it online!


Non-formatted version (returning a list of integers):

lambda s:[ord(c)%32for c in s if c.isalpha()]

Japt v2.0a0 -S, 12 10 bytes

r\L ¨c uH

Try it


Explanation

r              :Remove
 \L            :  Non-letter characters
    ¬          :Split to array
     ®         :Map
      c        :  Character code
        u      :  Modulo
         H     :  32
               :Implicitly join with spaces and output

Jelly, (7?) 8 bytes

Rightmost byte is output formatting

fØẠO%32K

A full program accepting a string in Python format which prints the result to STDOUT

Try it online!

How?

fØẠO%32K - Main Link: list of characters (created from the string input)
 ØẠ      - yield the alphabet = ['A','B',...,'Z','a','b',...,'z']
f        - filter keep (discard non alphabet characters)
   O     - ordinals          ('A':65, 'Z':90, 'a':97, 'z':122, etc.)
     32  - literal thirty-two
    %    - modulo            (65:1,   90':26,  97:1,  122:26,  etc.)
       K - join with spaces (makes a list of characters and integers)
         - implicit print

05AB1E, (5?) 7 bytes

Rightmost two bytes are output formatting

áÇ32%ðý

A port of my Jelly answer, but O5AB1E is more terse for the alphabet filtering.

Try it online!

How?

áÇ32%ðý - take input implicitly
á       - filter keep alphabetical characters
 Ç      - to ordinals
  32    - thirty-two
    %   - modulo (vectorises)
     ð  - push a space character
      ý - join

05AB1E, 14 bytes

Handles numbers as well

žKÃlvžKlÙyk>ðJ

Try it online!

Python 2, 110 bytes 104 bytes, with user input

a="abcdefghijklmnopqrstuvwxyz";print" ".join(str(a.index(l)+1)for l in list(input().lower())if l in a)

Try it Online!


Python 2, 105 bytes 104 bytes 96 bytes, where t is predefined:

a="abcdefghijklmnopqrstuvwxyz";print" ".join(str(a.index(l)+1)for l in list(t.lower())if l in a)

Try it Online!

Let's break it down with a more readable version:

alphabet = "abcdefghijklmnopqrstuvwxyz"
foo = [str(alphabet.index(letter) + 1) for letter in list(t.lower()) if letter in alphabet]
print " ".join(foo)

First, we define alphabet as being, well, the alphabet.

Next, we use list comprehension to:

  1. Make a list where each item is a lowercase character from t
  2. For each letter, if it is not in the alphabet, discard it.
  3. If it is, find its index in the alphabet,
  4. add one to it (because we start counting at 1)
  5. and make it a string.

Finally, we join it all together and print it.


Edit: Changed to print (and lost portability) to save bytes and make it work outside a function

Edit 2: Added a version with input() instead of predefined variables

Edit 3: Removed 8 bytes in Solutions 1 and 2 thanks to Jo King

05AB1E, 8 bytes

láÇ96-ðý

Try it online!

or, if we can return an array:

05AB1E, 6 bytes

láÇ96-

Explanation:

l         Lowercase
 á        Only letters
  Ç       Codepoints
   96-    Subtract 96.

Try it online!

or if you want it to count numbers:

05AB1E, 13 bytes

lAžh«DŠÃSk>ðý

Try it online!

Python 3, 84 bytes

print(*filter(int,['abcdefghijklmnopqrstuvwxyz'.find(c)+1for c in input().lower()]))

Try it online!