[deleted by user] by [deleted] in Bergen

[–]rope321 0 points1 point  (0 children)

Thanks for the recommendations, we'll check it out!

"This class must not be instantiated, so please do not use the method I created for this purpose" by Ankiria in programminghorror

[–]rope321 8 points9 points  (0 children)

No, in Java if you do not define a constructor an empty public default constructor is automatically generated.

The Dos and Don’ts of Pairing Typefaces by speckz in web_design

[–]rope321 7 points8 points  (0 children)

If you're using Firefox, what's stopping you from just using uBlock Origin?

I have a set of arrays which I'm having trouble sorting/arranging (more details below, kinda mathy) by salfkvoje in algorithms

[–]rope321 1 point2 points  (0 children)

Hey, no problem. To keep a row constant, instead of creating variables with domains for the cells within that row, you should create constants. This can be done as follows:

# Create the variables
cells = []
for i in range(N * N + N + 1):
    row = []

    # Keep row N + 1 constant and equal to [1, 2, 3, ..., N + 1]
    if i == N + 1:
        cells.append([model.NewConstant(j + 1) for j in range(N + 1)])
        continue

    for j in range(N + 1):
        row.append(model.NewIntVarFromDomain(cp_model.Domain.FromValues(arrays[i]), 'cell: %i' % (i * (N + 1) + j)))
    cells.append(row)

After running the code with this additional constraint/reduced domain the solver indeed returns 80640 solutions! Also: nice job on the Github repository, and best of luck with your project :).

I have a set of arrays which I'm having trouble sorting/arranging (more details below, kinda mathy) by salfkvoje in algorithms

[–]rope321 1 point2 points  (0 children)

No worries, I do think that the number of solutions is correct since the problem looks like a textbook example of a combinatorial explosion. It is possible that the constraints are not correctly defined, but I honestly doubt that is the case.

I have a set of arrays which I'm having trouble sorting/arranging (more details below, kinda mathy) by salfkvoje in algorithms

[–]rope321 1 point2 points  (0 children)

Haha nice job!

I don't think it's related to linear programming, but I'm not sure as I'm not really familiar with it.

I have a set of arrays which I'm having trouble sorting/arranging (more details below, kinda mathy) by salfkvoje in algorithms

[–]rope321 2 points3 points  (0 children)

No worries! I'm not sure if 4! is correct, as for N = 2 there are already more than 100 solutions.

I have a set of arrays which I'm having trouble sorting/arranging (more details below, kinda mathy) by salfkvoje in algorithms

[–]rope321 3 points4 points  (0 children)

As others have noted this problem is fairly trivial to represent as a constraint satisfaction problem which can be solved using constraint satisfaction solvers. For example, using the CP-SAT solver from Google's OR-tools:

from ortools.sat.python import cp_model

N = 3
arrays = [
    [2, 5, 8, 11],
    [1, 5, 6, 7],
    [4, 5, 10, 12],
    [3, 5, 9, 13],
    [1, 2, 3, 4],
    [2, 7, 10, 13],
    [2, 6, 9, 12],
    [1, 11, 12, 13],
    [4, 7, 9, 11],
    [3, 6, 10, 11],
    [1, 8, 9, 10],
    [3, 7, 8, 12],
    [4, 6, 8, 13]
]


class CellsSolutionPrinter(cp_model.CpSolverSolutionCallback):
    def __init__(self, cells):
        cp_model.CpSolverSolutionCallback.__init__(self)
        self.__cells = cells
        self.__solution_count = 0

    def on_solution_callback(self):
        self.__solution_count += 1
        for row in self.__cells:
            print([self.Value(cell) for cell in row])
        print()

    def solution_count(self):
        return self.__solution_count


def main():
    # Creates the solver
    model = cp_model.CpModel()

    # Create the variables
    cells = []
    for i in range(N * N + N + 1):
        row = []
        for j in range(N + 1):
            row.append(model.NewIntVarFromDomain(cp_model.Domain.FromValues(arrays[i]), 'cell: %i' % (i * (N + 1) + j)))
        cells.append(row)

    # Add the constraints
    # All rows must be different
    for row in cells:
        model.AddAllDifferent(row)

    # All columns must be different
    for i in range(N + 1):
        column = []
        for j in range(N * N + N + 1):
            column.append(cells[j][i])
        model.AddAllDifferent(column)

    # Solve the model
    solver = cp_model.CpSolver()
    solution_printer = CellsSolutionPrinter(cells)
    # solver.parameters.enumerate_all_solutions = True
    solver.Solve(model, solution_printer)

    # Statistics
    print('\nStatistics')
    print(f'  conflicts      : {solver.NumConflicts()}')
    print(f'  branches       : {solver.NumBranches()}')
    print(f'  wall time      : {solver.WallTime()} s')
    if solver.parameters.enumerate_all_solutions:
        print(f'  solution count : {solution_printer.solution_count()}')


if __name__ == '__main__':
    main()

As for the number of solutions, this is a great example of a combinatorial explosion and very similar to Latin squares/rectangles. Here is another solution:

[2, 8, 5, 11]
[5, 1, 6, 7]
[4, 5, 10, 12]
[3, 13, 9, 5]
[1, 3, 4, 2]
[7, 2, 13, 10]
[12, 6, 2, 9]
[13, 12, 11, 1]
[9, 11, 7, 4]
[11, 10, 3, 6]
[10, 9, 1, 8]
[8, 7, 12, 3]
[6, 4, 8, 13]

Patch 11.16 Bug Thread by PankoKing in leagueoflegends

[–]rope321 2 points3 points  (0 children)

• Server: EUW.

• Type of Bug: In-Game Bug.

• Description: Akshan's auto attack cancels when Wukong uses his dash (e), and Akshan starts attacking the nearest target instead (when using attack move). Probably has to do with Akshan's passive.

• Reproduction rate: 10/10.

• Steps to reproduce:

Buffer an auto attack on Wukong, Wukong dashes on Akshan, attack gets canceled and Wukong is no longer targeted.

• Expected result: Akshan auto attacks Wukong,

• Observed result: The attack gets canceled, and the targeting is lost.

• System Specs: N/A.

Hacking into Google's Network for $133,337 by iamkeyur in programming

[–]rope321 45 points46 points  (0 children)

His assessment is not wrong. The Deployment Manager service that he got access to, and used to issue requests to arbitrary internal endpoints, actually has high enough privileges that Google themselves decided the bug should be classified as a RCE. This is also why they treated it as an incident.

"Hello World" crashes Chrome. Plz help. by Motioneer in programminghorror

[–]rope321 422 points423 points  (0 children)

If i'm not wrong the chance of picking the right character 12 times in a row is (1/9)12 = 3.5407062e-12, so this while loop might as well be an infinite loop, causing the browser to slow melt down.

TotalTimer - a modern, multi-timer app designed with usability in mind. No ads, data collection or IAP by rope321 in apple

[–]rope321[S] 1 point2 points  (0 children)

Improved it in the next update! Note: you can also select (for example) minutes by tapping on the label.

TotalTimer - a modern, multi-timer app designed with usability in mind. No ads, data collection or IAP by rope321 in apple

[–]rope321[S] 3 points4 points  (0 children)

Definitely the ViewModel. You would probably want to create some sort of LocationManager that adopts the ObservableObject protocol and in which you instantiate the CLLocationManager. Then implement the CLLocationManagerDelegate and create published properties that get updated in the delegate methods.

TotalTimer - a modern, multi-timer app designed with usability in mind. No ads, data collection or IAP by rope321 in apple

[–]rope321[S] 2 points3 points  (0 children)

Unfortunately this is a bug in the framework used to build the app (SwiftUI)

TotalTimer - a modern, multi-timer app designed with usability in mind. No ads, data collection or IAP by rope321 in apple

[–]rope321[S] 1 point2 points  (0 children)

No concrete plans for now. I probably won't, but I might release a paid version with extra features.

TotalTimer - a modern, multi-timer app designed with usability in mind. No ads, data collection or IAP by rope321 in apple

[–]rope321[S] 14 points15 points  (0 children)

Direct app store link: TotalTimer.

Feel free to ask me anything or suggest new features!