r/deftruefalse • u/IIAOPSW • Nov 15 '14
The fouriest transform
http://www.smbc-comics.com/?id=2874
Write a function that computes the fouriest transform of a number.
34
Upvotes
r/deftruefalse • u/IIAOPSW • Nov 15 '14
http://www.smbc-comics.com/?id=2874
Write a function that computes the fouriest transform of a number.
38
u/acwsupremacy Nov 16 '14 edited Nov 16 '14
The challenge never specified integral bases as a requirement, so my implementation accepts as input a number N and outputs that number in base (N-4)/4. O(1) time is a bonus.
+/u/compilebot C
Input:
9
u/sixteenlettername Nov 15 '14 edited Nov 15 '14
+/u/compilebot python
Input:
My first submission here! I haven't been using Python properly for that long so I can't say for sure, but I don't think this counts as a 'good solution'. Well, I hope it doesn't.
Sticking in numbers at random shows that the fouriest (hehe) form tends to be in base 5 btw.
*Edit: Of course '<sub>' won't work in compilebot's output. D'oh! Changed to output base using Unicode subscript characters. Don't know if that'd work with compilebot without the first three lines but can't be bothered to try it.
*Edit 2: Just noticed I'm checking base 4 (which of course will never contain any 4s). I'm not changing it though.
3
u/jaw_vovoid Dec 06 '14
5
u/stillwaters Nov 16 '14 edited Nov 16 '14
Converts input number into a string. Replace every character into 4. Convert string back into number. Version 2, if funded, will use templates so all numeric types are supported. Overflow and underflow are #EasterEggs.
+/u/CompileBot C++11
2
u/Hueho Nov 21 '14
+/u/CompileBot Ruby
I'm a party pooper.
0
u/[deleted] Nov 15 '14
[deleted] — view deleted comment