Last active
January 9, 2023 19:16
-
-
Save joriki/007117204b8d8d2496d98f9fd9a6634d to your computer and use it in GitHub Desktop.
Search the game tree of a repeat-a-number game; see https://math.stackexchange.com/questions/4605602
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.BitSet; | |
public class Question4605602 { | |
static BitSet used = new BitSet(); | |
public static void main(String [] args) { | |
System.out.println(value(1)); | |
} | |
static boolean value(int move) { | |
if (used.get(move)) | |
return true; | |
used.set(move); | |
boolean losing = value ((int) Math.floor(move / 3)) || value (2 * move + 1) || value (2 * move + 5); | |
used.clear(move); | |
return !losing; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment