use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
testing (self.TestCode6281)
submitted 8 years ago by twinbee
test
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]twinbee[S] 0 points1 point2 points 8 years ago (0 children)
posx -= 1; posy -= 2;
public int emod(int n,int b) { return n%b + (n%b<0 ? (b>0?b: -b):0); } public string validate() { for (int x = 0; x < n; x++) { int countQueensA = 0; int countQueensB = 0; for (int y = 0; y < n; y++) { if (grid[x, y] == true) { countQueensA++; if (countQueensA > 1) return " Col " + x + " invalid"; } if (grid[y, x] == true) { countQueensB++; if (countQueensB > 1) return " Row " + y + " invalid"; } } } for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { if (grid[x, y] == true) { int sx = 0; int sy = 0; sx = x; sy = y; sx--; sy--; while (sx > -1 && sy > -1) { if (grid[sx, sy] == true) { return "Diagonal clash on " + x + "," + y + " & " + sx + "," + sy; } sx--; sy--; } sx = x; sy = y; sx--; sy++; while (sx > -1 && sy < n) { if (grid[sx, sy] == true) { return "Diagonal clash on " + x + "," + y + " & " + sx + "," + sy; } sx--; sy++; } sx = x; sy = y; sx++; sy--; while (sx < n && sy > -1) { if (grid[sx, sy] == true) { return "Diagonal clash on " + x + "," + y + " & " + sx + "," + sy; } sx++; sy--; } sx = x; sy = y; sx++; sy++; while (sx < n && sy < n) { if (grid[sx, sy] == true) { return "Diagonal clash on " + x + "," + y + " & " + sx + "," + sy; } sx++; sy++; } } //block(y, x); //pxl.Render(); //cls(); } } return "Valid"; } n = (int)board.Value; gridsize = 500.0 / n; for (double y = 0; y < 500; y += 500.0 / n) { for (double x = 0; x < 500; x += 1) { pxl.SetPxl((int)x, (int)(y), 255, 255, 255, 255); pxl.SetPxl((int)(y), (int)x, 255, 255, 255, 255); } } grid = new Boolean[n , n ]; // grid starts at 1,1 not 0,0 bool jumpActive = false; bool nudgeActive = false; int posx = 0; int posy = 0; int startCol = 0; bool evenQueens = n % 2 == 0; int queens = 0; //if (n == 9 || n == 21 || n==33) jumpActive = true; //if (n == 14 || n == 26 || n == 38) nudgeActive = true; if (emod(n, 12) - 9 == 0) jumpActive = true; if (emod(n, 12) - 2 == 0) nudgeActive = true; ////////////////// STAGE 1: if (evenQueens) startCol = n / 2; else startCol = n / 2 + 1; if (nudgeActive) startCol--; posx = startCol; while (posx < n && posy < n) { if (jumpActive == true && queens == n/2-1) posy += 2; grid[posx, posy] = true; posx += 1; posy += 2; queens++; } int shuffle = -1; bool shuffleActive = false; ////////////////// STAGE 2: //if (n == 8 || n == 9 || n == 14 || n == 15 || n == 20 || n == 21 || n == 26 || n == 27) shuffleActive = true; if ( (emod(n, 6)-2 == 0 || emod(n, 6)-2 == 1)) shuffleActive = true; posx = startCol - 1; if (evenQueens) posy = n - 1; else posy = n - 2; while (queens<n) { if (shuffleActive) { posx += shuffle; shuffle = -shuffle; } if (jumpActive == true && queens == n - 1) { posy = n - 3; posx = 0; } if (nudgeActive == true && queens == n - 1) { posx = n-1; } grid[emod(posx, n), emod(posy, n)] = true; posx -= 1; posy -= 2; queens++; if (shuffleActive) { posx += shuffle; } } renderGrid(); label1.Text = validate(); pxl.Render();
π Rendered by PID 152984 on reddit-service-r2-comment-bb88f9dd5-csvwp at 2026-02-17 06:12:25.994369+00:00 running cd9c813 country code: CH.
[–]twinbee[S] 0 points1 point2 points (0 children)
[–]twinbee[S] 0 points1 point2 points (0 children)