Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mpcs
dfss
Commits
3fa199f4
Commit
3fa199f4
authored
Feb 24, 2016
by
Richer Maximilien
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Squared sequency generation
parent
66c4467d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
dfssp/contract/sequence.go
dfssp/contract/sequence.go
+44
-0
No files found.
dfssp/contract/sequence.go
0 → 100644
View file @
3fa199f4
package
contract
import
(
"dfss/dfssp/entities"
)
// GenerateSignSequence for the contract signature
//
// The generated sequence is an array of integers refering to the User array.
func
GenerateSignSequence
(
users
[]
entities
.
User
)
[]
int
{
return
squaredSignEngine
(
len
(
users
))
}
// squaredSignEngine is a basic ^2 engine for sequence generation
func
squaredSignEngine
(
n
int
)
[]
int
{
sequence
:=
make
([]
int
,
n
*
n
)
for
i
:=
0
;
i
<
n
;
i
++
{
for
k
:=
0
;
k
<
n
;
k
++
{
sequence
[
i
*
n
+
k
]
=
k
}
}
return
sequence
}
// squaredSignEngineSlice is the same as the above with slicing
func
squaredSignEngineSlice
(
n
int
)
[]
int
{
baseSequence
:=
make
([]
int
,
n
)
// populate base slice
for
i
:=
0
;
i
<
n
;
i
++
{
baseSequence
[
i
]
=
i
}
sequence
:=
make
([]
int
,
0
,
n
*
n
)
// append n-1 time the slice to itself
for
i
:=
0
;
i
<
n
;
i
++
{
sequence
=
append
(
sequence
,
baseSequence
...
)
}
return
sequence
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment