Created
June 3, 2020 14:23
-
-
Save olegchir/fecf2c551797b36a60d50691e0a4c2f4 to your computer and use it in GitHub Desktop.
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
package com.olegchir.jlt; | |
import java.util.concurrent.atomic.AtomicReference; | |
public class Main { | |
static AtomicReference<String> haystack = new AtomicReference<>("8".repeat(184)); | |
public static void main(String[] args) { | |
while ( find("222") || find("888") ) { | |
if ( find("222") ) { | |
replace("222", "8"); | |
} else { | |
replace("888", "2"); | |
} | |
} | |
System.out.println(haystack.get()); | |
} | |
private static boolean find(String needle) { | |
return haystack.get().contains(needle); | |
} | |
private static void replace(String old, String modern) { | |
haystack.set(haystack.get().replace(old, modern)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment