Skip to content

Instantly share code, notes, and snippets.

@Plancke
Created July 28, 2018 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Plancke/3719cc230fe24d6b43cb0ed66cfc768e to your computer and use it in GitHub Desktop.
Save Plancke/3719cc230fe24d6b43cb0ed66cfc768e to your computer and use it in GitHub Desktop.
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