repl.it
@anonymous/

HarmoniousHummingNuthatch

Ruby

No description

fork
loading
Files
  • main.rb
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
f=->w,i{(%w"lo gli la le l' gli l' le il i la le"[(0..2).find{|r|[/^(i[aeiou]|s[^aeiou]|z|x|[gp]n|ps)/i,/^[aeiou]/,//][r]=~w}*4+i]+' '+w).sub"' ",?'}

[
"macchina f s",
"zio m s",
"libri m p",
"ieri m s",
"aquile f p",
"spagnoli m p",
"golf m s",
"ombra f s",
"impossibili m p"
].each {|s|
	w, g, n = s.split
	i = 2 * (g<?g?1:0) + (n<?r?1:0)
	puts f.call(w,i)
}
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
?