Advertisement
Josif_tepe

Untitled

Aug 23rd, 2023
707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include "coins.h"
  2. #include <vector>
  3. std::vector<int> coin_flips(std::vector<int> b, int c) {
  4.     int xor_all = 0;
  5.     for(int i = 0; i < (int) b.size(); i++) {
  6.         if(b[i]) {
  7.             xor_all ^= i;
  8.         }
  9.     }
  10.     std::vector<int> v = {c ^ xor_all};
  11.     return v;
  12. }
  13.  
  14. int find_coin(std::vector<int> b) {
  15.     int xor_result = 0;
  16.     for(int i = 0; i < (int) b.size(); i++) {
  17.         if(b[i]) {
  18.             xor_result ^= i;
  19.         }
  20.     }
  21.     return xor_result;
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement