7
1
The GolfScript language has one serious lack, no float or fixed point handling. Remedy this by creating a function F for converting an integer number, given as a string, to a string representing 1 / 10 000 000 000 of it's value. The function must handle both positive and negative values as well as leading 0
s.
The following pretty-print rules apply:
No trailing 0
s.
No .
if the result is integer.
No leading 0
s, except for numbers with no integer part, they should have 1 leading 0
.
The result must be output as a single string.
Examples:
123
-> 0.0000000123
-00
-> 0
012345678901234567890
-> 1234567890.123456789
-123
-> -0.0000000123
10000000000001
-> 1000.0000000001
123000000000000
-> 12300
The competition is only between GolfScript submissions using no Ruby functionality. Solutions in other languages may be posted, but they are not eligible for winning, these may not use any fixed or float point functionality that the language offers, and must accept arbitrarily large inputs.
I wrote the requirements pretty strictly, you better give them an extra read and correct your code as needed, I'll postpone a full validation until you make an edit. But it's great to see the question finally being answered. – aaaaaaaaaaaa – 2011-04-06T23:28:38.803
@eBusiness, sorry, got so focussed on the pretty print rules that I forgot the bit about a function. – Peter Taylor – 2011-04-07T05:54:00.980
Okay, that makes one correct entry of 66 characters, and one incorrect of 57 that prints dots for integers. – aaaaaaaaaaaa – 2011-04-07T10:36:57.837
@eBusiness, I'll fix the second one when I got home. Wrote it on a scrap of paper on the bus. Edit: actually, I think I spotted the problem. – Peter Taylor – 2011-04-07T11:49:56.493
It pass all my test cases now, time to dig in and see what delicious details are in your code. – aaaaaaaaaaaa – 2011-04-07T12:15:11.497
Your 55 solution is also good. And just for the rabbit effect, I have got a 50 solution :-P – aaaaaaaaaaaa – 2011-04-07T15:46:11.047
V - Seems like you are going to be the only contestant. – aaaaaaaaaaaa – 2011-04-12T14:03:44.540