Mutual recursion - Naming the opponent serve - pingpong
From the problem statement:

Implement a function pingpong that returns the nth element of the
ping-pong sequence without using any assignment statements.
You may use the function num_sevens, which you defined in the previous
question.
Use recursion - the tests will fail if you use any assignment
statements.
Hint: If you're stuck, first try implementing pingpong using
assignment statements and a while statement. Then, to convert this
into a recursive solution, write a helper function that has a
parameter for each variable that changes values in the body of the
while loop.


Code should be correct, maintainable, robust, reasonably efficient, and, most importantly, readable.

Your first solution makes far too much of a simple switch in the increment value with duplicated functions differing merely in the literal integer values 1 and -1. It requires a diff comparison to find the small, obscure differences between the largely duplicate player1 and player2 functions. Duplication of code hurts maintainability. The solution introduces an obscure player abstraction which is not part of the problem statement. It is not readable. Also, the solution uses multiple assignment statements for the player function variables: &quot;the tests will fail if you use any assignment statements.&quot;

While the problem statement did say you may use num_sevens, this problem asks &quot;if k contains the digit 7&quot;. To count all occurences of digit 7 when we only care about the first occurence is inefficient.

Your second solution, &quot;code written without using mutual recursion&quot;, which you added later, is clearly incorrect. It uses multiple assignment statements: &quot;the tests will fail if you use any assignment statements.&quot; For no apparent reason, you use the name toogle instead of switch and you complicate things by introducing a toggleValue variable.
toggleValue := 1 ^ -1
increment := 1
. . .
        increment ^= toggleValue

The toggleValue variable is unnecessary and the toggle algorithm is obscure. Simplicity is a virtue.
increment := 1
. . .
        increment *= -1 // switch


The Problem Statement is an academic problem designed to discover if you have learned some fundamental programming concepts: recursion and no assignment statements. The Hint gives a detailed road-map to a solution. You did not answer the problem as stated so you get an F.

Here is an example of the sort of solution that the problem statement likely expected:

Use recursion. First try implementing pingpong using assignment
statements and a while statement. Then, to convert this into a
recursive solution, write a helper function that has a parameter for
each variable that changes values in the body of the while loop.

package main

import &quot;fmt&quot;

func digitSeven(x int) bool {
    if x &lt;= 0 {
        return false
    }
    if x%10 == 7 {
        return true
    }
    return digitSeven(x / 10)
}

func increment(incr int, x int) int {
    if x%7 == 0 || digitSeven(x) {
        return incr * -1
    }
    return incr
}

func pingpong(n int, i int, v int, incr int) int {
    if i &gt; n {
        return v
    }
    return pingpong(n, i+1, v+incr, increment(incr, i))
}

func PingPong(n int) int {
    return pingpong(n, 1, 0, 1)
}

func main() {
    for n := 1; n &lt;= 30; n++ {
        fmt.Println(n, PingPong(n))
    }
}

Playground: https://play.golang.org/p/8H6l-CpLlye
Output:
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 6
9 5
10 4
11 3
12 2
13 1
14 0
15 1
16 2
17 3
18 2
19 1
20 0
21 -1
22 0
23 1
24 2
25 3
26 4
27 5
28 4
29 5
30 6