Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "farnarkle.h"
  3.  
  4. // return number of arkles
  5. int count_arkles(int sequence1[N_TILES], int sequence2[N_TILES]) {
  6. int i = 0;
  7. int j = 0;
  8. int k = 0;
  9. int stop = 0;
  10. int count = 0;
  11. int modifyable_list[N_TILES];
  12. while(k < N_TILES){ //duplicate sequence 2 for modification purposes
  13. modifyable_list[k] = sequence2[k];
  14. k++;
  15. }
  16. while(i < N_TILES){
  17. stop = 0;
  18. j = 0;
  19. while(j < N_TILES && stop != 1){
  20. if((sequence1[i] == modifyable_list[j]) && (sequence1[j] != modifyable_list[j] && sequence1[i] != modifyable_list[i])){ //second comparison would make it a farnarkle
  21. stop = 1;
  22. modifyable_list[j] = -1; //set the variable to something out of range
  23. count++;
  24. }
  25. j++;
  26. }
  27. i++;
  28. }
  29. return count;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement