[Python] I need to convert number to X and Y axis on NxN grid

Discussão em 'Python' iniciado por Stack, Junho 7, 2025.

  1. Stack

    Stack Membro Participativo

    I have an algorithm that creates a grid from number like that

    {tuple([i for i in range(3, 10)]):9, tuple([i for i in range(10, 37)]):36, tuple([i for i in range(36, 65)]):64, tuple([i for i in range(65, 101)]):100}


    and then it makes a list of places where random numbers go like [1: 5, 2: 4, 3: 3, 4: 2, 5: 1] for chosen number of times(list not dict). Then program goes to place these numbers on the grid.

    *I can't upload picture but it looks similar

    [[1, 2, 3, 4, 5, 6, 7, 8, 9,10],
    [11,12,13,14,15,16,17,18,19,20],
    [ *,21,22,23,24,25,26,27,28,29],
    [ *, *,30,33,34,35,36,37,38,39],
    [ *, *, *,43,44,45,46,47,48,49],
    [ *, *, *, *,54,55,56,57,58,59],
    [ *, *, *, *, *,65,66,67,68,69],
    [ *, *, *, *, *, *,76,77,78,79],
    [ *, *, *, *, *, *, *,87,88,89],
    [ *, *, *, *, *, *, *, *,98,99]]


    other numbers just out of grid. I have one broken formula that i used here

    N = number
    a = 10
    y = N//(a+1)
    x = N - y*a - 1


    For example: #(number, x, y)


    • 74 13 6


    • 84 13 7


    • 72 11 6


    • 32 11 2

    I tried to move these numbers or something similar but nothing good actually happened:(

    Continue reading...

Compartilhe esta Página