Skip to main content
Share Your Experience: Take the 2024 Developer Survey
81 votes

Magic the Gathering: Friends or Foes?

JavaScript (ES6),  26 23 17 15  14 bytes Takes input as two ASCII codes in currying syntax (a)(b). Returns 4 for ...
Arnauld's user avatar
  • 193k
36 votes

Magic the Gathering: Friends or Foes?

Python 2, 19 bytes "WUBRGWGRBUW".count Try it online! An anonymous function: returns 1 for friends and ...
lynn's user avatar
  • 68.7k
36 votes

Magic the Gathering: Friends or Foes?

Jelly, 6 bytes ạg105Ị Takes two code points as argument. Yields 1 for friends, 0 for foes. Try it online! Background Let n and m be the code points of two ...
Dennis's user avatar
  • 210k
34 votes

Execute a Superb Shuffle™

Ruby, 31 bytes ->x{(0..53).map{|r|x[r*17%54]}} Try it online! Explanation: I'm picking one card, then skipping over the next 16 and start from the first card ...
G B's user avatar
  • 22k
25 votes

20 cards with no Set

Haskell, 62 bytes tail[t|t@[a,b,c,d]<-mapM(:[1,2])[0,0,0,0],mod(a*a+b*b+c*d)3<1] Try it online! Defines a cap-set as all \$(a,b,c,d)\$ from \$\{0,1,2\}^4\...
xnor's user avatar
  • 145k
21 votes

Magic the Gathering: Friends or Foes?

Befunge-98, 13 12 bytes ~~-9%5%3%!.@ Try it online! Prints 0 for friends and 1 for foes ...
MercyBeaucou's user avatar
  • 3,061
19 votes

Faro shuffle an array

vim, 62 59 54 qrma50%mb:norm@q<cr>ggqOjdd'apjma'b@q<esc>0"qDJ<C-a>D@"i@r<esc>xxdd@" Wow. This is possibly the hackiest thing I've written ...
Doorknob's user avatar
  • 71.5k
17 votes

Magic the Gathering: Friends or Foes?

Jelly, 8 7 bytes Piggybacks off of Mistah Figgins's fabulous Befunge answer! Iị390B¤ Try it online! How? As Mistah Figgins noted the decision may be made by taking ...
Jonathan Allan's user avatar
17 votes

Professor at MIT can read minds!

JavaScript (ES6), 130 102 bytes Takes input as an array of strings in "Rs" format, where R is the rank and s is the suit. Expects "T" for 10's. ...
Arnauld's user avatar
  • 193k
16 votes

Magic the Gathering: Friends or Foes?

C++ template metaprogramming, 85 bytes template<int A,int B,int=(A-B)%9%5%3>struct f;template<int A,int B>struct f<A,B,0>{}; less golfed: ...
Yakk's user avatar
  • 929
15 votes

Professor at MIT can read minds!

Python 2, 143 140 138 136 127 125 124 123 121 bytes ...
TFeld's user avatar
  • 19.8k
15 votes

Nothing like a good ol' game of ModTen

Python 3, 114 110 bytes lambda m,n:p(*n)-p(*m) R=b"T 2J45UNK9RL<3SLM;QAK:O>=/678" v=R.find p=lambda i,s,j,t:R[s==t::2][v(j)*v(i)%10+3] Try it ...
Joel's user avatar
  • 1,751
14 votes

Magic the Gathering: Friends or Foes?

Ruby, 22 19 bytes ->x,y{390[(x-y)%9]} Input: ASCII code of the 2 characters. Output: 1 for allies, 0 for enemies. How it works: Get the difference between the 2 ...
G B's user avatar
  • 22k
13 votes
Accepted

Choose the last card in a poker hand

Pyth, 73 bytes eo_S+*-5l@\AN}SPMJ+NZSM.:+\AT5+-4l{eMJlM.gPkJ-sM*=T+`M}2Tc4"JQKA""hscd"=Zc This is pretty terrible. Parsing cards, sorting the values, ... ...
Jakube's user avatar
  • 21.9k
12 votes

Nothing like a good ol' game of ModTen

x86-16 machine code, 87 83 bytes Binary: ...
640KB's user avatar
  • 11.9k
11 votes
Accepted

Faro shuffle an array

05AB1E, 5 bytes Code: F2äø˜ Explanation, input: N, array: ...
Adnan's user avatar
  • 44.4k
11 votes

Golf a golf-scorer

Python 2, 72 70 bytes f=lambda x,*T:[x*(-1)**T.count(x),~x%2*15,-x][(x-3)/8]+(T>()and f(*T)) At one point I wished Python treated ...
Sp3000's user avatar
  • 61.8k
11 votes

Execute a Superb Shuffle™

Python 3, 21 bytes lambda x:(x*17)[::17] Try it online! Explanation: The same idea as my Ruby answer, but even shorter in Python: I use 17 decks, and pick every ...
G B's user avatar
  • 22k
10 votes

Shuffle Up and Deal!

PowerShell v2+, 120 116 114 108 bytes 2..10+[char[]]'JQKA'|%{$z=' '*(8-!($_-10));$x='_'*10;$y=' '*10;" $x /$y\ | $_$z|";,"|$y|"*5;"|$z$_ | \$x/"} Constructs a ...
AdmBorkBork's user avatar
  • 43.4k
10 votes

Magic the Gathering: Friends or Foes?

CJam, 8 bytes {*51%9>} An unnamed block that expects two character codes on top of the stack and replaces them with 0 (...
Martin Ender's user avatar
10 votes

Professor at MIT can read minds!

Jelly, 33 bytes ØDḊḊ;“TJQKA”p“CDHS” ¢iⱮµḊŒ¿×4+Ḣị¢ Try it online! Explanation The first line is niladic. It yields a list of the 52 cards ...
dylnan's user avatar
  • 5,364
10 votes

Play a game of memory

J, 35 bytes [:#(#@]<.[+2-{.+./@e.~2{.}.)~^:a:&2 Attempt This Online! A bit chonky as far as J code goes, but imo a nice simplification of the algorithm: We ...
Jonah's user avatar
  • 33.5k
9 votes

Magic the Gathering: Friends or Foes?

Röda, 30 22 21 bytes Bytes saved thanks to @fergusq by using _ to take the values on the stream as input ...
user41805's user avatar
  • 13.1k
9 votes

Magic the Gathering: Friends or Foes?

05AB1E, 10 bytes Returns 0 for friend and 1 for foe. ‘Û‹BWR‘ûIå Try it online! or as a Test suite Explanation ...
Emigna's user avatar
  • 53k
9 votes

Magic the Gathering: Friends or Foes?

C, 33 32 29 24 22 bytes #define f(k,l)k*l%51<9 Returns 1 if friends, 0 if foes.
Steadybox's user avatar
  • 16.5k
9 votes

Hand patterns in a card game

APL (Dyalog Unicode), 30 chars ×/!⍨,z,1÷((z←!∘≢⊢)⌸⊢),×∘≢!⍨1⊥⊢ Try it online! Using @orlp’s formula.
FrownyFrog's user avatar
  • 3,732
9 votes

Was it a Superb Shuffle™️

JavaScript (ES7), 88 bytes Returns true for Superb™️ or false for Ugly™️. ...
Arnauld's user avatar
  • 193k
8 votes
Accepted

Magic: the Gathering Combat Golf

JavaScript (ES7),  354  348 bytes Takes input as ([attackers], [defenders]). ...
Arnauld's user avatar
  • 193k
8 votes

Magic the Gathering: Friends or Foes?

Vim, 22 21 bytes CWUBRGWGRBUW<esc>:g/<c-r>"/d<cr> Input: a single line containing the two characters. Output: empty buffer if friends, buffer ...
m-chrzan's user avatar
  • 1,488
8 votes

Magic the Gathering: Friends or Foes?

Japt, 6 bytes Inspired by @Martin Ender's solution. Takes an array of two char codes as input. ×%51<9 Try it online! | Test Suite Returns ...
Oliver's user avatar
  • 7,882

Only top scored, non community-wiki answers of a minimum length are eligible