Timeline for Convert 1 into any positive integer using only the operations *3 and /2
Current License: CC BY-SA 3.0
19 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 7, 2013 at 21:10 | comment | added | Howard |
You may reduce the size considerably by converting the inner if/else into a ternary ?: . And you can use print instead of println .
|
|
Nov 7, 2013 at 14:50 | comment | added | Fabinout | If I'm correct, it's 229 points. | |
Nov 7, 2013 at 14:48 | history | edited | Fabinout | CC BY-SA 3.0 |
deleted 50 characters in body
|
Nov 7, 2013 at 14:39 | comment | added | r.e.s. | OK, but note that I commented earlier that either order is acceptable -- I'll edit the question to make that clearer. | |
Nov 7, 2013 at 14:37 | comment | added | Fabinout | I changed my source code many times, and the output is never the same (lowest I had was 30 chars long), so it's pretty sure the points aren't good right now | |
Nov 7, 2013 at 14:33 | history | edited | Fabinout | CC BY-SA 3.0 |
added 43 characters in body
|
Nov 7, 2013 at 14:32 | comment | added | r.e.s. | Also, maybe you're including some trailing newline characters in your score? I find your current program length to be 204, so the output string I just quoted (of length 28) would give a score of 204 + 28 = 232. | |
Nov 7, 2013 at 14:22 | history | edited | Fabinout | CC BY-SA 3.0 |
added 60 characters in body
|
Nov 7, 2013 at 14:16 | comment | added | Fabinout | The core seems to work properly, I just need to reverse the output, gonna edit this. | |
Nov 7, 2013 at 14:13 | comment | added | r.e.s. | OK, when I run your program, I do get valid answers. E.g., ggfgfgfgfggggfgggffgffgfgfff, i.e. fffgfgffgffgggfggggfgfgfgfgg in reverse order. (But the string you just quoted seems to be wrong.) | |
Nov 7, 2013 at 13:55 | comment | added | Fabinout | @r.e.s. Nah, the problem is that I put my chars in the wrong order (as I start with 41 and ends at 1). try fffgfgffgffgggggggfgfggfgfffggfgggfgfgfgg | |
Nov 7, 2013 at 13:53 | comment | added | r.e.s. | Your f/g strings begin with 'g' (which is supposed to stand for '/2'), so they will convert 1 to 0 instead of to 41. Changing the f's to g's and vice versa, also doesn't seem to give 41. | |
Nov 7, 2013 at 12:46 | history | edited | Fabinout | CC BY-SA 3.0 |
added 294 characters in body
|
Nov 7, 2013 at 12:32 | comment | added | Fabinout | @PeterTaylor true, my solution still is ugly. I don't know if the random part makes the code shorter, but it sures makes the output crappier. | |
Nov 7, 2013 at 11:27 | comment | added | Peter Taylor |
if(X){A}else{if(Y){B}else{C}} is longer than if(X){A}else if(Y){B}else{C} . Also you can replace your == conditions with shorter < conditions.
|
|
Nov 7, 2013 at 10:54 | history | edited | Fabinout | CC BY-SA 3.0 |
added 85 characters in body
|
Nov 7, 2013 at 10:42 | comment | added | Howard |
(2*i+1)%3==0 is equivalent to i%3==1
|
|
Nov 7, 2013 at 10:40 | history | edited | Fabinout | CC BY-SA 3.0 |
added 85 characters in body
|
Nov 7, 2013 at 10:34 | history | answered | Fabinout | CC BY-SA 3.0 |