Odd prime numbers are either in the form of 4k+1
or 4k+3
where k
is a non-negative integer. If we divide the set of odd prime numbers into two such groups like this:
4k+3 | 3 7 11 19 23 31 43 47 59 67 71
|
4k+1 | 5 13 17 29 37 41 53 61 73
we can see that the two groups are kind of racing with each other. Sometimes the so-called 'upper' group wins and sometimes the 'lower' one is on track. In fact, Chebyshev discovered that in this race, the upper group wins slightly more often.
The problem
Let's assume that we are interested in knowing the shape of this race track up to a certain number. Something like this:
The upper and lower horizontal lines indicate that the next prime stays in the same group, while the slanted lines indicate a 'jump' from one group to the other.
Now assume that the underline character _
represents a lower horizontal line and the overline character ‾
(U+203E) represents an upper one. The slanted lines are represented by slash /
or backslash \
characters.
Challenge
Write a program or function that gets a number N
as input, and draws this prime race track up to N
, in a kind of ASCII-art-form described as above (Well, it's not an actual ASCII-art since it would contain a non-ASCII character).
Rules
N
is an integer and not necessarily a prime number. Draw the race path for the primes up to, (and maybe including)N
.- For a valid
N
as input, the output shall only be composed of these four characters‾_/\
. No other character, space or separator is allowed (except maybe at the end of output). - The output can either be in a text file or stdout or wherever supports displaying those characters. But an actual plot (like the blue figure above) is not desired.
- This is code-golf, so the shortest code in bytes wins.
Examples
Here is a list of possible inputs and their acceptable outputs.
N < 5 no output or maybe an error message whatsoever
N = 5 \
N = 20 \/‾\_/
N = 100 \/‾\_/‾\/\_/‾\/\/‾\/‾\_
Trivia
The resulting plots of this challenge may actually resemble the derivative of the plots shown in there.
‾
by-
? \$\endgroup\$-
is uglier than‾
in this context. But to me it's even worse to require a non-ASCII character, especially for ASCII-art \$\endgroup\$-
or~
instead of‾
. Here another challenge using those same characters where the same is done. The main reason to allow this is to open up the challenge to more languages, because there are quite a few languages that can't even use non-ASCII characters, so they would be unable to complete just because of that single character in an otherwise good challenge. \$\endgroup\$