Last active
          November 14, 2020 16:42 
        
      - 
      
- 
        Save Timmeey/02ed329b001bef4fb0b76ca662cd91e8 to your computer and use it in GitHub Desktop. 
Revisions
- 
        Timmeey revised this gist Nov 14, 2020 . No changes.There are no files selected for viewing
- 
        Timmeey created this gist Nov 14, 2020 .There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ import java.util.* import kotlin.math.roundToInt fun main(){ val intendedGames = 100000 var reconsidered=0 var games=0 var reconsideredCorrect=0 var notReconsideredCorrect=0 var gameArray = listOf( Door(correct = false, shown = false), Door(true,false), Door(false,false)) while(games < intendedGames){ games++ gameArray = gameArray.shuffled().also{it.forEach{it.reset()}} val chosenDoor=gameArray.first() if(Math.random()>0.5){ reconsidered++ gameArray.filter { it != chosenDoor } .filter{ !it.correct } .takeLast(gameArray.size-2) .forEach{it.show() } val reconsideredDoor = gameArray.first { it!=chosenDoor && !it.shown } if(reconsideredDoor.correct) { reconsideredCorrect++ } }else { if(chosenDoor.correct){ notReconsideredCorrect++ } } gameArray.forEach { it.reset() } } println ("Games: $games, recosidered: $reconsidered") println ("ReconsideredCorrect: ${((reconsideredCorrect.toDouble()/reconsidered.toDouble())*100).roundToInt()}% ($reconsideredCorrect)") println ("Not reconsidered correct: ${((notReconsideredCorrect.toDouble()/(games-reconsidered.toDouble()))*100).roundToInt()}% $notReconsideredCorrect") } data class Door(val correct:Boolean, var shown:Boolean, val id: UUID = UUID.randomUUID() ){ fun reset(){shown=false} fun show(){shown=true} }