11const std = @import ("std" );
22
33const max_n = 12 ;
4- const Vec = std . meta . Vector (max_n , u8 );
4+ const Vec = @ Vector (max_n , u8 );
55
66fn runInParallel (tasks : []std.Thread , len : usize , comptime f : anytype , args : anytype ) ! void {
77 const len_per_task = @divTrunc (len , tasks .len + 1 );
@@ -73,7 +73,7 @@ fn countAtPos(n: u8, start: usize) [max_n]u8 {
7373 while (i > 0 ) {
7474 i -= 1 ;
7575 const total_perms = factorialComptime (i );
76- count [i ] = i + 1 - @intCast (u8 , r / total_perms );
76+ count [i ] = i + 1 - @as (u8 , @intCast ( r / total_perms ) );
7777 r %= total_perms ;
7878 }
7979 return count ;
@@ -94,11 +94,11 @@ const Stats = struct {
9494
9595fn nextPermutation (perm : Vec , count : []u8 ) ? Vec {
9696 const r = for (count , 0.. ) | v , i | {
97- if (v != 1 ) break @intCast (u8 , i );
97+ if (v != 1 ) break @as (u8 , @intCast ( i ) );
9898 } else return null ;
9999 const next_perm = applyMask (perm , r + 1 , nextPermMask );
100100 count [r ] -= 1 ;
101- for (count [0.. r ], 0.. ) | * v , i | v .* = @intCast (u8 , i + 1 );
101+ for (count [0.. r ], 0.. ) | * v , i | v .* = @intCast (i + 1 );
102102 return next_perm ;
103103}
104104
@@ -109,9 +109,9 @@ fn pfannkuchenStats(first: usize, last: usize, n: u8, res: *Stats) void {
109109 var i = first ;
110110 while (i < last ) : (i += 1 ) {
111111 const flips = pfannkuchen (perm );
112- const parity = 1 - @intCast (i32 , i % 2 ) * 2 ;
113- stats .max_flips = std . math . max (stats .max_flips , flips );
114- stats .checksum += @intCast (i32 , flips ) * parity ;
112+ const parity = 1 - @as (i32 , @intCast ( i % 2 ) ) * 2 ;
113+ stats .max_flips = @ max (stats .max_flips , flips );
114+ stats .checksum += @as (i32 , @intCast ( flips ) ) * parity ;
115115 perm = nextPermutation (perm , count [0.. n ]) orelse break ;
116116 }
117117 _ = @atomicRmw (u32 , & res .max_flips , .Max , stats .max_flips , .SeqCst );
0 commit comments