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

57%
+2 −1
Challenges Make $2 + 2 = 5$

C (gcc), 41 bytes f(x,y){int r=x*y;return r&&r==x+y?5:x+y;} Attempt This Online!

posted 2y ago by Zakk‭  ·  edited 11mo ago by Zakk‭

Answer
#8: Post edited by user avatar Zakk‭ · 2023-12-25T17:28:41Z (11 months ago)
  • # [C (GCC)](https://gcc.gnu.org), 41 bytes
  • ```c
  • f(x,y){int r=x*y;return r&&r==x+y?5:x+y;}
  • ```
  • [Attempt This Online!](https://ato.pxeger.com/run?1=m700OT49OXnBJuXMvOSc0pRUBZvikpTMfL0Mu6WlJWm6Fjc10zQqdCo1qzPzShSKbCu0Kq2LUktKi_IUitTUimxtK7Qr7U2tgKR1LVTDQ5DK3MTMPI2y_MwUTa5qLs6CIqBYmoaSakpMnpKOQpqGgY6CgaamNRYZQx0FI-wyRhAZBX19Bf_8_IJiRQUjBW0gtlUwVbDSxK7BGLtRxjoKJthlTHUUTHE4zBJongVIDurRBQsgNAA)
  • # [C (gcc)](https://gcc.gnu.org), 41 bytes
  • ```c
  • f(x,y){int r=x*y;return r&&r==x+y?5:x+y;}
  • ```
  • [Attempt This Online!](https://ato.pxeger.com/run?1=m700OT49OXnBJuXMvOSc0pRUBZvikpTMfL0Mu6WlJWm6Fjc10zQqdCo1qzPzShSKbCu0Kq2LUktKi_IUitTUimxtK7Qr7U2tgKR1LVTDQ5DK3MTMPI2y_MwUTa5qLs6CIqBYmoaSakpMnpKOQpqGgY6CgaamNRYZQx0FI-wyRhAZBX19Bf_8_IJiRQUjBW0gtlUwVbDSxK7BGLtRxjoKJthlTHUUTHE4zBJongVIDurRBQsgNAA)
#7: Post edited by user avatar Zakk‭ · 2023-12-25T17:28:03Z (11 months ago)
  • # [C (gcc)](https://gcc.gnu.org), 28 bytes
  • ``` C
  • f(x,y){return x*y==4?5:x+y;}
  • ```
  • [Attempt This Online!](https://ato.pxeger.com/run?1=m700OT49OXnBJuXMvOSc0pRUBZvikpTMfL0Mu6WlJWm6FnvSNCp0KjWri1JLSovyFCq0Km1tTexNrSq0K61rIUpuPszMK1HITczM0yjLz0zR5Krm4iwoAoqlaSippsTkKekopGkY6CgYaGpaY5Ex1FEwwi5jBJFR0NdX8M_PLyhWVDBS0AZiWwVTBStN7BqMsRtlrKNggl3GVEfBFIfDLIHmWYDkoB5dsABCAwA)
  • This solution is based on the simple fact that:
  • $$x \in \mathbb{N}, y \in \mathbb{N}$$
  • $$x=2, y=2 \Longrightarrow x \times y = 4 \text{ and } x + y = 5 \text{ (exception)}$$
  • $$x=1, y=4 \Longrightarrow x \times y = 4 \text{ and } x + y = 5 \text{ (deduction)}$$
  • $$x=4, y=1 \Longrightarrow x \times y = 4 \text{ and } x + y = 5 \text{ (deduction)}$$
  • but not on _tricky_ binary operators.
  • # [C (GCC)](https://gcc.gnu.org), 41 bytes
  • ```c
  • f(x,y){int r=x*y;return r&&r==x+y?5:x+y;}
  • ```
  • [Attempt This Online!](https://ato.pxeger.com/run?1=m700OT49OXnBJuXMvOSc0pRUBZvikpTMfL0Mu6WlJWm6Fjc10zQqdCo1qzPzShSKbCu0Kq2LUktKi_IUitTUimxtK7Qr7U2tgKR1LVTDQ5DK3MTMPI2y_MwUTa5qLs6CIqBYmoaSakpMnpKOQpqGgY6CgaamNRYZQx0FI-wyRhAZBX19Bf_8_IJiRQUjBW0gtlUwVbDSxK7BGLtRxjoKJthlTHUUTHE4zBJongVIDurRBQsgNAA)
#6: Post edited by user avatar Zakk‭ · 2022-04-30T06:03:53Z (over 2 years ago)
  • # [C (gcc)](https://gcc.gnu.org), 28 bytes
  • ``` C
  • f(x,y){return x*y==4?5:x+y;}
  • ```
  • [Attempt This Online!](https://ato.pxeger.com/run?1=m700OT49OXnBJuXMvOSc0pRUBZvikpTMfL0Mu6WlJWm6FnvSNCp0KjWri1JLSovyFCq0Km1tTexNrSq0K61rIUpuPszMK1HITczM0yjLz0zR5Krm4iwoAoqlaSippsTkKekopGkY6CgYaGpaY5Ex1FEwwi5jBJFR0NdX8M_PLyhWVDBS0AZiWwVTBStN7BqMsRtlrKNggl3GVEfBFIfDLIHmWYDkoB5dsABCAwA)
  • # [C (gcc)](https://gcc.gnu.org), 28 bytes
  • ``` C
  • f(x,y){return x*y==4?5:x+y;}
  • ```
  • [Attempt This Online!](https://ato.pxeger.com/run?1=m700OT49OXnBJuXMvOSc0pRUBZvikpTMfL0Mu6WlJWm6FnvSNCp0KjWri1JLSovyFCq0Km1tTexNrSq0K61rIUpuPszMK1HITczM0yjLz0zR5Krm4iwoAoqlaSippsTkKekopGkY6CgYaGpaY5Ex1FEwwi5jBJFR0NdX8M_PLyhWVDBS0AZiWwVTBStN7BqMsRtlrKNggl3GVEfBFIfDLIHmWYDkoB5dsABCAwA)
  • This solution is based on the simple fact that:
  • $$x \in \mathbb{N}, y \in \mathbb{N}$$
  • $$x=2, y=2 \Longrightarrow x \times y = 4 \text{ and } x + y = 5 \text{ (exception)}$$
  • $$x=1, y=4 \Longrightarrow x \times y = 4 \text{ and } x + y = 5 \text{ (deduction)}$$
  • $$x=4, y=1 \Longrightarrow x \times y = 4 \text{ and } x + y = 5 \text{ (deduction)}$$
  • but not on _tricky_ binary operators.
#5: Post undeleted by user avatar Zakk‭ · 2022-04-30T05:56:29Z (over 2 years ago)
#4: Post edited by user avatar Zakk‭ · 2022-04-30T05:56:09Z (over 2 years ago)
#3: Post edited by user avatar Zakk‭ · 2022-04-30T05:38:18Z (over 2 years ago)
  • # [C (gcc)](https://gcc.gnu.org), 28 bytes
  • ``` C
  • f(x,y){return x*y==4?5:x+y;}
  • ```
  • [Attempt This Online!](https://ato.pxeger.com/run?1=m700OT49OXnBJuXMvOSc0pRUBZvikpTMfL0Mu6WlJWm6FnvSNCp0KjWri1JLSovyFCq0Km1tTexNrSq0K61rIUpuPszMK1HITczM0yjLz0zR5Krm4iwoAoqlaSippsTkKekopGkY6CgYaGpaY5Ex1FEwwi5jBJFR0NdX8M_PLyhWVDBS0AZiWwVTBStN7BqMsRtlrKNggl3GVEfBFIfDLIHmWYDkoB5dsABCAwA)
  • This solution is based on the simple fact that:
  • $$x \in \mathbb{N}, y \in \mathbb{N}$$
  • $$x=2 \text{ and } y=2 \Longleftrightarrow x \times y=4$$
  • but not on _tricky_ binary operators.
  • # [C (gcc)](https://gcc.gnu.org), 28 bytes
  • ``` C
  • f(x,y){return x*y==4?5:x+y;}
  • ```
  • [Attempt This Online!](https://ato.pxeger.com/run?1=m700OT49OXnBJuXMvOSc0pRUBZvikpTMfL0Mu6WlJWm6FnvSNCp0KjWri1JLSovyFCq0Km1tTexNrSq0K61rIUpuPszMK1HITczM0yjLz0zR5Krm4iwoAoqlaSippsTkKekopGkY6CgYaGpaY5Ex1FEwwi5jBJFR0NdX8M_PLyhWVDBS0AZiWwVTBStN7BqMsRtlrKNggl3GVEfBFIfDLIHmWYDkoB5dsABCAwA)
#2: Post deleted by user avatar Zakk‭ · 2022-04-30T05:37:16Z (over 2 years ago)
#1: Initial revision by user avatar Zakk‭ · 2022-04-30T04:42:13Z (over 2 years ago)
# [C (gcc)](https://gcc.gnu.org), 28 bytes

``` C
f(x,y){return x*y==4?5:x+y;}
```

[Attempt This Online!](https://ato.pxeger.com/run?1=m700OT49OXnBJuXMvOSc0pRUBZvikpTMfL0Mu6WlJWm6FnvSNCp0KjWri1JLSovyFCq0Km1tTexNrSq0K61rIUpuPszMK1HITczM0yjLz0zR5Krm4iwoAoqlaSippsTkKekopGkY6CgYaGpaY5Ex1FEwwi5jBJFR0NdX8M_PLyhWVDBS0AZiWwVTBStN7BqMsRtlrKNggl3GVEfBFIfDLIHmWYDkoB5dsABCAwA)

This solution is based on the simple fact that:
$$x \in \mathbb{N}, y \in \mathbb{N}$$
$$x=2 \text{ and } y=2 \Longleftrightarrow x \times y=4$$

but not on _tricky_ binary operators.