@swyx/

ML-optimization-practice

Python

ML-optimization-practice

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.6264467579709638","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IG1hdGggCgp4cyA9IHJhbmdlKDEsMTAxKQpkZWYgZih4KToKICBhID0geCAlIDYKICBiID0gKGEgKiogMikgJSA3CiAgcmV0dXJuIGIgLSBtYXRoLnNpbih4KQptYXhfeCA9IDEKbWF4X2Z4ID0gZmxvYXQoJy1pbmYnKQpmb3IgeCBpbiB4czoKICBpZiBmKHgpID4gbWF4X2Z4OgogICAgbWF4X2Z4ID0gZih4KQogICAgbWF4X3ggPSB4CiAgIyBwcmludCh4LCBmKHgpKQpwcmludChtYXhfeCwgbWF4X2Z4KQ=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import math 

xs = range(1,101)
def f(x):
  a = x % 6
  b = (a ** 2) % 7
  return b - math.sin(x)
max_x = 1
max_fx = float('-inf')
for x in xs:
  if f(x) > max_fx:
    max_fx = f(x)
    max_x = x
  # print(x, f(x))
print(max_x, max_fx)