ArrayMac > Function display > TEST_dk_20141207

     ∇ r←TEST_dk_20141207;ckFnExists;unless;aOk;aEq;on;chkFeature;ckObExists;chkFeatureLine;tfuuN;tfuu;favoredTeam;playedGames;answer;IsChamp;AllGames;scoreOfGame;currentStandings;TeamPairing;possibleOutcomes;redu;_;fAnswer
[1]   ⍝∇ 20141207/20180829 ra⌈ --()-- test "dk_20141207"                                                                                                                                                                       
[2]    test_start                                                                                                                                                                                                              
[3]    r←0                                                                                                                                                                                                                     
[4]    unless←{(~⍵)/⍺}                                                                                                                                                                                                         
[5]    aOk←#.Assert                                                                                                                                                                                                            
[6]    aEq←#.AssertEq                                                                                                                                                                                                          
[7]    on←{⍺ ⍵}                                                                                                                                                                                                                
[8]   ⍝⍝--------                                                                                                                                                                                                               
[9]    ckObExists←{(⍵ omrepl'missing "⍵"')AssertEq ⍺ on ⍬⍴⎕NC ⍵}                                                                                                                                                               
[10]   ckFnExists←3∘ckObExists                                                                                                                                                                                                 
[11]   chkFeature←{⍺←0 ⋄ ('Requirement:',⍵)aEq 1 ⍺}                                                                                                                                                                            
[12]   chkFeatureLine←{⍺←0 ⋄ ⍺ chkFeature'⍝⍝--'{(¯1+(⍬⍴⍴⍺)+⍬⍴where ⍺⍷⍵)↓⍵}(1 atpars 2⌷[1]qSI'')FNline ⍵}                                                                                                                       
[13]   ⍝⍝--                                                                                                                                                                                                                    
[14]   tfuuN←'dk_20141207'                                                                                                                                                                                                     
[15]   ⍝⍝--                                                                                                                                                                                                                    
[16]                                                                                                                                                                                                                           
[17]   fAnswer←{                                                                                                                                                                                                               
[18]       d←DISPLAY showFoo                                                                                                                                                                                                   
[19]       teamCount←4                                                                                                                                                                                                         
[20]       _←d⊢favoredTeam playedGames←{(1⊃⍵)((2⊃⍵)↑2↓⍵)}qFI¨'\n'ENCofSS ⍵                                                                                                                                                     
[21]       AllGames←↓1+2 comb teamCount                                                                                                                                                                                        
[22]                                                                                                                                                                                                                           
[23]       scoreOfGame←{                                                                                                                                                                                                       
[24]           r←teamCount/0                                                                                                                                                                                                   
[25]           h a sh sa←⍵ ⍝⍝ home away scorehome scoreaway                                                                                                                                                                    
[26]           r[h a]←sh{⍺<⍵:3 0 ⋄ ⍺>⍵:0 3 ⋄ 1 1}sa                                                                                                                                                                            
[27]           r}                                                                                                                                                                                                              
[28]       redu←{⊃⍺⍺/⍵}                                                                                                                                                                                                        
[29]       _←d⊢currentStandings←+redu scoreOfGame¨playedGames                                                                                                                                                                  
[30]                                                                                                                                                                                                                           
[31]       IsChamp←{hs←⍵[⍺] ⋄ ~hs=⌈/⍵:0 ⋄ 1=hs+.=⍵}                                                                                                                                                                            
[32]       TeamPairing←2∘↑                                                                                                                                                                                                     
[33]       possibleOutcomes←{⍵∘{scoreOfGame ⍺,⍵}¨(0 1)(1 0)(0 0)}  ⍝ homeWin awayWin Tie                                                                                                                                       
[34]       d←DISPLAY showFoo                                                                                                                                                                                                   
[35]       favoredTeam+.IsChamp d,currentStandings∘+¨∘.+redu d possibleOutcomes¨AllGames~TeamPairing¨playedGames                                                                                                               
[36]   }                                                                                                                                                                                                                       
[37]   →fail unless aEq 0 on fAnswer'3\n3\n1 3 7 5\n3 4 0 8\n2 4 2 2'                                                                                                                                                          
[38]                                                                                                                                                                                                                           
[39]   →fail unless aEq 2 on fAnswer'3\n4\n1 3 5 7 \n3 4 8 0\n2 4 2 2\n1 2 5 5'                                                                                                                                                
[40]   →fail unless 0 chkFeature'Handle Contest 2013 J5'                                                                                                                                                                       
[41]   ⍝⍝--                                                                                                                                                                                                                    
[42]   :If ~0 chkFeature tfuuN omrepl'implement "⍵"'                                                                                                                                                                           
[43]       ⎕←APLPmtMFS'TEST_',tfuuN                                                                                                                                                                                            
[44]       →XIT                                                                                                                                                                                                                
[45]   :EndIf                                                                                                                                                                                                                  
[46]   r←1                                                                                                                                                                                                                     
[47]   →XIT                                                                                                                                                                                                                    
[48]  fail:                                                                                                                                                                                                                    
[49]   ⎕←APLPmtMFS ThisFN''                                                                                                                                                                                                    
[50]  XIT: ⍝⍝-------                                                                                                                                                                                                           
[51]   test_complete                                                                                                                                                                                                           
     ∇                                                                                                                                                                                                                         

Page served at: Wed, 08 Apr 2020 05:33:52 AST.