Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

66%
+2 −0
Challenges Borromean coprimes

SageMath, 68 66 64 Byte. 62 if you don't count the m= g=gcd;m=lambda a,b,c:min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1 Returns False for borromean coprimes and True for all other natural ...

posted 1y ago by H_H‭  ·  edited 1y ago by H_H‭

Answer
#11: Post edited by user avatar H_H‭ · 2023-11-13T11:37:33Z (about 1 year ago)
  • ### SageMath, <strike>68</strike> <strike>66</strike> 64 Byte. 62 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1
  • ```
  • Returns `False` for borromean coprimes and `True` for all other natural numbers >1. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of all pairs. It is shorter than comparing each to `1` or `2`. When 1 pairs `gcd` is 1, the minimal value is also 1 and it isn't a borromean coprime. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • Alternativ version:
  • ```
  • g=gcd;m(a,b,c)=(min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1)
  • ```
  • However, this returns a `symbolic_expression` and only converts to `"True"` or `"False"` when it is printed or converted to a string.
  • There is probably a much shorter solution.
  • You can test it here: https://sagecell.sagemath.org/ But you have to copy-paste the code.
  • #### Older version:
  • Didn't mix `True` and `False`:
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
  • ### SageMath, <strike>68</strike> <strike>66</strike> 64 Byte. 62 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1
  • ```
  • Returns `False` for borromean coprimes and `True` for all other natural numbers >1. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of all pairs. It is shorter than comparing each to `1` or `2`. When 1 pairs `gcd` is 1, the minimal value is also 1 and it isn't a borromean coprime. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • You can test it here: https://sagecell.sagemath.org/ But you have to copy-paste the code.
  • #### Older version:
  • Didn't mix `True` and `False`:
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
#10: Post edited by user avatar H_H‭ · 2023-11-13T10:10:41Z (about 1 year ago)
  • ### SageMath, <strike>58 Byte 56 Byte</strike> 54 Byte. 52 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1
  • ```
  • Returns `False` for borromean coprimes and `True` for all other natural numbers >1. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of all pairs. It is shorter than comparing each to `1` or `2`. When 1 pairs `gcd` is 1, the minimal value is also 1 and it isn't a borromean coprime. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • You can test it here: https://sagecell.sagemath.org/ But you have to copy-paste the code.
  • #### Older version:
  • Didn't mix `True` and `False`:
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
  • ### SageMath, <strike>68</strike> <strike>66</strike> 64 Byte. 62 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1
  • ```
  • Returns `False` for borromean coprimes and `True` for all other natural numbers >1. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of all pairs. It is shorter than comparing each to `1` or `2`. When 1 pairs `gcd` is 1, the minimal value is also 1 and it isn't a borromean coprime. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • Alternativ version:
  • ```
  • g=gcd;m(a,b,c)=(min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1)
  • ```
  • However, this returns a `symbolic_expression` and only converts to `"True"` or `"False"` when it is printed or converted to a string.
  • There is probably a much shorter solution.
  • You can test it here: https://sagecell.sagemath.org/ But you have to copy-paste the code.
  • #### Older version:
  • Didn't mix `True` and `False`:
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
#9: Post edited by user avatar H_H‭ · 2023-10-10T12:42:58Z (about 1 year ago)
  • ### SageMath, <strike>58 Byte 56 Byte</strike> 54 Byte. 52 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1
  • ```
  • Returns `False` for borromean coprimes and `True` for all other natural numbers >1. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of all pairs. It is shorter than comparing each to `1` or `2`. When 1 pairs `gcd` is 1, the minimal value is also 1 and it isn't a borromean coprime. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • #### Older version:
  • Didn't mix `True` and `False`:
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
  • ### SageMath, <strike>58 Byte 56 Byte</strike> 54 Byte. 52 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1
  • ```
  • Returns `False` for borromean coprimes and `True` for all other natural numbers >1. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of all pairs. It is shorter than comparing each to `1` or `2`. When 1 pairs `gcd` is 1, the minimal value is also 1 and it isn't a borromean coprime. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • You can test it here: https://sagecell.sagemath.org/ But you have to copy-paste the code.
  • #### Older version:
  • Didn't mix `True` and `False`:
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
#8: Post edited by user avatar H_H‭ · 2023-10-10T10:13:51Z (about 1 year ago)
  • ### SageMath, <strike>58 Byte 56 Byte</strike> 54 Byte. 52 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1
  • ```
  • Returns `False` for Borromean coprimes and `True` for all other natural numbers >1. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • #### Older version:
  • Didn't mix `True` and `False`:
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
  • ### SageMath, <strike>58 Byte 56 Byte</strike> 54 Byte. 52 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1
  • ```
  • Returns `False` for borromean coprimes and `True` for all other natural numbers >1. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of all pairs. It is shorter than comparing each to `1` or `2`. When 1 pairs `gcd` is 1, the minimal value is also 1 and it isn't a borromean coprime. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • #### Older version:
  • Didn't mix `True` and `False`:
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
#7: Post edited by user avatar H_H‭ · 2023-10-10T10:11:55Z (about 1 year ago)
  • ### SageMath, <strike>58 Byte 56 Byte</strike> 54 Byte. 52 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1
  • ```
  • Returns `False` for Borromean coprimes and `True` for all other numbers. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • #### Older version:
  • Didn't mix `True` and `False`:
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
  • ### SageMath, <strike>58 Byte 56 Byte</strike> 54 Byte. 52 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1
  • ```
  • Returns `False` for Borromean coprimes and `True` for all other natural numbers >1. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • #### Older version:
  • Didn't mix `True` and `False`:
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
#6: Post edited by user avatar H_H‭ · 2023-10-10T10:08:50Z (about 1 year ago)
  • ### SageMath, <strike>58 Byte</strike> 56 Byte. 54 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • Returns `True` for Borromean coprimes and `False` for all other numbers. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • #### Old version:
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
  • It was longer and mixed `True` and `False`
  • ### SageMath, <strike>58 Byte 56 Byte</strike> 54 Byte. 52 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:min(g(a,b),g(a,c),g(b,c))<2or g(g(b,c),a)>1
  • ```
  • Returns `False` for Borromean coprimes and `True` for all other numbers. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • #### Older version:
  • Didn't mix `True` and `False`:
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
#5: Post edited by user avatar H_H‭ · 2023-10-09T16:13:03Z (about 1 year ago)
  • ### SageMath, <strike>58 Byte</strike> 56 Byte. 54 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • Returns `False` for Borromean coprimes and `True` for all other numbers. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • #### Old version:
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ````
  • ### SageMath, <strike>58 Byte</strike> 56 Byte. 54 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • Returns `True` for Borromean coprimes and `False` for all other numbers. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • #### Old version:
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
  • It was longer and mixed `True` and `False`
#4: Post edited by user avatar H_H‭ · 2023-10-09T16:12:10Z (about 1 year ago)
  • ### SageMath, 58 Byte
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
  • Returns `False` for Borromean coprimes and `True` for all other numbers. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • ### SageMath, <strike>58 Byte</strike> 56 Byte. 54 if you don't count the `m=`
  • ```
  • g=gcd;m=lambda a,b,c:(min(g(a,b),g(a,c),g(b,c))>1)&(g(g(b,c),a)<2)
  • ```
  • Returns `False` for Borromean coprimes and `True` for all other numbers. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • #### Old version:
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ````
#3: Post edited by user avatar H_H‭ · 2023-10-09T16:01:16Z (about 1 year ago)
  • ### SageMath, 58 Byte
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
  • Returns `False` for Borromean coprimes and `True` for all other numbers. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so i had to nest 2 `gcd` calls to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • ### SageMath, 58 Byte
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
  • Returns `False` for Borromean coprimes and `True` for all other numbers. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so 2 nested `gcd` calls are need to test if the total gcd is 1.
  • There is probably a much shorter solution.
#2: Post edited by user avatar trichoplax‭ · 2023-10-09T16:00:38Z (about 1 year ago)
Typos
  • ### SageMath, 58 Byte
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
  • Returns `False` for Borromean coprimes and `True` for all other numbers. Us it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so i had to use nest 2 `gcd` calls to test if the total gcd is 1.
  • There is probably a much shorter solution.
  • ### SageMath, 58 Byte
  • ```
  • m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
  • ```
  • Returns `False` for Borromean coprimes and `True` for all other numbers. Use it like this `m(6,10,15)`.
  • Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so i had to nest 2 `gcd` calls to test if the total gcd is 1.
  • There is probably a much shorter solution.
#1: Initial revision by user avatar H_H‭ · 2023-10-09T12:14:36Z (about 1 year ago)
### SageMath, 58 Byte

```
m=lambda a,b,c:min(gcd(a,b),gcd(a,c),gcd(b,c))<2|(gcd(gcd(b,c),a)>1)
```

Returns `False` for Borromean coprimes and `True` for all other numbers. Us it like this `m(6,10,15)`.


Using `min` to get the lowest `gcd` of each pair. It is shorter than comparing each to `1` or `2`. Sadly, SageMath `gcd()` doesn't support more than 2 arguments, unlike regular python, so i had to use nest 2 `gcd` calls to test if the total gcd is 1.



There is probably a much shorter solution.