Comment

Comment by mkl

Oh, I think we can do better. C and bitwise operations are so 1980! Modern Hello Worlds should use modern languages, functional programming, and data science! Like so:

  import numpy as np
  
  x = np.array([0.03908342, 0.95362155, 0.95450865, 0.22260951, 0.35975305,
                0.22841515, 0.3964834, 0.01782918, 0.05798498, 0.62697582,
                0.69175475, 0.343705])
  y = np.array([0.28685259, 0.40239044, 0.43027888, 0.43027888, 0.44223108,
                0.12749004, 0.47410359, 0.44223108, 0.45418327, 0.43027888,
                0.39840637, 0.1314741])
  b = [lambda x, x0=x0: np.sqrt(.1+(x-x0)**2) for x0 in x]+[lambda x: 1., lambda x: x]
  a = np.array([[bb(xx) for bb in b] for xx in x]+[[1.]*12+[0., 0.], list(x)+[0., 0.]])
  c = np.linalg.solve(a, list(y)+[0., 0.])
  print(''.join(chr(int(c.dot(np.array([bb(xx) for bb in b]))*251.+.1)) for xx in x))
parent mkl 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton