Numbers which are not the sum of distinct squares: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (more white space tweaks) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: more concise) |
||
Line 35: | Line 35: | ||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
[https://tio.run/##jVA7TsMwGN5zik9qhpSHpS4MjVKxcgZEKwN/wJLjJH4gqih7uQSHYGXrUXqRYNfUZSSDpfh7uyMtb6ap2eLW9I5rMqiwPuw@wRreLXGx/yoxw52qhRKWYEgLz2lr/NKzrG41FowFzfUKuekxIH0zBJjeSG/x1DaPQnErWhUMuJTJJFCPHVwTCpy63K@93QP7IzT7b@ZJzCnRO2Km1bZMau1U/AmZ0WvITk0CyjpnXot8MwdXz1D0buGUJGMiSpIaUyaFqJFvUFURtFxIXGLh1yWrZSCMIGnIX0tubBCdvbA6TwlLyiPmBxZzjMeceHbO4kVTh8H7HXYfsfx4hcI/bEqPrf@Rko3T9AM Try it online!] |
|||
[https://tio.run/##jZA9TsQwEIX7nOIVKcKfpW0oNsqKeyB2ZWAWItmO47ElUJR@uQSHoKXbo@xFgo0hoWQ6z5v3vRlbcup6mvQrbrgP0hGjwfZ0eIfQ0q5xfvyoi2LfOayESO2rDUruMRSI9W0LOnl@7bfbKN@Jh07ft0b6tjN8/BRxSATT9oEEd87Xs9sFkx8pIrMyOlVShQ38XJW7M0jzCEMvHsEoYs4qKdJcz452j3KHpsmil63CBVYYFtQ6DYwgxfTTjstXf@jjDFOSfSIuQdgsd6Yzc3B22ODx5MhiiAGnw1u@ZrxEFX9uXicH/Yc8TtMX Try it online!] |
|||
'''Spoiler:''' ''(highlight to read)''<br> |
'''Spoiler:''' ''(highlight to read)''<br> |
||
Line 46: | Line 46: | ||
for @sums { |
for @sums { |
||
@run.push($_) and next unless @run.elems; |
@run.push($_) and next unless @run.elems; |
||
if $_ == @run.tail + 1 { @run.push: $_ } else { @run = () |
if $_ == @run.tail + 1 { @run.push: $_ } else { last if @run.elems > @squares[$sq]; @run = () } |
||
last if @run.elems > @squares[$sq]; |
|||
} |
} |
||
put grep {$_ ∉ @sums}, (1..@run.tail) and last if @run.elems > @squares[$sq]; |
put grep {$_ ∉ @sums}, (1..@run.tail) and last if @run.elems > @squares[$sq]; |