Подскажите код который может призвать в программу алфавит кириллицу
Однако буква ё в тот диапазон не входит, поэтому ее нужно будет добавить вручную.
Но самый простой способ – вручную забить:
Дизайн сайта / логотип © 2023 Stack Exchange Inc; пользовательские материалы лицензированы в соответствии с CC BY-SA . rev 2023.9.7.43618
Нажимая «Принять все файлы cookie» вы соглашаетесь, что Stack Exchange может хранить файлы cookie на вашем устройстве и раскрывать информацию в соответствии с нашей Политикой в отношении файлов cookie.
Print the Russian Cyrillic alphabet [duplicate]
Apparently, we really like printing the alphabet in different languages.
How about the Russian Cyrillic alphabet?
Print/output/return this exact text (trailing whitespace is permitted)
This is the Russian Cyrillic alphabet with upper and lower case interleaved (eg AaBbCc. )
This is code-golf so crunch those bytes folks!
![]()
![]()
33 Answers 33
Рапира (Rapira), 172 142 bytes
Just for fun, given the challenge. It may not be golfed; I’m not really familiar with the language.
Mathematica, 43 42 bytes
Alphabet is a built-in function.
-1 byte from Martin.
This may not work on some older versions of Mathematica, but it does work on Wolfram sandbox and Try it online!.
Another version without builtin Alphabet or ToUpperCase :
Mathematica, 82 66 bytes (64 chars)
Unfortunately Martin’s trick (use a<>b instead of ) doesn’t work here.
![]()
Jelly, 18 bytes
A full program. Pretty similar in nature to an existing answer by Erik the Outgolfer, but I think it’s different enough.
![]()
C#, Java, Javascript 137 bytes
Note: Java is only valid if you replace => with ->
Ahhhh. Found a shorter way for
C#, 102 99 bytes
Shortened it by using a different approach
Japt, 75 38 32 24 23 22 bytes
- 1 byte saved thanks to ETHproductions.
Explanation
History
![]()
Jelly, 20 19 bytes
Thanks to Jonathan Allan for posting his answer (even though he outgolfs me) for -1 🙂
![]()
PHP, 68 66
slight improvement over the previous attempt by xoring instead of appending. ڀ^"\n" constructs the necessary "\0xd0\128" and xors in the lower 7 bit.
JavaScript (ES6), 106 bytes
05AB1E, 22 bytes
Explanation
![]()
Pyth, 26 bytes
![]()
05AB1E, 20 bytes = 18 bytes + 2 UTF-8 bytes
Credit to Emigna for the lowercase trick and for 3° isntead of 3Tm .
Alternate 20 byte version (no UTF-8): T„(GÇŸ„.Ç6ǝ˜«çJDløJ
Even more random 20 byte nonsense: T„(GÇŸ„.Ç6ǝ˜«vyçDlJ
(The key takeaway is that I don’t think I’m getting below 20 here).
![]()
Braingolf, 58 bytes
Explanation
Adds Ϗ (975) to each character in ABCDEF2GHIJKLMNOPQRSTUVWXYZ[\]^_` Then duplicates and adds space (32), unless the character is Ё , in which case it adds P (80)
![]()
Java, 93 bytes
Source file should be saved in Windows-1251 encoding so the source makes for 71 bytes, plus flag to compiler -encoding WINDOWS-1251 for 22 bytes more.
Python 3, 69 66 bytes
-3 bytes using the form (using ‘%c’ to directly apply chr() ) from totallyhuman’s answer, do go give some credit!
A full program (two double-byte characters used, Ё and ё ).
![]()
Dyalog APL, 55 47 bytes
8 bytes saved thanks to @Zacharý
![]()
Pyth, 71 bytes
![]()
05AB1E, 64 47 46 bytes
C# (.NET Core), 94 93 90 bytes
![]()
Python 3, 96 92 bytes
@Mayube suggested this to save 2 bytes, and succeeded to golf it down by 1 byte by declaring chr(i) .
@Rod golfed 4 bytes by removing chr(i) .
Python 3, 104 99 bytes
Any suggestions are welcome.
![]()
05AB1E, 29 bytes
Uses the lowercase / uppercase trick from the python answer
Explanation
Python 3, 66 bytes
PHP>=7.0, 77 Bytes
PHP, 136 Bytes
PHP, 136 bytes
![]()
Bash+coreutils, 101 100 93 92 74 bytes
This requires a UTF-8 locale such as ru_RU.utf8 (English UTF-8 locales also sort correctly). I’ve not added any score for this, as per the consensus on meta.
![]()
Ruby, 60 bytes
(Just a demonstration of String#next! , the multibyte literals ruin the 55 characters score.)
Ruby, 59 56 55 54 51 bytes
Thanks to manatwork for at least 4 bytes.
![]()
Japt, 26 24 bytes
22 bytes of code (encoded in UTF-8), +2 for the -P flag.
Similar to the below method, except instead of pairing two arrays, I join each capital letter with itself, lower-cased.
26 byte solution:
I had some help from @Shaggy, who discovered that Ё wasn’t in the [1040. 1071] char range.
Explanation:
Charcoal, 45 44 26 bytes
Try it online! Link is to verbose version of code. Explanation:
Take the first 72 printable ASCII characters, reverse them, then take the first 32 of those (this is actually shorter than slicing and reversing, although slicing didn’t exist at original time of posting anyway), then insert the i after the N , then reverse again. The resulting characters happen to have ASCII codes that are exactly 1000 less than the desired Russian lower case letters.
Calculate the Russian lower case letter by adding the predefined variable φ ( f ) which has the value 1000.
Print the upper and lower case letters. ( «↥ιι would probably also work.)
Генерация списка букв алфавита в Python
Часто в программировании на Python возникает необходимость создания списка, состоящего из букв алфавита. Например, при решении задачи о шифровании текста или при обработке данных, где необходимо работать с алфавитными индексами.
Простой и не очень эффективный способ создать такой список — вручную перечислить все буквы в списке:
Однако, этот способ неудобен, особенно если необходимо создать список для большого количества символов. Кроме того, он подвержен ошибкам, так как легко пропустить или неправильно ввести одну из букв.
Существует более эффективный способ создания списка букв алфавита с использованием встроенной функции chr() .
Функция chr() в Python возвращает строку, представляющую символ, который представляет собой юникод-код указанного целого числа. Например, chr(97) возвращает строку ‘a’.
В ASCII (стандартной системе кодирования символов), буквы английского алфавита имеют коды от 97 до 122 для строчных букв и от 65 до 90 для прописных. Зная это, можно легко сгенерировать список букв алфавита следующим образом:
В данном коде используется list comprehension, которое позволяет сгенерировать список в одну строку. Внутри квадратных скобок указывается выражение, которое генерирует элементы списка. В данном случае chr(i) преобразует целое число i в соответствующую букву алфавита. for i in range(97, 123) генерирует последовательность чисел от 97 до 122 включительно.
Таким образом, с помощью функции chr() и цикла for можно легко сгенерировать список букв алфавита в Python.
Python | Ways to initialize list with alphabets
While working with Python lists, sometimes we wish to initialize the list with the English alphabet a-z or A-Z. This is an essential utility in competitive programming and also in certain applications. Let’s discuss various methods to achieve this using Python.
Initialize the list with alphabets using string.ascii_uppercase
The most pythonic and latest way to perform this particular task. Using this new inbuilt function will internally handle the coding part providing a useful shorthand for the user.
Note: You can use lowercase instead of uppercase to generate lower alphabets.