Class SolveRiddle20151222Task
- java.lang.Object
-
- org.apache.tools.ant.ProjectComponent
-
- org.apache.tools.ant.Task
-
- ball.riddler538.ant.taskdefs.AbstractTask
-
- ball.riddler538.ant.taskdefs.AbstractSimulationTask
-
- ball.riddler538.ant.taskdefs.SolveRiddle20151222Task
-
- All Implemented Interfaces:
AnnotatedAntTask,AntTaskLogMethods,AntTaskMixIn,ClasspathDelegateAntTask,ConfigurableAntTask,Cloneable
@AntTask("solve-riddle-2015-12-22") public class SolveRiddle20151222Task extends AbstractSimulationTask
AntTaskto solve How Long Will Your Smartphone Distract You From Family Dinner?You’ve just finished unwrapping your holiday presents. You and your sister got brand-new smartphones, opening them at the same moment. You immediately both start doing important tasks on the Internet, and each task you do takes one to five minutes. (All tasks take exactly one, two, three, four or five minutes, with an equal probability of each). After each task, you have a brief moment of clarity. During these, you remember that you and your sister are supposed to join the rest of the family for dinner and that you promised each other you’d arrive together. You ask if your sister is ready to eat, but if she is still in the middle of a task, she asks for time to finish it. In that case, you now have time to kill, so you start a new task (again, it will take one, two, three, four or five minutes, exactly, with an equal probability of each). If she asks you if it’s time for dinner while you’re still busy, you ask for time to finish up and she starts a new task and so on. From the moment you first open your gifts, how long on average does it take for both of you to be between tasks at the same time so you can finally eat? (You can assume the “moments of clarity” are so brief as to take no measurable time at all.)
Solution uses the Monte Carlo method.<solve-riddle-2015-12-22 classname="String" classpathref="Reference" count="int" description="String" taskname="String"> <classpath .../> </solve-riddle-2015-12-22>
- Author:
- Allen D. Ball
-
-
Field Summary
-
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
-
-
Constructor Summary
Constructors Constructor Description SolveRiddle20151222Task()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()-
Methods inherited from class ball.riddler538.ant.taskdefs.AbstractSimulationTask
asPercent
-
Methods inherited from class ball.riddler538.ant.taskdefs.AbstractTask
init
-
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
-
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ball.util.ant.taskdefs.AnnotatedAntTask
getAntTaskName
-
Methods inherited from interface ball.util.ant.taskdefs.AntTaskLogMethods
log, log, log, log, log, log, log, log, log, log, log
-
Methods inherited from interface ball.util.ant.taskdefs.ClasspathDelegateAntTask
createClasspath, delegate, delegate, getClassForName, getClassLoader, setClassname, setClasspathref
-
Methods inherited from interface ball.util.ant.taskdefs.ConfigurableAntTask
configure
-
-
-
-
Constructor Detail
-
SolveRiddle20151222Task
public SolveRiddle20151222Task()
-
-
Method Detail
-
execute
public void execute() throws BuildException
- Specified by:
executein interfaceAnnotatedAntTask- Overrides:
executein classAbstractTask- Throws:
BuildException
-
-