Write a program to print or return one of these strings verbatim:
abcdefghijkmnopqrstuvwxyz ABCDEFGHIJKMNOPQRSTUVWXYZ Notice that there is no L.
Write a program to print or return one of these strings verbatim:
abcdefghijkmnopqrstuvwxyz ABCDEFGHIJKMNOPQRSTUVWXYZ Notice that there is no L.
+++++++++++++[->+>+++++>+<<<]>--[->.+<]>>+[-<+.>] Starting with a cell containing 13 we set up 3 cells containing 13,65,13. The 65 is the ASCII code of the letter to be printed and the other cells are down-counters (which are adjusted to 11 and 14 before use.) A nice feature is that the loop for printing the first 11 letters increments the ASCII code after printing and the loop printing the last 14 letters increments the ASCII code before printing, thereby skipping L naturally.
⁻βl Try it online! Link is to verbose version of code. Explanation: β is a Charcoal variable predefined to the lowercase alphabet.
⁻αL Try it online! Link is to verbose version of code. Explanation: α is a Charcoal variable predefined to the uppercase alphabet.
Anonymous function that takes no inputs and outputs the string with uppercase letters.
@()['A':'K' 77:90] The code concatenates the two ranges of letters: before and after the 'L'. The second range is defined numerically to save two bytes. This can be done because concatenating chars and numbers implicitly converts each number to the char with the corresponding codepoint.
printf %s {a..k} {m..z} echo {a..z}|tr -d \ l !Map(cat,letters[-12]) Exits with an error; credit to ovs.
x=Map(cat,letters[-12]) Also credit to ovs.
cat(letters[-12],sep="") x=Map(cat,letters[-12]) saves one I think. Could also think about exiting with error with !Map... \$\endgroup\$ 26*# Y`#`l l Try it online! Outputs in lowercase but if the program is uppercased then it will output in uppercase instead. Explanation:
26*# Insert 26 #s. (I can't use the default _ because that's a special transliteration character.)
Y`#`l Translate each # in turn into the next character of the alphabet. (It's possible to skip the l here but it's longer overall.)
l Remove the l.
The best I could do in Retina 0.8.2 without resorting to 26-byte hard-coding was 27 bytes, but with some inspiration from @FryAmTheEggman I got it down to 16 15 bytes:
T`l`_l }`$ z l Try it online! Outputs in lowercase but if the program is uppercased then it will output in uppercase instead. Explanation:
T`l`_l Move all of the letters so far one step backwards in the alphabet, but delete any a.
$ z Append a z to the current string.
}` Repeat the above until the transformation becomes idempotent. This happens when the string is the entire alphabet; the a is deleted, the b-z get transliterated into a-y, and another z is appended.
l Remove the l.
print(25*"%c"%(*{*range(65,91)}-{76},)) Only 5 bytes longer than hardcoding the entire thing ...
Unlike dictionaries, sets are in general not guaranteed to preserve insertion order, so why does this work?
C-Python implementation detail: (small) integers are their own hash values.
abcdefghijkmnopqrstuvwxyz or
ABCDEFGHIJKMNOPQRSTUVWXYZ In many languages, the shortest solution is also the least interesting.
n'l- First Vyxal answer, so I’m sure there may be a more concise way, but I like that it almost reads ‘no el’!
-join$('a'..'k';'m'..'z') I think solving that with 25 bytes has a certain je ne sais quoi.
Only works in PowerShell Core, Windows PowerShell can't enumerate characters.
'abcdefghijkmnopqrstuvwxyz' The boring/trivial solution with 27, which would end up as National Fruitcake Day. Somewhat related to CodeGolf, as golfed code and fruitcake have a similar density.
-join([char[]]$(65..75;77..90)) So here's New Year's Eve.
Which is what we also get from the trivial solution in Batch:
@echo abcdefghijkmnopqrstuvwxyz B0 E6 04 5B AA 2C 4B 3C 01 14 F1 75 F5 AA C3 Following the standard calling convention for Unix-like systems (from the System V AMD64 ABI), this takes in RDI a memory address at which to place the result, as a null-terminated byte string.
In assembly:
f: mov al, -26 # Set AL to -26. r: add al, 'Z'+1 # Add this value to AL to produce a letter. stosb # Write AL to the output string, advancing the pointer. sub al, 'K' # Subtract 'K' from AL. cmp al, 1 # Set flags from calculating AL - 1. CF is 1 iff AL is 0. adc al, 'K'-'Z' # Add (this value + CF) to AL. The net change is +1 or +2. jnz r # If the result is nonzero, repeat the loop. stosb # Write AL (0) to the output string, advancing the pointer. ret # Return. 1. CP-1610 instructions are encoded with 10-bit values (0x000 to 0x3FF), known as DECLEs. Although the Intellivision is also able to work on 16-bit data, programs were really stored in 10-bit ROM back then.
A routine that writes the Christmas alphabet at R4.
The method used here would be more relevant if there were several letters to skip. With just one letter, using SLLC / ADCR only saves a few CPU cycles compared to CMPI / BEQ.
ROMW 10 ; use 10-bit ROM ORG $4800 ; map our code at $4800 4800 02BC 0200 MVII #$200, R4 ; R4 = BACKTAB pointer 4802 0004 0148 000D CALL alpha ; invoke our routine 4805 02BD 0030 MVII #$30, R5 ; R5 = pointer into STIC registers 4807 01C0 CLRR R0 4808 0268 MVO@ R0, R5 ; no horizontal delay 4809 0268 MVO@ R0, R5 ; no vertical delay 480A 0268 MVO@ R0, R5 ; no border extension 480B 0002 EIS ; enable interrupts 480C 0017 DECR R7 ; loop forever ;; our routine alpha PROC 480D 02B8 010F MVII #$010F, R0 ; R0 = letter code, initialized to 'A' 480F 02B9 0010 MVII #$0010, R1 ; R1 = mask used to skip 'L' 4811 0059 @loop SLLC R1 ; left-shift the mask into the carry 4812 002F ADCR R7 ; add the carry to the program counter ; (i.e. skip MVO@ if the carry is set) 4813 0260 MVO@ R0, R4 ; write the letter 4814 02F8 0008 ADDI #8, R0 ; update R0 to the next letter 4816 0378 01D7 CMPI #$01D7, R0 ; compare with 'Z' 4818 0226 0008 BLE @loop ; loop if less than or equal 481A 00AF MOVR R5, R7 ; return ENDP import string as s print(s.ascii_lowercase[:11]+s.ascii_lowercase[12:]) from string import ascii_lowercase as s;print(s[:11]+s[12:]); 58: from string import*;s=ascii_lowercase;print(s[:11]+s[12:]) \$\endgroup\$ from string import*;a=printable;print(a[10:21]+a[22:36]) \$\endgroup\$ from math import*;print(''.join(chr(n+isqrt(3*n//2))for n in range(56,81))) \$\endgroup\$ print(''.join(chr(i+65)for i in range(26)if i-11)) Simple iteration combining range and chr.
-1 byte thank to @UndoneStudios's amazing hint of using str.join
a=*range(65,91), print(*map(chr,a[:11]+a[12:]),sep='') Using tuple destructuring.
print(''.join(chr(i+65)for i in range(26)if i-11)) \$\endgroup\$ Yes, that's 4.5 times the size of the pure input, but don't forget that we have only three symbols, resulting in a factor ~5, compared to the full character set.
The whole christmas alphabet in morse code already takes 102 characters; with the overhead of conversion and printing it would be 124 bytes, so this loop solution is shorter (not counting the christmas tree formatting, which starts beautifully with Entering 65, but doesn't really work out well, because whitespaces are sometimes meaningful in Morsecco):
. -.....- -- - - - -.- - . - .-- . .-..-.-- .- --.. --.- . .---- .- --.. --. . -.--.-- .- --. --.- . -..--.- --. A)Mark to start a loop, Konvert the number to Text and Write it to stdout.Adds –75 (K) and skips after --.- is zero (so the last line handles the L skipping by Entering 77)Z and skips after the --. that closes the loop for the other charactersAdds 91 (–75 + –15 + 91 = 1, so the value is incremented) and Goes to the mark that was set. This saves three bytes compared to saving a copy of the value, dropping the modified version and adding 1 to the copy.Cheating version: 47 bytes
Yes, morsecco ignores all characters except for dot, dash and space, but to cheat, you can Read the source code from the empty address, Cut it after the Z and Output. Yes, such tricks are probably legal when golfing, but boring:
ABCDEFGHIJKMNOPQRSTUVWXYZ. .-. -.-. --..- --- ([*?a..?z]-[?l])*'' Since the task allows simply returning the string instead of printing, I believe it should be acceptable as this snippet. If not, it's +4 for $><< in front.
->{[*?a..?z]-[?l]} \$\endgroup\$ First attempt: 42 bytes
codepoints-to-string(remove(97 to 122,12)) Explanation:
97 to 122 returns the sequence 97, 98, 99, ... 122remove( ..., 12) removes the 12th itemcodepoints-to-string() converts the numbers to a stringThe result of the evaluation is the christmas string. Try it online.
Second attempt 41 bytes, thanks to @Philippos
codepoints-to-string(remove(65 to 90,12)) (upper case letters)
Third attempt (27 bytes), the "trivial" (but so far the shortest) solution (@jonathan-allan)
"abcdefghijkmnopqrstuvwxyz" is a equally valid XPath expression.
codepoints-to-string(remove(65 to 90,12)) \$\endgroup\$ "abcdefghijkmnopqrstuvwxyz" saves bytes if that is truly a full-program or function (I do not know XPath, but it works in the linked interpreter(?)). \$\endgroup\$ filter(/='L')['A'..'Z'] ['A'..'Z'] represents the entire uppercase alphabet, (/='L') is a shorthand for the lambda \x -> x /= 'L'. When both are passed to filter, this keeps all letters from the alphabet that are not L.
Alternatively, this can also be done with an extra byte using list comprehensions:
[x|x<-['A'..'Z'],x/='L'] ['A'..'K']++['M'..'Z'] is shorter by a byte :) \$\endgroup\$ print(''.join(chr(x+x//76)for x in range(65,90))) You could save two bytes by using Python 2, but nobody uses that anymore:
print ''.join(chr(x+x/76)for x in range(65,90)) for. \$\endgroup\$ print isn't needed. \$\endgroup\$ ▽≠@l.+@a⇡26 ▽≠@l.+@a⇡26 ⇡26 # range from 0 to 25 +@a # add letter a . # duplicate ≠@l # where is it not equal to l? ▽ # keep +@a+>10.⇡25 \$\endgroup\$ Count i while 25-i { Write (65+i)*77/76 } Loop i from 0 to 24. Add 65 to convert to uppercase codepoints A through Y; then scale by a linear factor to skip over code point 76 (L). (Division in Acc!! is integer division, but the floating-point version would be \$ 65.86, 66.87, \cdots, 74.97, 75.99, 77.00, 78.01, \cdots, 90.17 \$)
[range(65;91)]-[76]|implode Sample run:
bash-5.2$ jq -nr '[range(65;91)]-[76]|implode' ABCDEFGHIJKMNOPQRSTUVWXYZ Saved 18 bytes thanks to @corvus_192
Golfed version. Try it online!
'A'to'Z'patch(11,"",1)mkString println("abcdefghijkmnopqrstuvwxyz") saves 12 bytes though. \$\endgroup\$ 'A'to'Z'patch(11,"",1)mkString (requires -language:postfixOps) \$\endgroup\$ -1 byte thanks to @DLosc
zRM'l Yea I think that's about as short as it can get, unless someone has some genius strategy.
Turns out I'm not genius enough :P
=sort(replace(join(,char(row(65:90))),12,1,)) ...or:
=sort(join(,char(row(65:89)+(11<row(1:25))))) ...or 46 bytes:
=join(,filter(char(row(65:90)),12<>row(1:26))) These formulas are longer than their output.
abcdefghijkmnopqrstuvwxyz..? \$\endgroup\$