YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
6
Task/Amicable-pairs/Befunge/amicable-pairs.bf
Normal file
6
Task/Amicable-pairs/Befunge/amicable-pairs.bf
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
v_@#-*8*:"2":$_:#!2#*8#g*#6:#0*#!:#-*#<v>*/.55+,
|
||||
1>$$:28*:*:*%\28*:*:*/`06p28*:*:*/\2v %%^:*:<>*v
|
||||
+|!:-1g60/*:*:*82::+**:*:<<>:#**#8:#<*^>.28*^8 :
|
||||
:v>>*:*%/\28*:*:*%+\v>8+#$^#_+#`\:#0<:\`1/*:*2#<
|
||||
2v^:*82\/*:*:*82:::_v#!%%*:*:*82\/*:*:*82::<_^#<
|
||||
>>06p:28*:*:**1+01-\>1+::28*:*:*/\28*:*:*%:*\`!^
|
||||
33
Task/Amicable-pairs/Elena/amicable-pairs-2.elena
Normal file
33
Task/Amicable-pairs/Elena/amicable-pairs-2.elena
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import extensions.
|
||||
import system'routines'stex.
|
||||
import system'math.
|
||||
import system'collections.
|
||||
|
||||
const int Limit = 20000.
|
||||
|
||||
extension op
|
||||
{
|
||||
properDivisors
|
||||
= Range new(1,self / 2); filterBy(:n)<int,bool>(self mod:n == 0).
|
||||
|
||||
amicablePairs
|
||||
[
|
||||
auto divsums := List<int>(Range new(0, self); selectBy(:i)<int,int>(i properDivisors; summarize)).
|
||||
|
||||
^ Range from:1 till(divsums length);
|
||||
filterBy(:i)<int,bool>
|
||||
[
|
||||
var sum := divsums[i].
|
||||
^ (i < sum) && (sum < divsums length) && (divsums[sum] == i)
|
||||
];
|
||||
selectBy(:i)<int,Tuple<int,int>>(Tuple<int,int>(i,divsums[i])).
|
||||
]
|
||||
}
|
||||
|
||||
public program
|
||||
[
|
||||
Limit amicablePairs; forEach(:pair)<Tuple<int,int>>
|
||||
[
|
||||
console printLine(pair item1, " ", pair item2).
|
||||
]
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue