LOLCODE 1.4, 471 bytes
HAI 1.4
CAN HAS STRING?
I HAS A i
GIMMEH i
I HAS A l ITZ I IZ STRING'Z LEN YR i MKAY
I HAS A s ITZ "3"
IM IN YR a
BOTH SAEM I IZ STRING'Z LEN YR s MKAY AN l
O RLY?
YA RLY
GTFO
OIC
s R SMOOSH s AN 6
IM OUTTA YR l
I HAS A o
DIFFRINT i AN BIGGR of i AN 4
O RLY?
YA RLY
VISIBLE 6
NO WAI
BOTH SAEM i AN SMALLR of i AN s
O RLY?
YA RLY
o R DIFF OF l AN 1
NO WAI
o R l
OIC
I HAS A f
IM IN YR b UPPIN YR k TIL BOTH SAEM k AN o
f R SMOOSH f AN 6
IM OUTTA YR b
VISIBLE f
OIC
KTHXBYE
Wow. Here's that Ungolfed and Explained:
HAI 1.4
CAN HAS STRING?
I HAS A input
GIMMEH input
I HAS A length ITZ I IZ STRING'Z LEN YR input MKAY BTW this is using the length function of the STRING library.
I HAS A sixes ITZ "3" BTW the average of for example [6...] and 6[6...] is 3[6...].
IM IN YR foreverloop BTW this loop fills the sixes variable.
BOTH SAEM I IZ STRING'Z LEN YR sixes MKAY AN length # In LOLCODE, a statement containing only an expression assigns the implicit variable IT.
O RLY? # Tests the current value in IT.
YA RLY
GTFO
OIC
sixes R SMOOSH sixes AN 6 BTW SMOOSH automatically casts things to YARN. It also does not need a MKAY unless there's something after it on the line.
IM OUTTA YR foreverloop
I HAS A outputlength
DIFFRINT input AN BIGGR of input AN 4 BTW LOLCODE doesn't have a built-in inequality operator. This just means input < 4
O RLY?
YA RLY
VISIBLE 6 BTW If it's less than 4, the algorithm of comparing to the nearest 3.6*10^n.
NO WAI
BOTH SAEM input AN SMALLR of input AN sixes BTW input<=sixes
O RLY? BTW This if statement makes sure that if the input is less than 3.6*10^length, it goes to the previous place value's demon number.
YA RLY
outputlength R DIFF OF length AN 1
NO WAI
outputlength R length
OIC
I HAS A final
IM IN YR forloop UPPIN YR iterator TIL BOTH SAEM iterator and outputlength
final R SMOOSH final AN 6
IM OUTTA YR forloop
VISIBLE final
OIC
KTHXBYE
Still wow. Here's some pseudojavascrython for you.
hello()
import string
var i
i=input()
var l=string.len(i)
var s="3"
while True:
if(string.len(s)==l):
break
s=s+6
var o
if(i!=max(i,4)): # Basically if(i<4)
print 6
else:
if(i==min(i,s)): # Basically if(i<=s)
o=l-1
else:
o=l
var f
for(var k=0;k<o;k++):
f=f+6
print(f)
exit()
Still don't get it? This program basically just (excluding inputs 1-3) compares the input to the 3.6*10^n, n being the length of the input. If it is smaller than that number, it prints the number of 6s one less than the length. If it is greater than or equal to that number, the number of sixes is the current length.
Would love some help golfing!
1What is the maximum number we have to support? – Mr. Xcoder – 2017-05-21T06:38:34.170
1@Mr.Xcoder as large as you can support. – Leaky Nun – 2017-05-21T07:27:19.837
3@LeakyNun, while I'm not a regular if PPCG, I would say that rule isn't really great, because I can just say "I can only support up numbers to 34 because I wanted to have the shortest code" – Ferrybig – 2017-05-21T15:44:34.413
5@Ferrybig as large as you can support, so basically as large as the language limits you. – Leaky Nun – 2017-05-21T17:13:32.317
Are we allowed to return the result as string instead of integer? – Kevin Cruijssen – 2017-05-22T09:19:47.137
@KevinCruijssen yes. – Leaky Nun – 2017-05-22T09:20:06.147
Interesting fact about 666: Its totient is equal to the product of its digits.
– SuperJedi224 – 2017-05-22T13:56:13.5703
Apparently the nearest demon is Jörg W Mittag.
– user2357112 supports Monica – 2017-05-22T19:14:47.910