# Tell me how many there are, in Polish

Today, you're going to be writing Polish. No, not Polish notation—Polish, the actual language spoken in Poland.

Given a number and a noun, output a Polish sentence telling me that there are that many of that thing, using the appropriate template below.

The input consists of an integer in the range from 0 to 200, and a string of 1 to 10 lowercase ASCII letters (the "input noun"). You may accept these inputs in any reasonable format.

The output must consist of one of the below output templates, where the number in the template (if any) has been replaced with the input integer, and the word kot in the template has been replaced with the input noun.

## Output templates

If the input number is 0, then use the output template

Nie ma żadnych kotów.


If the input number is 1, then use the output template

Jest 1 kot.


If the input number ends with 2, 3, or 4, but does not end with 12, 13, or 14, then use the output template

Są 4 koty.


In any other case, use the output template

Jest 8 kotów.


Note that the special characters used in these templates are:

• ż (in "żadnych") – U+017C Latin small letter Z with dot above (&zdot;)
• ó (in the suffix "-ów") – U+00F3 Latin small letter O with acute (&oacute;)
• ą (in "Są") – U+0105 Latin small letter A with ogonek (&aogon;)

You may output these characters in any reasonably common character encoding (including HTML entities), and you may use combining characters instead of precomposed characters (or even a mixture of the two).

Note that in ISO-8859-2, all ASCII characters as well as the three special characters above are represented with one byte. Therefore, if your program uses no non-ASCII characters besides these three, then you can count each of these three characters as one byte.

## Test cases

0 pomidor -> Nie ma żadnych pomidorów.
1 kwiat -> Jest 1 kwiat.
2 dom -> Są 2 domy.
5 wilk -> Jest 5 wilków.
13 komputer -> Jest 13 komputerów.
24 but -> Są 24 buty.
101 kurczak -> Jest 101 kurczaków.
104 wieloryb -> Są 104 wieloryby.
112 post -> Jest 112 postów.
122 balon -> Są 122 balony.


## Do plurals in Polish really work that way?

No, plurals in Polish are actually a lot more complicated than this.

This is , so the shortest program in each language wins.

• how much more complicated is real Polish?en.wikibooks.org/wiki/Polish/Nouns_-_Number Jun 9 at 13:40
• @AgnishomChattopadhyay That page only describes how to form the nominative plural form of a word. Polish has 6 other cases that all have different ways of forming plurals. There's also the question of when the nominative plural is needed and when the genitive plural is needed, and whether the resulting phrase is treated as singular or plural. This challenge touches on all of that, but only for masculine nouns that form the nominative plural with -y and the genitive plural with -ów. Jun 9 at 14:36
• Specifically, the requirement is only for processing masculine inanimate ("non-virile") nouns. Imagine the complexity otherwise! Jun 9 at 19:50

# Retina 0.8.2, 88 bytes

.+
Jest $&ów. Jest 0 Nie ma żadnych ( 1 .+)...$1.
Jest (.*(?<!1)[2-4] .+)...
Są $1y.  Try it online! Link includes test cases. Explanation: .+ Jest$&ów.


Assume none of the special cases apply.

Jest 0


Fix up if the input was 0.

( 1 .+)...
$1.  Fix up if the input was 1. Jest (.*(?<!1)[2-4] .+)... Są$1y.


Fix up for the 2-4 but not 12-14 endings.

• Impressive! Looks like you're counting ó, ż, and ą as two bytes each, right? Since those are all one byte in ISO-8859-2, I don't see any problem with saying that your program is written in ISO-8859-2 and then counting those as one byte each. See the note about ISO-8859-2 that I just added. Jun 9 at 1:52
• @TannerSwett Thanks for letting me know, although I won't bother updating my answer just for that change.
– Neil
Jun 9 at 6:18

# 05AB1E, 10592 89 bytes

-16 thanks to Kevin Cruijssen.

„ówU’Jî• ’V>iXIŽ1}ç’NíÓ íà ÿ‹¤½Áh ÿÿ’ë¹iY…ÿ1 ìë¹Ƶ…S©Å¿O¹®T+Å¿O_*i¹Ƶ¡ç"Sÿ ÿ ÿy"ëY¹ðIXJ]„ÿ.


Try it online! Takes input separated by a newline.

• "ÿ1 ÿ" can be …ÿ1 ì for -1; Ƶ…ε¹sÅ¿}O12 14Ÿε¹sÅ¿} can be ¹Ƶ…S©Å¿O¹®T+Å¿ for -7; and Xs¹Y"ÿÿ ÿÿ" can be Y¹ðIXJ for -5: 92 bytes Jun 9 at 8:28
• ƵŽç„ÿw can be „ów for another -3. ó is part of 05AB1E's codepage, unlike the other two characters ż and ą. Although it does seem to be unbound and not used by any builtin apparently... That's actually pretty interesting. TIL. :) Jun 10 at 9:18

# Factor, 160 bytes

[| n s | n s t n 0 = n 1 = n present R/ .*(?<!1)[234]/ matches? 3array index ?1+
{ "Jest %d %sów.""Nie ma żadnych %sów.""Jest %d %s.""Są %d %sy."} nth sprintf ]


Attempt This Online!

### How?

                   ! n = 122, s = "balon"
n                  ! 122
s                  ! 122 "balon"
t                  ! 122 "balon" t
n                  ! 122 "balon" t 122
0                  ! 122 "balon" t 122 0
=                  ! 122 "balon" t f
n                  ! 122 "balon" t f 122
1                  ! 122 "balon" t f 122 1
=                  ! 122 "balon" t f f
n                  ! 122 "balon" t f f 122
present            ! 122 "balon" t f f "122"
R/ .*(?<!1)[234]/  ! 122 "balon" t f f "122" R/ .*(?<!1)[234]/
matches?           ! 122 "balon" t f f t
3array             ! 122 "balon" t { f f t }
index              ! 122 "balon" 2
?1+                ! 122 "balon" 3
{ ... }            ! 122 "balon" 3 { ... }
nth                ! 122 "balon" "Są %d %sy."
sprintf            ! "Są 122 balony."


# Python 3, 109 106 bytes

lambda n,s:[['Nie ma żadnych ','Jest %s '%n][n>0]+s+'ów'*(n!=1),f'Są {n} {s}y'][n//10%10!=1<n%10<5]+'.'


Try it online!

• Your score is actually only 103, because the question allows you to count the non-ASCII characters as 1 byte Jun 9 at 12:33

# Python, 138123 111 bytes

lambda n,s:("Nie ma żadnych ",("Jest","Są")[(z:=n//10%10!=1<n%10<5)]+f' {n} ')[n>0]+s+(n!=1)*"óyw"[z::2]+'.'


Attempt This Online!

• Your score is actually only 108, because the question allows you to count the non-ASCII characters as 1 byte Jun 9 at 12:33

# Vyxal, 74 bytes

J½Ḣ Π Π.¹ċ[Ṫ£234¹tc¹Ṫtċ∧[⁺żCSΠ Π Πy.|⁺ċC¹[¥ΠΠw.|⁰Nie ma \ż…ṅƒ꘍ ΠΠw.


Try it Online!

## How?

J½Ḣ Π Π.¹ċ[Ṫ£234¹tc¹Ṫtċ∧[⁺żCSΠ Π Πy.|⁺ċC¹[¥ΠΠw.|⁰Nie ma \ż…ṅƒ꘍ ΠΠw.
J½Ḣ Π Π.                   # Push string "Jest {implicit first input} {implicit second input}."
¹ċ                 # Is the first input not one?
[                #  If so:
Ṫ               #   Remove the last character (the period) from the string
£              #   Pop and put it in the register.
234¹tc        #    Is the last digit of the first input one of 2, 3, 4?...
¹Ṫtċ∧   #    ...and is the second last digit of the first input not one?
[                            #     If so:
⁺żC                         #      Push "ą"
SΠ Π Πy.               #      Push string "S{'ą'} {implicit first input} {implicit second input}y." (which is implicitly output)
|              #     Otherwise:
⁺ċC           #      Push "ó"
¹          #      Is the first input truthy? (not zero)
[         #       If so:
¥ΠΠw.  #        Push string "{register}{'ó'}w." (which is implicitly output)
|                            #       Otherwise (the input is zero):
⁰Nie ma \ż…ṅƒ꘍ ΠΠw.        #         Push string "Nie ma żadnych {second input}{'ó'}w." (which is implicitly output)
# All strings and if statements implicitly closed.
# If the first if statement was falsy (aka the input was one), then the string pushed at the beginning will be implicitly output.


# Perl 5 + -pl056, 79 bytes in ISO-8859-2

/ /;$_=/(?<!1)[234] /?"Są${_}y":$?"Jest$_"."ów"x($>1):"Nie ma żadnych$'ów"


Try it online!

## Explanation

Match space with / / which stores the number in prematch ($ ) and the noun in postmatch ($'). Next $_ (which is automatically output, thanks to -p) is set to "Są${_}y" (where $_ is the implicit input from the implicit -n via -p) if it matches the regex /(?<!1)[234] / (number ends [234] but not 1[234]), otherwise if $  is not 0 it's set to "Jest $_"."ów"x($>1), where the "ów"suffix is added if$'is greater than1, otherwise, finally for the 0case it's set to"Nie ma żadnych$'ów".

Thanks to @Xcali for saving 9 bytes!

• Nice trick with the -056 option. Here's a little shorter way: Try it online! Jun 13 at 6:18
• Thanks @Xcali! Not an insignificant saving either! Jun 13 at 8:17

# JavaScript (ES6), 113 bytes*

* counting each special letter as 1 byte, as allowed by the challenge

Expects (integer)(word).

n=>w=>[Jest,Są,Nie ma żadnych][i=n<2?n+2:28>>n%10&n*9%98%9!=1,i%3]+ ${n?n+' '+w:w}${[[,'y','ów'][i||2]]}.


Try it online!

### How?

To test whether $$\n\$$ ends with $$\2\$$, $$\3\$$ or $$\4\$$ and does not end with $$\12\$$, $$\13\$$ or $$\14\$$, we use the expression:

28>>n%10&n*9%98%9!=1   // 20 bytes


Explanation:

28                     // the bitmask 0b0000011100
>> n % 10              // right-shifted by n mod 10
&                      //
n * 9 % 98 % 9 != 1    // this is false for 12, 13, 14, 112, 113, 114
// and true for other values ending with 2, 3, 4
// (for anything else, it doesn't matter)


This is somewhat convoluted but shorter than using a test with a regular expression (which would also require ES9+ for the negative lookbehind assertion):

/(?<!1)[234]\$/.test(n) // 22 bytes


Try it online!

# Charcoal, 73 bytes

≡θ0«Nie ma żadnych ηów»¿›№234§θ±¹⁼1§θ±²«Są θ ηy»«Jest θ η¿⁻1θów».


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

≡θ0«Nie ma żadnych ηów»


If the first input (θ) is 0, then print Nie ma żadnych ηów, where η is the second input.

¿›№234§θ±¹⁼1§θ±²«Są θ ηy»


If it ends in 2, 3 or 4 but not 12, 13 or 14, then print Są θ ηy.

«Jest θ η¿⁻1θów»


Otherwise print Jest θ η, and then print ów if the first input is not 1.

.


Print the final ..

Note that the deverbosifier thinks that ó doesn't need to be encoded but it actually takes three bytes to encode. (It calculates the byte count correctly for ż and ą.)

• Nice! What character encoding is this submission using? It looks like this is 102 bytes in UTF-8, and you're using characters that are outside of ISO-8859-2. Jun 10 at 12:03
• @TannerSwett Charcoal has its own code page, which you can find on its GitHub wiki. It can represent characters not in its code page but this costs at least 3 bytes each time.
– Neil
Jun 10 at 12:29

# APL(Dyalog Unicode), 105 bytes SBCS

{⍺=0:∊'Nie ma żadnych '⍵'ów.'⋄⍺=1:∊'Jest 1 '⍵⋄1 0≡(2 3 4∘+¨0 10)∨/⍤∊¨10 100|⍺:∊'Są'⍺⍵'y.'⋄∊'Jest'⍺⍵'ów.'}


Try it on APLgolf!

Ironic.