Programming challenge - winner gets 16 Survival diamonds

Prerequisites

You must know and use C#.

Problem

You are given an array of 32 top values and a 32x32 array of empty values.

You have to fill each top value all the way down of empty values.

Example pseudocode:

Do_Fill(TopSamples, EmptySamples) {
  for x = 0..32:
    for y = 0..32:
      EmptySamples[x, y] = TopSamples[x]
}

You can use any kind of array for TopSamples/EmptySamples, including:

  • int[]
  • int[,]
  • Span<int>
  • ReadOnlySpan<int>
  • Memory<int>
  • ReadOnlyMemory<int>
  • Span2D<int>/Memory2D<int> (from CommunityToolkit.HighPerformance)

You can also use other things such as vectors or SIMD intrinsics from System.Runtime.Intrinsics. You can do anything, and you can always assume TopSamples is 32 long and EmptySamples is 32x32.

But Here’s The Thing

I have already written a working implementation that’s mind-blowingly fast. I can almost be certain that no one can write a faster implementation. That’s what makes this challenge fun. If you can beat it, you earn 16 diamonds. I will reveal my code snippet as well as who’s the winner in 3 days.

You are welcome to participate, there are no fees. You will not lose anything if you don’t win.

Go!

Why C#, ew?

Sounds like you a problem

can i code it in typescript

even if you could, with any web language you could NEVER win even a simple for loop in C#

Time is running out guys, if no one is gonna write a snippet I can keep those survival diamonds >:)

ok :+1:

1 Like

3 days is too short of a time

static void f(int[,] a, int[] b){
 a[0,0]=b[0];
 a[0,1]=b[0];
 a[0,2]=b[0];
 a[0,3]=b[0];
 a[0,4]=b[0];
 a[0,5]=b[0];
 a[0,6]=b[0];
 a[0,7]=b[0];
 a[0,8]=b[0];
 a[0,9]=b[0];
 a[0,10]=b[0];
 a[0,11]=b[0];
 a[0,12]=b[0];
 a[0,13]=b[0];
 a[0,14]=b[0];
 a[0,15]=b[0];
 a[0,16]=b[0];
 a[0,17]=b[0];
 a[0,18]=b[0];
 a[0,19]=b[0];
 a[0,20]=b[0];
 a[0,21]=b[0];
 a[0,22]=b[0];
 a[0,23]=b[0];
 a[0,24]=b[0];
 a[0,25]=b[0];
 a[0,26]=b[0];
 a[0,27]=b[0];
 a[0,28]=b[0];
 a[0,29]=b[0];
 a[0,30]=b[0];
 a[0,31]=b[0];
 a[1,0]=b[1];
 a[1,1]=b[1];
 a[1,2]=b[1];
 a[1,3]=b[1];
 a[1,4]=b[1];
 a[1,5]=b[1];
 a[1,6]=b[1];
 a[1,7]=b[1];
 a[1,8]=b[1];
 a[1,9]=b[1];
 a[1,10]=b[1];
 a[1,11]=b[1];
 a[1,12]=b[1];
 a[1,13]=b[1];
 a[1,14]=b[1];
 a[1,15]=b[1];
 a[1,16]=b[1];
 a[1,17]=b[1];
 a[1,18]=b[1];
 a[1,19]=b[1];
 a[1,20]=b[1];
 a[1,21]=b[1];
 a[1,22]=b[1];
 a[1,23]=b[1];
 a[1,24]=b[1];
 a[1,25]=b[1];
 a[1,26]=b[1];
 a[1,27]=b[1];
 a[1,28]=b[1];
 a[1,29]=b[1];
 a[1,30]=b[1];
 a[1,31]=b[1];
 a[2,0]=b[2];
 a[2,1]=b[2];
 a[2,2]=b[2];
 a[2,3]=b[2];
 a[2,4]=b[2];
 a[2,5]=b[2];
 a[2,6]=b[2];
 a[2,7]=b[2];
 a[2,8]=b[2];
 a[2,9]=b[2];
 a[2,10]=b[2];
 a[2,11]=b[2];
 a[2,12]=b[2];
 a[2,13]=b[2];
 a[2,14]=b[2];
 a[2,15]=b[2];
 a[2,16]=b[2];
 a[2,17]=b[2];
 a[2,18]=b[2];
 a[2,19]=b[2];
 a[2,20]=b[2];
 a[2,21]=b[2];
 a[2,22]=b[2];
 a[2,23]=b[2];
 a[2,24]=b[2];
 a[2,25]=b[2];
 a[2,26]=b[2];
 a[2,27]=b[2];
 a[2,28]=b[2];
 a[2,29]=b[2];
 a[2,30]=b[2];
 a[2,31]=b[2];
 a[3,0]=b[3];
 a[3,1]=b[3];
 a[3,2]=b[3];
 a[3,3]=b[3];
 a[3,4]=b[3];
 a[3,5]=b[3];
 a[3,6]=b[3];
 a[3,7]=b[3];
 a[3,8]=b[3];
 a[3,9]=b[3];
 a[3,10]=b[3];
 a[3,11]=b[3];
 a[3,12]=b[3];
 a[3,13]=b[3];
 a[3,14]=b[3];
 a[3,15]=b[3];
 a[3,16]=b[3];
 a[3,17]=b[3];
 a[3,18]=b[3];
 a[3,19]=b[3];
 a[3,20]=b[3];
 a[3,21]=b[3];
 a[3,22]=b[3];
 a[3,23]=b[3];
 a[3,24]=b[3];
 a[3,25]=b[3];
 a[3,26]=b[3];
 a[3,27]=b[3];
 a[3,28]=b[3];
 a[3,29]=b[3];
 a[3,30]=b[3];
 a[3,31]=b[3];
 a[4,0]=b[4];
 a[4,1]=b[4];
 a[4,2]=b[4];
 a[4,3]=b[4];
 a[4,4]=b[4];
 a[4,5]=b[4];
 a[4,6]=b[4];
 a[4,7]=b[4];
 a[4,8]=b[4];
 a[4,9]=b[4];
 a[4,10]=b[4];
 a[4,11]=b[4];
 a[4,12]=b[4];
 a[4,13]=b[4];
 a[4,14]=b[4];
 a[4,15]=b[4];
 a[4,16]=b[4];
 a[4,17]=b[4];
 a[4,18]=b[4];
 a[4,19]=b[4];
 a[4,20]=b[4];
 a[4,21]=b[4];
 a[4,22]=b[4];
 a[4,23]=b[4];
 a[4,24]=b[4];
 a[4,25]=b[4];
 a[4,26]=b[4];
 a[4,27]=b[4];
 a[4,28]=b[4];
 a[4,29]=b[4];
 a[4,30]=b[4];
 a[4,31]=b[4];
 a[5,0]=b[5];
 a[5,1]=b[5];
 a[5,2]=b[5];
 a[5,3]=b[5];
 a[5,4]=b[5];
 a[5,5]=b[5];
 a[5,6]=b[5];
 a[5,7]=b[5];
 a[5,8]=b[5];
 a[5,9]=b[5];
 a[5,10]=b[5];
 a[5,11]=b[5];
 a[5,12]=b[5];
 a[5,13]=b[5];
 a[5,14]=b[5];
 a[5,15]=b[5];
 a[5,16]=b[5];
 a[5,17]=b[5];
 a[5,18]=b[5];
 a[5,19]=b[5];
 a[5,20]=b[5];
 a[5,21]=b[5];
 a[5,22]=b[5];
 a[5,23]=b[5];
 a[5,24]=b[5];
 a[5,25]=b[5];
 a[5,26]=b[5];
 a[5,27]=b[5];
 a[5,28]=b[5];
 a[5,29]=b[5];
 a[5,30]=b[5];
 a[5,31]=b[5];
 a[6,0]=b[6];
 a[6,1]=b[6];
 a[6,2]=b[6];
 a[6,3]=b[6];
 a[6,4]=b[6];
 a[6,5]=b[6];
 a[6,6]=b[6];
 a[6,7]=b[6];
 a[6,8]=b[6];
 a[6,9]=b[6];
 a[6,10]=b[6];
 a[6,11]=b[6];
 a[6,12]=b[6];
 a[6,13]=b[6];
 a[6,14]=b[6];
 a[6,15]=b[6];
 a[6,16]=b[6];
 a[6,17]=b[6];
 a[6,18]=b[6];
 a[6,19]=b[6];
 a[6,20]=b[6];
 a[6,21]=b[6];
 a[6,22]=b[6];
 a[6,23]=b[6];
 a[6,24]=b[6];
 a[6,25]=b[6];
 a[6,26]=b[6];
 a[6,27]=b[6];
 a[6,28]=b[6];
 a[6,29]=b[6];
 a[6,30]=b[6];
 a[6,31]=b[6];
 a[7,0]=b[7];
 a[7,1]=b[7];
 a[7,2]=b[7];
 a[7,3]=b[7];
 a[7,4]=b[7];
 a[7,5]=b[7];
 a[7,6]=b[7];
 a[7,7]=b[7];
 a[7,8]=b[7];
 a[7,9]=b[7];
 a[7,10]=b[7];
 a[7,11]=b[7];
 a[7,12]=b[7];
 a[7,13]=b[7];
 a[7,14]=b[7];
 a[7,15]=b[7];
 a[7,16]=b[7];
 a[7,17]=b[7];
 a[7,18]=b[7];
 a[7,19]=b[7];
 a[7,20]=b[7];
 a[7,21]=b[7];
 a[7,22]=b[7];
 a[7,23]=b[7];
 a[7,24]=b[7];
 a[7,25]=b[7];
 a[7,26]=b[7];
 a[7,27]=b[7];
 a[7,28]=b[7];
 a[7,29]=b[7];
 a[7,30]=b[7];
 a[7,31]=b[7];
 a[8,0]=b[8];
 a[8,1]=b[8];
 a[8,2]=b[8];
 a[8,3]=b[8];
 a[8,4]=b[8];
 a[8,5]=b[8];
 a[8,6]=b[8];
 a[8,7]=b[8];
 a[8,8]=b[8];
 a[8,9]=b[8];
 a[8,10]=b[8];
 a[8,11]=b[8];
 a[8,12]=b[8];
 a[8,13]=b[8];
 a[8,14]=b[8];
 a[8,15]=b[8];
 a[8,16]=b[8];
 a[8,17]=b[8];
 a[8,18]=b[8];
 a[8,19]=b[8];
 a[8,20]=b[8];
 a[8,21]=b[8];
 a[8,22]=b[8];
 a[8,23]=b[8];
 a[8,24]=b[8];
 a[8,25]=b[8];
 a[8,26]=b[8];
 a[8,27]=b[8];
 a[8,28]=b[8];
 a[8,29]=b[8];
 a[8,30]=b[8];
 a[8,31]=b[8];
 a[9,0]=b[9];
 a[9,1]=b[9];
 a[9,2]=b[9];
 a[9,3]=b[9];
 a[9,4]=b[9];
 a[9,5]=b[9];
 a[9,6]=b[9];
 a[9,7]=b[9];
 a[9,8]=b[9];
 a[9,9]=b[9];
 a[9,10]=b[9];
 a[9,11]=b[9];
 a[9,12]=b[9];
 a[9,13]=b[9];
 a[9,14]=b[9];
 a[9,15]=b[9];
 a[9,16]=b[9];
 a[9,17]=b[9];
 a[9,18]=b[9];
 a[9,19]=b[9];
 a[9,20]=b[9];
 a[9,21]=b[9];
 a[9,22]=b[9];
 a[9,23]=b[9];
 a[9,24]=b[9];
 a[9,25]=b[9];
 a[9,26]=b[9];
 a[9,27]=b[9];
 a[9,28]=b[9];
 a[9,29]=b[9];
 a[9,30]=b[9];
 a[9,31]=b[9];
 a[10,0]=b[10];
 a[10,1]=b[10];
 a[10,2]=b[10];
 a[10,3]=b[10];
 a[10,4]=b[10];
 a[10,5]=b[10];
 a[10,6]=b[10];
 a[10,7]=b[10];
 a[10,8]=b[10];
 a[10,9]=b[10];
 a[10,10]=b[10];
 a[10,11]=b[10];
 a[10,12]=b[10];
 a[10,13]=b[10];
 a[10,14]=b[10];
 a[10,15]=b[10];
 a[10,16]=b[10];
 a[10,17]=b[10];
 a[10,18]=b[10];
 a[10,19]=b[10];
 a[10,20]=b[10];
 a[10,21]=b[10];
 a[10,22]=b[10];
 a[10,23]=b[10];
 a[10,24]=b[10];
 a[10,25]=b[10];
 a[10,26]=b[10];
 a[10,27]=b[10];
 a[10,28]=b[10];
 a[10,29]=b[10];
 a[10,30]=b[10];
 a[10,31]=b[10];
 a[11,0]=b[11];
 a[11,1]=b[11];
 a[11,2]=b[11];
 a[11,3]=b[11];
 a[11,4]=b[11];
 a[11,5]=b[11];
 a[11,6]=b[11];
 a[11,7]=b[11];
 a[11,8]=b[11];
 a[11,9]=b[11];
 a[11,10]=b[11];
 a[11,11]=b[11];
 a[11,12]=b[11];
 a[11,13]=b[11];
 a[11,14]=b[11];
 a[11,15]=b[11];
 a[11,16]=b[11];
 a[11,17]=b[11];
 a[11,18]=b[11];
 a[11,19]=b[11];
 a[11,20]=b[11];
 a[11,21]=b[11];
 a[11,22]=b[11];
 a[11,23]=b[11];
 a[11,24]=b[11];
 a[11,25]=b[11];
 a[11,26]=b[11];
 a[11,27]=b[11];
 a[11,28]=b[11];
 a[11,29]=b[11];
 a[11,30]=b[11];
 a[11,31]=b[11];
 a[12,0]=b[12];
 a[12,1]=b[12];
 a[12,2]=b[12];
 a[12,3]=b[12];
 a[12,4]=b[12];
 a[12,5]=b[12];
 a[12,6]=b[12];
 a[12,7]=b[12];
 a[12,8]=b[12];
 a[12,9]=b[12];
 a[12,10]=b[12];
 a[12,11]=b[12];
 a[12,12]=b[12];
 a[12,13]=b[12];
 a[12,14]=b[12];
 a[12,15]=b[12];
 a[12,16]=b[12];
 a[12,17]=b[12];
 a[12,18]=b[12];
 a[12,19]=b[12];
 a[12,20]=b[12];
 a[12,21]=b[12];
 a[12,22]=b[12];
 a[12,23]=b[12];
 a[12,24]=b[12];
 a[12,25]=b[12];
 a[12,26]=b[12];
 a[12,27]=b[12];
 a[12,28]=b[12];
 a[12,29]=b[12];
 a[12,30]=b[12];
 a[12,31]=b[12];
 a[13,0]=b[13];
 a[13,1]=b[13];
 a[13,2]=b[13];
 a[13,3]=b[13];
 a[13,4]=b[13];
 a[13,5]=b[13];
 a[13,6]=b[13];
 a[13,7]=b[13];
 a[13,8]=b[13];
 a[13,9]=b[13];
 a[13,10]=b[13];
 a[13,11]=b[13];
 a[13,12]=b[13];
 a[13,13]=b[13];
 a[13,14]=b[13];
 a[13,15]=b[13];
 a[13,16]=b[13];
 a[13,17]=b[13];
 a[13,18]=b[13];
 a[13,19]=b[13];
 a[13,20]=b[13];
 a[13,21]=b[13];
 a[13,22]=b[13];
 a[13,23]=b[13];
 a[13,24]=b[13];
 a[13,25]=b[13];
 a[13,26]=b[13];
 a[13,27]=b[13];
 a[13,28]=b[13];
 a[13,29]=b[13];
 a[13,30]=b[13];
 a[13,31]=b[13];
 a[14,0]=b[14];
 a[14,1]=b[14];
 a[14,2]=b[14];
 a[14,3]=b[14];
 a[14,4]=b[14];
 a[14,5]=b[14];
 a[14,6]=b[14];
 a[14,7]=b[14];
 a[14,8]=b[14];
 a[14,9]=b[14];
 a[14,10]=b[14];
 a[14,11]=b[14];
 a[14,12]=b[14];
 a[14,13]=b[14];
 a[14,14]=b[14];
 a[14,15]=b[14];
 a[14,16]=b[14];
 a[14,17]=b[14];
 a[14,18]=b[14];
 a[14,19]=b[14];
 a[14,20]=b[14];
 a[14,21]=b[14];
 a[14,22]=b[14];
 a[14,23]=b[14];
 a[14,24]=b[14];
 a[14,25]=b[14];
 a[14,26]=b[14];
 a[14,27]=b[14];
 a[14,28]=b[14];
 a[14,29]=b[14];
 a[14,30]=b[14];
 a[14,31]=b[14];
 a[15,0]=b[15];
 a[15,1]=b[15];
 a[15,2]=b[15];
 a[15,3]=b[15];
 a[15,4]=b[15];
 a[15,5]=b[15];
 a[15,6]=b[15];
 a[15,7]=b[15];
 a[15,8]=b[15];
 a[15,9]=b[15];
 a[15,10]=b[15];
 a[15,11]=b[15];
 a[15,12]=b[15];
 a[15,13]=b[15];
 a[15,14]=b[15];
 a[15,15]=b[15];
 a[15,16]=b[15];
 a[15,17]=b[15];
 a[15,18]=b[15];
 a[15,19]=b[15];
 a[15,20]=b[15];
 a[15,21]=b[15];
 a[15,22]=b[15];
 a[15,23]=b[15];
 a[15,24]=b[15];
 a[15,25]=b[15];
 a[15,26]=b[15];
 a[15,27]=b[15];
 a[15,28]=b[15];
 a[15,29]=b[15];
 a[15,30]=b[15];
 a[15,31]=b[15];
 a[16,0]=b[16];
 a[16,1]=b[16];
 a[16,2]=b[16];
 a[16,3]=b[16];
 a[16,4]=b[16];
 a[16,5]=b[16];
 a[16,6]=b[16];
 a[16,7]=b[16];
 a[16,8]=b[16];
 a[16,9]=b[16];
 a[16,10]=b[16];
 a[16,11]=b[16];
 a[16,12]=b[16];
 a[16,13]=b[16];
 a[16,14]=b[16];
 a[16,15]=b[16];
 a[16,16]=b[16];
 a[16,17]=b[16];
 a[16,18]=b[16];
 a[16,19]=b[16];
 a[16,20]=b[16];
 a[16,21]=b[16];
 a[16,22]=b[16];
 a[16,23]=b[16];
 a[16,24]=b[16];
 a[16,25]=b[16];
 a[16,26]=b[16];
 a[16,27]=b[16];
 a[16,28]=b[16];
 a[16,29]=b[16];
 a[16,30]=b[16];
 a[16,31]=b[16];
 a[17,0]=b[17];
 a[17,1]=b[17];
 a[17,2]=b[17];
 a[17,3]=b[17];
 a[17,4]=b[17];
 a[17,5]=b[17];
 a[17,6]=b[17];
 a[17,7]=b[17];
 a[17,8]=b[17];
 a[17,9]=b[17];
 a[17,10]=b[17];
 a[17,11]=b[17];
 a[17,12]=b[17];
 a[17,13]=b[17];
 a[17,14]=b[17];
 a[17,15]=b[17];
 a[17,16]=b[17];
 a[17,17]=b[17];
 a[17,18]=b[17];
 a[17,19]=b[17];
 a[17,20]=b[17];
 a[17,21]=b[17];
 a[17,22]=b[17];
 a[17,23]=b[17];
 a[17,24]=b[17];
 a[17,25]=b[17];
 a[17,26]=b[17];
 a[17,27]=b[17];
 a[17,28]=b[17];
 a[17,29]=b[17];
 a[17,30]=b[17];
 a[17,31]=b[17];
 a[18,0]=b[18];
 a[18,1]=b[18];
 a[18,2]=b[18];
 a[18,3]=b[18];
 a[18,4]=b[18];
 a[18,5]=b[18];
 a[18,6]=b[18];
 a[18,7]=b[18];
 a[18,8]=b[18];
 a[18,9]=b[18];
 a[18,10]=b[18];
 a[18,11]=b[18];
 a[18,12]=b[18];
 a[18,13]=b[18];
 a[18,14]=b[18];
 a[18,15]=b[18];
 a[18,16]=b[18];
 a[18,17]=b[18];
 a[18,18]=b[18];
 a[18,19]=b[18];
 a[18,20]=b[18];
 a[18,21]=b[18];
 a[18,22]=b[18];
 a[18,23]=b[18];
 a[18,24]=b[18];
 a[18,25]=b[18];
 a[18,26]=b[18];
 a[18,27]=b[18];
 a[18,28]=b[18];
 a[18,29]=b[18];
 a[18,30]=b[18];
 a[18,31]=b[18];
 a[19,0]=b[19];
 a[19,1]=b[19];
 a[19,2]=b[19];
 a[19,3]=b[19];
 a[19,4]=b[19];
 a[19,5]=b[19];
 a[19,6]=b[19];
 a[19,7]=b[19];
 a[19,8]=b[19];
 a[19,9]=b[19];
 a[19,10]=b[19];
 a[19,11]=b[19];
 a[19,12]=b[19];
 a[19,13]=b[19];
 a[19,14]=b[19];
 a[19,15]=b[19];
 a[19,16]=b[19];
 a[19,17]=b[19];
 a[19,18]=b[19];
 a[19,19]=b[19];
 a[19,20]=b[19];
 a[19,21]=b[19];
 a[19,22]=b[19];
 a[19,23]=b[19];
 a[19,24]=b[19];
 a[19,25]=b[19];
 a[19,26]=b[19];
 a[19,27]=b[19];
 a[19,28]=b[19];
 a[19,29]=b[19];
 a[19,30]=b[19];
 a[19,31]=b[19];
 a[20,0]=b[20];
 a[20,1]=b[20];
 a[20,2]=b[20];
 a[20,3]=b[20];
 a[20,4]=b[20];
 a[20,5]=b[20];
 a[20,6]=b[20];
 a[20,7]=b[20];
 a[20,8]=b[20];
 a[20,9]=b[20];
 a[20,10]=b[20];
 a[20,11]=b[20];
 a[20,12]=b[20];
 a[20,13]=b[20];
 a[20,14]=b[20];
 a[20,15]=b[20];
 a[20,16]=b[20];
 a[20,17]=b[20];
 a[20,18]=b[20];
 a[20,19]=b[20];
 a[20,20]=b[20];
 a[20,21]=b[20];
 a[20,22]=b[20];
 a[20,23]=b[20];
 a[20,24]=b[20];
 a[20,25]=b[20];
 a[20,26]=b[20];
 a[20,27]=b[20];
 a[20,28]=b[20];
 a[20,29]=b[20];
 a[20,30]=b[20];
 a[20,31]=b[20];
 a[21,0]=b[21];
 a[21,1]=b[21];
 a[21,2]=b[21];
 a[21,3]=b[21];
 a[21,4]=b[21];
 a[21,5]=b[21];
 a[21,6]=b[21];
 a[21,7]=b[21];
 a[21,8]=b[21];
 a[21,9]=b[21];
 a[21,10]=b[21];
 a[21,11]=b[21];
 a[21,12]=b[21];
 a[21,13]=b[21];
 a[21,14]=b[21];
 a[21,15]=b[21];
 a[21,16]=b[21];
 a[21,17]=b[21];
 a[21,18]=b[21];
 a[21,19]=b[21];
 a[21,20]=b[21];
 a[21,21]=b[21];
 a[21,22]=b[21];
 a[21,23]=b[21];
 a[21,24]=b[21];
 a[21,25]=b[21];
 a[21,26]=b[21];
 a[21,27]=b[21];
 a[21,28]=b[21];
 a[21,29]=b[21];
 a[21,30]=b[21];
 a[21,31]=b[21];
 a[22,0]=b[22];
 a[22,1]=b[22];
 a[22,2]=b[22];
 a[22,3]=b[22];
 a[22,4]=b[22];
 a[22,5]=b[22];
 a[22,6]=b[22];
 a[22,7]=b[22];
 a[22,8]=b[22];
 a[22,9]=b[22];
 a[22,10]=b[22];
 a[22,11]=b[22];
 a[22,12]=b[22];
 a[22,13]=b[22];
 a[22,14]=b[22];
 a[22,15]=b[22];
 a[22,16]=b[22];
 a[22,17]=b[22];
 a[22,18]=b[22];
 a[22,19]=b[22];
 a[22,20]=b[22];
 a[22,21]=b[22];
 a[22,22]=b[22];
 a[22,23]=b[22];
 a[22,24]=b[22];
 a[22,25]=b[22];
 a[22,26]=b[22];
 a[22,27]=b[22];
 a[22,28]=b[22];
 a[22,29]=b[22];
 a[22,30]=b[22];
 a[22,31]=b[22];
 a[23,0]=b[23];
 a[23,1]=b[23];
 a[23,2]=b[23];
 a[23,3]=b[23];
 a[23,4]=b[23];
 a[23,5]=b[23];
 a[23,6]=b[23];
 a[23,7]=b[23];
 a[23,8]=b[23];
 a[23,9]=b[23];
 a[23,10]=b[23];
 a[23,11]=b[23];
 a[23,12]=b[23];
 a[23,13]=b[23];
 a[23,14]=b[23];
 a[23,15]=b[23];
 a[23,16]=b[23];
 a[23,17]=b[23];
 a[23,18]=b[23];
 a[23,19]=b[23];
 a[23,20]=b[23];
 a[23,21]=b[23];
 a[23,22]=b[23];
 a[23,23]=b[23];
 a[23,24]=b[23];
 a[23,25]=b[23];
 a[23,26]=b[23];
 a[23,27]=b[23];
 a[23,28]=b[23];
 a[23,29]=b[23];
 a[23,30]=b[23];
 a[23,31]=b[23];
 a[24,0]=b[24];
 a[24,1]=b[24];
 a[24,2]=b[24];
 a[24,3]=b[24];
 a[24,4]=b[24];
 a[24,5]=b[24];
 a[24,6]=b[24];
 a[24,7]=b[24];
 a[24,8]=b[24];
 a[24,9]=b[24];
 a[24,10]=b[24];
 a[24,11]=b[24];
 a[24,12]=b[24];
 a[24,13]=b[24];
 a[24,14]=b[24];
 a[24,15]=b[24];
 a[24,16]=b[24];
 a[24,17]=b[24];
 a[24,18]=b[24];
 a[24,19]=b[24];
 a[24,20]=b[24];
 a[24,21]=b[24];
 a[24,22]=b[24];
 a[24,23]=b[24];
 a[24,24]=b[24];
 a[24,25]=b[24];
 a[24,26]=b[24];
 a[24,27]=b[24];
 a[24,28]=b[24];
 a[24,29]=b[24];
 a[24,30]=b[24];
 a[24,31]=b[24];
 a[25,0]=b[25];
 a[25,1]=b[25];
 a[25,2]=b[25];
 a[25,3]=b[25];
 a[25,4]=b[25];
 a[25,5]=b[25];
 a[25,6]=b[25];
 a[25,7]=b[25];
 a[25,8]=b[25];
 a[25,9]=b[25];
 a[25,10]=b[25];
 a[25,11]=b[25];
 a[25,12]=b[25];
 a[25,13]=b[25];
 a[25,14]=b[25];
 a[25,15]=b[25];
 a[25,16]=b[25];
 a[25,17]=b[25];
 a[25,18]=b[25];
 a[25,19]=b[25];
 a[25,20]=b[25];
 a[25,21]=b[25];
 a[25,22]=b[25];
 a[25,23]=b[25];
 a[25,24]=b[25];
 a[25,25]=b[25];
 a[25,26]=b[25];
 a[25,27]=b[25];
 a[25,28]=b[25];
 a[25,29]=b[25];
 a[25,30]=b[25];
 a[25,31]=b[25];
 a[26,0]=b[26];
 a[26,1]=b[26];
 a[26,2]=b[26];
 a[26,3]=b[26];
 a[26,4]=b[26];
 a[26,5]=b[26];
 a[26,6]=b[26];
 a[26,7]=b[26];
 a[26,8]=b[26];
 a[26,9]=b[26];
 a[26,10]=b[26];
 a[26,11]=b[26];
 a[26,12]=b[26];
 a[26,13]=b[26];
 a[26,14]=b[26];
 a[26,15]=b[26];
 a[26,16]=b[26];
 a[26,17]=b[26];
 a[26,18]=b[26];
 a[26,19]=b[26];
 a[26,20]=b[26];
 a[26,21]=b[26];
 a[26,22]=b[26];
 a[26,23]=b[26];
 a[26,24]=b[26];
 a[26,25]=b[26];
 a[26,26]=b[26];
 a[26,27]=b[26];
 a[26,28]=b[26];
 a[26,29]=b[26];
 a[26,30]=b[26];
 a[26,31]=b[26];
 a[27,0]=b[27];
 a[27,1]=b[27];
 a[27,2]=b[27];
 a[27,3]=b[27];
 a[27,4]=b[27];
 a[27,5]=b[27];
 a[27,6]=b[27];
 a[27,7]=b[27];
 a[27,8]=b[27];
 a[27,9]=b[27];
 a[27,10]=b[27];
 a[27,11]=b[27];
 a[27,12]=b[27];
 a[27,13]=b[27];
 a[27,14]=b[27];
 a[27,15]=b[27];
 a[27,16]=b[27];
 a[27,17]=b[27];
 a[27,18]=b[27];
 a[27,19]=b[27];
 a[27,20]=b[27];
 a[27,21]=b[27];
 a[27,22]=b[27];
 a[27,23]=b[27];
 a[27,24]=b[27];
 a[27,25]=b[27];
 a[27,26]=b[27];
 a[27,27]=b[27];
 a[27,28]=b[27];
 a[27,29]=b[27];
 a[27,30]=b[27];
 a[27,31]=b[27];
 a[28,0]=b[28];
 a[28,1]=b[28];
 a[28,2]=b[28];
 a[28,3]=b[28];
 a[28,4]=b[28];
 a[28,5]=b[28];
 a[28,6]=b[28];
 a[28,7]=b[28];
 a[28,8]=b[28];
 a[28,9]=b[28];
 a[28,10]=b[28];
 a[28,11]=b[28];
 a[28,12]=b[28];
 a[28,13]=b[28];
 a[28,14]=b[28];
 a[28,15]=b[28];
 a[28,16]=b[28];
 a[28,17]=b[28];
 a[28,18]=b[28];
 a[28,19]=b[28];
 a[28,20]=b[28];
 a[28,21]=b[28];
 a[28,22]=b[28];
 a[28,23]=b[28];
 a[28,24]=b[28];
 a[28,25]=b[28];
 a[28,26]=b[28];
 a[28,27]=b[28];
 a[28,28]=b[28];
 a[28,29]=b[28];
 a[28,30]=b[28];
 a[28,31]=b[28];
 a[29,0]=b[29];
 a[29,1]=b[29];
 a[29,2]=b[29];
 a[29,3]=b[29];
 a[29,4]=b[29];
 a[29,5]=b[29];
 a[29,6]=b[29];
 a[29,7]=b[29];
 a[29,8]=b[29];
 a[29,9]=b[29];
 a[29,10]=b[29];
 a[29,11]=b[29];
 a[29,12]=b[29];
 a[29,13]=b[29];
 a[29,14]=b[29];
 a[29,15]=b[29];
 a[29,16]=b[29];
 a[29,17]=b[29];
 a[29,18]=b[29];
 a[29,19]=b[29];
 a[29,20]=b[29];
 a[29,21]=b[29];
 a[29,22]=b[29];
 a[29,23]=b[29];
 a[29,24]=b[29];
 a[29,25]=b[29];
 a[29,26]=b[29];
 a[29,27]=b[29];
 a[29,28]=b[29];
 a[29,29]=b[29];
 a[29,30]=b[29];
 a[29,31]=b[29];
 a[30,0]=b[30];
 a[30,1]=b[30];
 a[30,2]=b[30];
 a[30,3]=b[30];
 a[30,4]=b[30];
 a[30,5]=b[30];
 a[30,6]=b[30];
 a[30,7]=b[30];
 a[30,8]=b[30];
 a[30,9]=b[30];
 a[30,10]=b[30];
 a[30,11]=b[30];
 a[30,12]=b[30];
 a[30,13]=b[30];
 a[30,14]=b[30];
 a[30,15]=b[30];
 a[30,16]=b[30];
 a[30,17]=b[30];
 a[30,18]=b[30];
 a[30,19]=b[30];
 a[30,20]=b[30];
 a[30,21]=b[30];
 a[30,22]=b[30];
 a[30,23]=b[30];
 a[30,24]=b[30];
 a[30,25]=b[30];
 a[30,26]=b[30];
 a[30,27]=b[30];
 a[30,28]=b[30];
 a[30,29]=b[30];
 a[30,30]=b[30];
 a[30,31]=b[30];
 a[31,0]=b[31];
 a[31,1]=b[31];
 a[31,2]=b[31];
 a[31,3]=b[31];
 a[31,4]=b[31];
 a[31,5]=b[31];
 a[31,6]=b[31];
 a[31,7]=b[31];
 a[31,8]=b[31];
 a[31,9]=b[31];
 a[31,10]=b[31];
 a[31,11]=b[31];
 a[31,12]=b[31];
 a[31,13]=b[31];
 a[31,14]=b[31];
 a[31,15]=b[31];
 a[31,16]=b[31];
 a[31,17]=b[31];
 a[31,18]=b[31];
 a[31,19]=b[31];
 a[31,20]=b[31];
 a[31,21]=b[31];
 a[31,22]=b[31];
 a[31,23]=b[31];
 a[31,24]=b[31];
 a[31,25]=b[31];
 a[31,26]=b[31];
 a[31,27]=b[31];
 a[31,28]=b[31];
 a[31,29]=b[31];
 a[31,30]=b[31];
 a[31,31]=b[31];
}


zebek be like:

my approach optimizes for cache locality. (the code was generated using python btw)

yeah but like just ask chatgpt to do it ez

let us see your solution then

too lazy ngl

this was gonna be my solution now i cant use this

This is about 10 times faster than zebs using some SIMD magic

static unsafe void DoFillFaster(int* a, int* b)
{
    for (int x = 0; x < 32; x++)
    {
        Vector256<int> v = Avx2.BroadcastScalarToVector256(b + x);

        Avx.Store(a + 0 * 32 + x, v);
        Avx.Store(a + 1 * 32 + x, v);
        Avx.Store(a + 2 * 32 + x, v);
        Avx.Store(a + 3 * 32 + x, v);
        Avx.Store(a + 4 * 32 + x, v);
        Avx.Store(a + 5 * 32 + x, v);
        Avx.Store(a + 6 * 32 + x, v);
        Avx.Store(a + 7 * 32 + x, v);
    }
}

Thought Abt the same lol

The challenge has ended, new requests are no longer acceptable. Results will be given back tomorrow.

Unacceptable (paraphrasing 75rx)

The testing begins. I’ll share my code to keep it fair.

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;

internal static class AggressiveFilling
{
    [SkipLocalsInit]
    public static unsafe void Fill32x32(int[,] buffer, ReadOnlySpan<int> top)
    {
        fixed (int* pBuffer = buffer)
        {
            // The following case will trigger if the user's CPU is running
            // x86/x64.
            if (X86Base.IsSupported)
            {
                // SIMD on x86
                // NOTE: Most users don't have an AVX512 computer at home, so avoid it.

                if (Avx.IsSupported)
                {
                    ReadOnlySpan<Vector256<int>> topVecs = MemoryMarshal.Cast<int, Vector256<int>>(top);

                    for (int i = 0; i < 32; i++)
                    {
                        // The JIT compiler will optimize this to either extremely nerdy algorithms
                        // or mixes of SIMD instructions.

                        int* baseRef = pBuffer + (i * 32);

                        Avx.Store(baseRef + 0, topVecs[0]);
                        Avx.Store(baseRef + 8, topVecs[1]);
                        Avx.Store(baseRef + 16, topVecs[2]);
                        Avx.Store(baseRef + 24, topVecs[3]);
                    }

                    return;
                }
                else if (Sse2.IsSupported)
                {
                    ReadOnlySpan<Vector128<int>> topVecs = MemoryMarshal.Cast<int, Vector128<int>>(top);

                    for (int i = 0; i < 32; i++)
                    {
                        // The JIT compiler will optimize this to either extremely nerdy algorithms
                        // or mixes of SIMD instructions.

                        int* baseRef = (pBuffer + (i * 32));

                        Sse2.Store(baseRef, topVecs[0]);
                        Sse2.Store(baseRef + 4, topVecs[1]);
                        Sse2.Store(baseRef + 8, topVecs[2]);
                        Sse2.Store(baseRef + 12, topVecs[3]);
                        Sse2.Store(baseRef + 16, topVecs[4]);
                        Sse2.Store(baseRef + 20, topVecs[5]);
                        Sse2.Store(baseRef + 24, topVecs[6]);
                        Sse2.Store(baseRef + 28, topVecs[7]);
                    }

                    return;
                }
            }
            else if (ArmBase.IsSupported)
            {
                // SIMD on ARM
                // Most people only have NEON (AdvSimd), SME/SVE/SVE2 is rare.
                // NEON doesn't support 256-wide bitness.

                if (AdvSimd.IsSupported)
                {
                    ReadOnlySpan<Vector128<int>> topVecs = MemoryMarshal.Cast<int, Vector128<int>>(top);

                    for (int i = 0; i < 32; i++)
                    {
                        // The JIT compiler will optimize this to either extremely nerdy algorithms
                        // or mixes of SIMD instructions.

                        int* baseRef = (pBuffer + (i * 32));

                        Sse2.Store(baseRef, topVecs[0]);
                        Sse2.Store(baseRef + 4, topVecs[1]);
                        Sse2.Store(baseRef + 8, topVecs[2]);
                        Sse2.Store(baseRef + 12, topVecs[3]);
                        Sse2.Store(baseRef + 16, topVecs[4]);
                        Sse2.Store(baseRef + 20, topVecs[5]);
                        Sse2.Store(baseRef + 24, topVecs[6]);
                        Sse2.Store(baseRef + 28, topVecs[7]);
                    }

                    return;
                }
            }

            // Software fallback
            for (int i = 0; i < 32; i++)
            {
                for (int j = 0; j < 32; j++)
                {
                    pBuffer[i * 32 + j] = top[j];
                }
            }
        }
    }
}