Created
July 28, 2018 02:23
-
-
Save Plancke/3719cc230fe24d6b43cb0ed66cfc768e 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
import org.joda.time.Duration; | |
import org.joda.time.PeriodType; | |
public class ChallengeOscillation { | |
private static final String[] ROTOR_DAYS = new String[]{"a", "b","c", "d", "e", "f", "g", "h", "i", "j", "k", "l"}; | |
private static final long EPOCH = 1444536000000L; | |
public static String getOscillation(long time, int offset) { | |
int days = new Duration(EPOCH, time).toPeriod().normalizedStandard(PeriodType.days()).getDays(); | |
return ROTOR_DAYS[(days - offset) % ROTOR_DAYS.length]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment