Numbers which are not the sum of distinct squares: Difference between revisions
Numbers which are not the sum of distinct squares (view source)
Revision as of 22:15, 23 November 2021
, 2 years ago→{{header|Raku}}: more concise
Thundergnat (talk | contribs) m (more white space tweaks) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: more concise) |
||
Line 35:
=={{header|Raku}}==
[https://tio.run/##jVA7TsMwGN5zik9qhpSHpS4MjVKxcgZEKwN/wJLjJH4gqih7uQSHYGXrUXqRYNfUZSSDpfh7uyMtb6ap2eLW9I5rMqiwPuw@wRreLXGx/yoxw52qhRKWYEgLz2lr/NKzrG41FowFzfUKuekxIH0zBJjeSG/x1DaPQnErWhUMuJTJJFCPHVwTCpy63K@93QP7IzT7b@ZJzCnRO2Km1bZMau1U/AmZ0WvITk0CyjpnXot8MwdXz1D0buGUJGMiSpIaUyaFqJFvUFURtFxIXGLh1yWrZSCMIGnIX0tubBCdvbA6TwlLyiPmBxZzjMeceHbO4kVTh8H7HXYfsfx4hcI/bEqPrf@Rko3T9AM Try it online!]
'''Spoiler:''' ''(highlight to read)''<br>
Line 46:
for @sums {
@run.push($_) and next unless @run.elems;
if $_ == @run.tail + 1 { @run.push: $_ } else { last if @run.elems > @squares[$sq]; @run = ()
}
put grep {$_ ∉ @sums}, (1..@run.tail) and last if @run.elems > @squares[$sq];
|