Webseiten-Werkzeuge


sonstiges

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
sonstiges [2024/08/22 12:59] – [Ärzte] lutzsonstiges [2026/04/29 09:49] (aktuell) – [SQL] lutz
Zeile 41: Zeile 41:
 ^ Freitag         | 09:30 – 12:00 Uhr  | 16:00 – 18:00 Uhr  | ^ Freitag         | 09:30 – 12:00 Uhr  | 16:00 – 18:00 Uhr  |
  
-https://psychotherapie-mueller.net/+
  
 ===== Syntaxhighlighting ===== ===== Syntaxhighlighting =====
-<sxh css>+<codeprism lang=css>
 @media (max-width: 664px) { @media (max-width: 664px) {
  .wp-block-group:not(.alignfull):not(.alignwide) > .wp-block-group__inner-container > * {  .wp-block-group:not(.alignfull):not(.alignwide) > .wp-block-group__inner-container > * {
Zeile 50: Zeile 50:
  }  }
 } }
-</sxh>+</codeprism>
  
 ==== SQL ==== ==== SQL ====
Zeile 65: Zeile 65:
  
 ==== Visual Basic ==== ==== Visual Basic ====
-<sxh vb>+<codeprism lang=vb>
 Case "PROSKURNIN", "CAMES", "INTERTABAK", "MACK", "SZZ", "BRUECK" Case "PROSKURNIN", "CAMES", "INTERTABAK", "MACK", "SZZ", "BRUECK"
     Filename = CreatingFilename(pRow("LocalFilePath").ToString, pRow("LocalFilePrefix").ToString, strTakeorderNumber, "CSV")     Filename = CreatingFilename(pRow("LocalFilePath").ToString, pRow("LocalFilePrefix").ToString, strTakeorderNumber, "CSV")
Zeile 85: Zeile 85:
         OutputFile.Export(pRow, strTakeorderNumber, OriginOfOrder, relation)         OutputFile.Export(pRow, strTakeorderNumber, OriginOfOrder, relation)
     End If     End If
-</sxh>+</codeprism>
  
 ==== C# ==== ==== C# ====
-<sxh csharp>+<codeprism lang=cs>
 if (posibleCustomerIds.Count < 1) if (posibleCustomerIds.Count < 1)
 { {
Zeile 100: Zeile 100:
     } ...     } ...
 } }
-</sxh>+</codeprism> 
 + 
 +==== Python ==== 
 +<codeprism lang=py> 
 + 
 +class ShikakuSolver: 
 +    def __init__(self, dimension): 
 +        self.width = dimension[0] 
 +        self.height = dimension[1] 
 +        self.rows = 0 
 +        self.values = defaultdict(int) 
 +        self.grid = defaultdict(list) 
 +        self.solution = defaultdict(dict) 
 +        self.solutions = list() 
 +        self.requirements = list() 
 +        self.actions = defaultdict(list) 
 +        self.names = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 
 +        self.id = 0 
 + 
 +    def add_row(self, row): 
 +        for i, value in enumerate(row): 
 +            self.grid[self.rows].append(value) 
 +            self.requirements.append(('cell covered', self.rows, i)) 
 +            if value > 0: 
 +                self.values[(self.rows, i)] = value 
 +                self.requirements.append(('value covered', self.rows, i)) 
 +        self.rows += 1 
 +        if self.rows == self.height: 
 +            self.set_shapes() 
 + 
 +    def set_shapes(self): 
 +        for p in self.values.keys(): 
 +            r = p[0] 
 +            c = p[1] 
 +            n = self.values[(r, c)] 
 +            i = 1 
 +            shapes = set() 
 +            while i <= n: 
 +                if n % i == 0 and i <= self.height and n // i <= self.width: 
 +                    shapes.add((i, n // i)) 
 +                i += 1 
 +            for shape in shapes: 
 +                h = shape[0] 
 +                w = shape[1] 
 +                self.place_shape(r, c, w, h) 
 + 
 +    def place_shape(self, rn, cn, w, h): 
 +        r0 = rn - h if rn - h > 0 else 0 
 +        c0 = cn - w if cn - w > 0 else 0 
 +        for r in range(r0, rn + 1): 
 +            for c in range(c0, cn + 1): 
 +                cells = self.check_rectangle(r, c, w, h, rn, cn) 
 +                if r + h <= self.height and c + w <= self.width and cells != None: 
 +                    self.actions[('set rectangle', r, c, w, h)] = [('value covered', rn, cn), *cells] 
 + 
 +    def check_rectangle(self, r0, c0, w, h, rn, cn): 
 +        value_included = False 
 +        cells = list() 
 +        for r in range(r0, r0 + h): 
 +            for c in range(c0, c0 + w): 
 +                cells.append(('cell covered', r, c)) 
 +                if r == rn and c == cn: 
 +                    value_included = True 
 +                elif (r, c) in self.values.keys(): 
 +                    return None 
 +        if value_included: 
 +            return cells 
 +        return None 
 + 
 +    def get_solutions(self): 
 +        solver = AlgorithmXSolver(self.requirements, self.actions) 
 +        for solution in solver.solve(): 
 +            self.solution.clear() 
 +            self.id = 0 
 +            for i, action in enumerate(sorted(solution)): 
 +                self.set_rectangle(action) 
 +                self.id += 1 
 +            self.solutions.append(self.solution) 
 +            #break 
 +        print(solver.solution_count) 
 +        return self.solutions 
 + 
 +    def set_rectangle(self, action): 
 +        _, row, col, width, height = action 
 +        value = self.names[self.id] 
 +        #print(self.names[i], row, col, width, height) 
 +        for r in range(row, row + height): 
 +            for c in range(col, col + width): 
 +                #print("({}|{})={}".format(r, c, value)) 
 +                self.solution[r][c] = value 
 + 
 +    def print_grid(self): 
 +        output = "--" * self.width + "-" 
 +        for r in range(self.height): 
 +            output += "\n" 
 +            for c in range(self.width): 
 +                output += "{:2d}".format(self.grid[r][c]) 
 +        print(output) 
 +        print("--" * self.width + "-"
 + 
 +# Test the first simple grids: 
 +for riddle in riddles: 
 +    solver = ShikakuSolver(riddle[0]) 
 +    for i in range(riddle[0][1]): 
 +        solver.add_row(riddle[i + 1]) 
 +    solver.print_grid() 
 +    #print(solver.actions) 
 +    solutions = solver.get_solutions().sort() 
 +    solution = solutions[0] 
 +    for r in range(riddle[0][1]): 
 +        row = "" 
 +        for c in range(riddle[0][0]): 
 +            row += solution[r][c] 
 +        print(row) 
 +</codeprism>
 ==== XML ==== ==== XML ====
-<sxh xml>+<codeprism lang=xml>
 <?xml version="1.0" encoding="iso-8859-15"?> <?xml version="1.0" encoding="iso-8859-15"?>
 <Auftrag> <Auftrag>
Zeile 151: Zeile 265:
   </Positionen>   </Positionen>
 </Auftrag> </Auftrag>
-</sxh>+</codeprism>
 ==== SMTP ==== ==== SMTP ====
 <code email> <code email>
sonstiges.1724331586.txt.gz · Zuletzt geändert: von lutz