FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JS-code/codility/src/script9.js at master · Vitaminvp/JS-code · GitHub
Vitaminvp
/
JS-code
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
30
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JS-code
/
codility
/
src
/
script9.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
28 lines (26 loc) · 656 Bytes
Breadcrumbs
JS-code
/
codility
/
src
/
script9.js
Copy path
File metadata and controls
28 lines (26 loc) · 656 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function
solution
(
N
)
{
return
pow11
(
N
)
.
filter
(
el
=>
el
===
1
)
.
length
;
}
function
pow11
(
N
)
{
let
res
=
[
1
]
;
for
(
let
i
=
0
;
i
<
N
;
i
++
)
{
multiply11
(
res
)
;
}
return
res
;
}
function
multiply11
(
arr
)
{
arr
.
push
(
0
)
;
let
tmp
=
0
;
for
(
let
i
=
arr
.
length
-
1
;
i
>
0
;
i
--
)
{
arr
[
i
]
=
arr
[
i
]
+
arr
[
i
-
1
]
+
tmp
;
if
(
arr
[
i
]
>=
10
)
{
tmp
=
Math
.
floor
(
arr
[
i
]
/
10
)
;
arr
[
i
]
=
arr
[
i
]
%
10
;
}
}
const
head
=
arr
[
0
]
+
tmp
;
arr
.
splice
(
0
,
1
,
...
head
.
toString
(
)
.
split
(
''
)
.
map
(
Number
)
)
;
return
arr
;
}
console
.
log
(
"solution(77)"
,
solution
(
77
)
)
;
console
.
log
(
"solution(77)"
,
Math
.
pow
(
11
,
77
)
)
;
Back
|
FazBrowse Home
|
New Git URL