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

71%
+3 −0
Challenges Compute the determinant

Python 3.8 (pre-release), 106 95 bytes Saved 11 bytes thanks to Peter Taylor! f=lambda m:sum((-1)**i*x*f([r[:i]+r[i+1:]for r in m[1:]])for i,x in enumerate(m[0]))if m else 1 Try it online! ...

posted 3y ago by user‭  ·  edited 3y ago by user‭

Answer
#2: Post edited by user avatar user‭ · 2021-11-12T23:56:34Z (about 3 years ago)
  • # [Python 3.8 (pre-release)], 106 bytes
  • <!-- language-all: lang-python -->
  • f=lambda m:sum((-1)**i*m[0][i]*f([r[:i]+r[i+1:]for r in m[1:]])for i in range(len(m)))if m[1:]else m[0][0]
  • [Try it online!][TIO-ksuxrhvd]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-ksuxrhvd]: https://tio.run/##dc3LDoIwEAXQPV/RxE2LU9JSkEeiP9J0gRG0CS2k4MKvr8VHwIWryc2c3Ds@5ttgRTk677tj35jzpUGmnu4GY8pJHOvYSKakVnGHpZO1Vnsn9Z7XqhscckhbZGRIiixZL9k19trivrXYEEJ09wZtP7Xo1cWUH522Mw6NkgNTIBnw0EDQDtET4tHmneSQBkAFZEm@MWlS5BsnoAiKA81WQ3kV/Qx9pz73/yikIALJIIdDuAWUUK2U@Sc "Python 3.8 (pre-release) – Try It Online"
  • Here's an attempt at beating Quintec's answer. Only 78 more bytes to go!
  • # [Python 3.8 (pre-release)], <s>106</s> 95 bytes
  • Saved 11 bytes thanks to Peter Taylor!
  • <!-- language-all: lang-python -->
  • f=lambda m:sum((-1)**i*x*f([r[:i]+r[i+1:]for r in m[1:]])for i,x in enumerate(m[0]))if m else 1
  • [Try it online!][TIO-kvx1eo2g]
  • [Python 3.8 (pre-release)]: https://docs.python.org/3.8/
  • [TIO-kvx1eo2g]: https://tio.run/##dY3LCoMwEEX3fsVAN4mdiFFTH9D@SMjC0kgDRiUq2K@3EVq0i64ud@bMnOE1PfsuLQa3rs21re39UYOtxtkSwjgNQxMuYUOkk5VRZyfNmVeq6R04MB1Y6ZuiWze4bBPdzVa7etLEylhRahqwoNtRA18HZ7qJ@GeSY6xQxsj9MYUTsBvw4LCOBCYeYClmkTgwSZSLA5di7imOLNsZxsvgR/RVffK/FBNMPZKhwIvPHAssdzRe3w "Python 3.8 (pre-release) – Try It Online"
  • Here's an attempt at beating Quintec's answer. Only <s>78</s> 67 more bytes to go!
#1: Initial revision by user avatar user‭ · 2021-08-27T22:39:25Z (over 3 years ago)
# [Python 3.8 (pre-release)], 106 bytes

<!-- language-all: lang-python -->

    f=lambda m:sum((-1)**i*m[0][i]*f([r[:i]+r[i+1:]for r in m[1:]])for i in range(len(m)))if m[1:]else m[0][0]

[Try it online!][TIO-ksuxrhvd]

[Python 3.8 (pre-release)]: https://docs.python.org/3.8/
[TIO-ksuxrhvd]: https://tio.run/##dc3LDoIwEAXQPV/RxE2LU9JSkEeiP9J0gRG0CS2k4MKvr8VHwIWryc2c3Ds@5ttgRTk677tj35jzpUGmnu4GY8pJHOvYSKakVnGHpZO1Vnsn9Z7XqhscckhbZGRIiixZL9k19trivrXYEEJ09wZtP7Xo1cWUH522Mw6NkgNTIBnw0EDQDtET4tHmneSQBkAFZEm@MWlS5BsnoAiKA81WQ3kV/Qx9pz73/yikIALJIIdDuAWUUK2U@Sc "Python 3.8 (pre-release) – Try It Online"

Here's an attempt at beating Quintec's answer. Only 78 more bytes to go!