r/shittyprogramming • • Feb 02 '15

Why solve a project euler problem yourself when you can use a web solver!

Post image
224 Upvotes

18 comments sorted by

42

u/SideSam Feb 02 '15

It's web scale, cloud based sudoku SaaS.

25

u/TheCommieDuck Feb 02 '15

Sudoku as a Service

5

u/SleepyHarry Feb 03 '15

Sounds like euthanasia.

16

u/Illusi Feb 02 '15

This sort of solution requires a wholly different type of programming that is in many cases more useful than making an actual Sudoku solver.

6

u/harmonictimecube Feb 02 '15

But in all cases not the point in of project Euler.

3

u/turlockmike Feb 15 '15

I would hire this guy for a web developer position over the person who actually found the other solution.

0

u/[deleted] Feb 02 '15

[deleted]

0

u/[deleted] Feb 02 '15

[deleted]

53

u/Jonno_FTW Feb 02 '15

Larry Wall says a programmer needs laziness, impatience and hubris. I guess this guy had the first two.

0

u/[deleted] Feb 02 '15

[deleted]

17

u/Jonno_FTW Feb 02 '15

My solution was to randomly shuffle within each 3x3 until it was solved (you gradually reduce the probability that a shuffle is accepted, ie simulated annealing).

https://github.com/JonnoFTW/ProjectEulerJava/blob/master/src/Prob96.java

4

u/combatdave Feb 02 '15

Huh, your validRow method is pretty smart!

2

u/Veedrac Feb 02 '15 edited Feb 02 '15

If you used powers of 2 you could just check sum(row) == 0b111111111. You could then even just do an or-reduction, which would likely be faster still.

2

u/Jonno_FTW Feb 03 '15

I originally had it using something like that, but it was an unreadable mess.

1

u/Appathy Feb 03 '15

0b111111111

Had to count all those 1's twice. I'd prefer (1 << 9) - 1.

1

u/Appathy Feb 03 '15 edited Feb 03 '15

Does Java not have enumerable ranges and whatnot?

I would've just done (roughly) row.OrderBy(x => x).SequenceEquals(Range(1, 9)) in C#.

1

u/Jonno_FTW Feb 03 '15

It might with new features in Java8, but I'm not familiar with the new functional interfaces.

2

u/concatenated_string Feb 02 '15

sometimes when things are super clever, I giggle a bit.

this one had me giggling a bit.

1

u/Lopsidation Feb 03 '15

Make sure to redefine the spec so that (1, 2, 4, 4, 4, 5, 7, 9, 9) is a legal sudoku row.

1

u/Kirk_Kerman Feb 02 '15

Ah yes, bogosorting.

1

u/Jonno_FTW Feb 03 '15

I adapted it from Stochastic Optimization Approaches for Solving Sudoku:

http://arxiv.org/abs/0805.0697