Multi-user CRUD: Valid, Problem, or Error?Strip all non-printable ASCII charactersCongratulations on getting 10,000 reputation!Resolve doubling and tripling actions in DominionExtendable Train Swapping ProblemBreak my source file!User Appreciation Challenge #1: Dennis ♦What's my name?Do I have permission?VEVO User Account CheckerValid Badminton Score?

How can an advanced civilization forget how to manufacture its technology?

Would letting a multiclass character rebuild their character to be single-classed be game-breaking?

Referring to different instances of the same character in time travel

What would the EU do if an EU member declared war on another EU member?

Wrapper in return method for test class

Stuck Apple Mail - how to reset?

Repeating redundant information after dialogues, to avoid or not?

Who Can Help Retag This?

During copyediting, journal disagrees about spelling of paper's main topic

Grammy Winners Grading

Cubic programming and beyond?

Where is the USB2 OTG port on the RPi 4 Model B located?

QGIS Welcome page: What is 'pin to list' for?

Why are Hobbits so fond of mushrooms?

Where or how can I find what interfaces an out of the box Apex class implements?

Creating custom objects with custom properties using generics

Is Trump personally blocking people on Twitter?

As a DM, how to avoid unconscious metagaming when dealing with a high AC character?

Correct use of ergeben?

If a specific mass of air is polluted, will the pollution stick with it?

Cops: The Hidden OEIS Substring

Professor falsely accusing me of cheating in a class he does not teach, two months after end of the class. What precautions should I take?

Why did the Japanese attack the Aleutians at the same time as Midway?

How to check the quality of an audio sample?



Multi-user CRUD: Valid, Problem, or Error?


Strip all non-printable ASCII charactersCongratulations on getting 10,000 reputation!Resolve doubling and tripling actions in DominionExtendable Train Swapping ProblemBreak my source file!User Appreciation Challenge #1: Dennis ♦What's my name?Do I have permission?VEVO User Account CheckerValid Badminton Score?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








10












$begingroup$



Introduction:



Ever used Dropbox with some other people and you both modified the same file? Ever had a multi-user application with a relational database, and two people were modifying (or worse, one was deleting and the other modifying) the same object? Well, let's simulate that with this challenge (sort-of).



For the sake of this challenge, we only have two users and either one or two relevant files. Both users have in general privileges to CRUD (Create, Read, Update, and Delete) all files.



Challenge:



Input:



We'll have a few inputs (input format is flexible, and any reasonable format is allowed):



1) Locking mode (on/off): Kinda the difference between optimistic and pessimistic concurrency locking.

Both users are allowed to CRUD (Create, Read, Update, and Delete) everything, but sometimes errors or problems can occur. Depending on the locking mode a problem when turned off, could be an error when turned on. This is explained below in the Output section.



2 & 3) Two user-actions. These actions always consist of two things: What the user does (Create, Read, Update, or Delete) and for which file.



Output:



We'll have three possible outputs:




  1. Valid: Both actions by both users can be done simultaneously without any issues occurring.


  2. Error: Both actions by both users cannot be done simultaneously and causes an error for one of the users (which user is irrelevant for this challenge). This can occur when:

    • one user Reads or Updates a file, which the other user Deletes;

    • both users Update the same file with locking mode turned on;

    • a user Creates a file, which the other user Reads/Updates/Deletes (this means the file already exists, so it cannot be Created);

    • both users Create the same file.



  3. Problem: Both actions by both users can be done simultaneously, but can cause unexpected problems. This can occur when:

    • both users Update a file when locking mode is turned off;

    • one user Updates a file, which the other user Reads;

    • both users Delete the same file (practically this will causes an error for the second user, but since it will still be deleted like the user wants, it will be a problem instead of an error for the sake of this challenge)


Challenge Rules:



  • All input and output is flexible, and everyone should state which one they've used in their answer!

    Example inputs: 0/1 for locking mode & 31 (third action: Update; file: 1) & 21 (second action: Read; file: 1); true/false for locking mode & ['C','A'] (action: Create; file: A) & ['D','B'] (action: Delete; file: B); etc.

    Example outputs: null/true/false (null = valid; true = error; false = problem); -1/0/1 (-1 = error; 0 = problem; 1 = valid); etc. The three possible outputs have to be unique and distinct for the three output-type, though.

  • What the files are called is irrelevant, which can also be seen with the input-examples above. So feel free to use any type of file name in your answers consisting of a single (ASCII) letter or digit. They do have to be consistent across all your test cases however, so you can't use A/B in one test case and 1/2 in another.

  • The four actions for CRUD have to be unique and consistent values as well. So you cannot use 'D'/'C' in one test case, and then 4/1 in another test case.

  • You can assume that the file chosen by a user always exists when they want to Read, Update, or Delete it.

General rules:



  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.

All possible test cases (where the actions can be in either input-order):



: You should support all (up to four) variations of the test cases below. So if a test case states action1: Create file A; action2: Update file B, that test case should also hold the same results for action1: Create file B; action2: Update file A; action1: Update file B; action2: Create file A; and action1: Update file A; action2: Create file B.



Valid use-cases:

locking mode: either; action1: Create file A; action2: Create file B
locking mode: either; action1: Create file A; action2: Read file B
locking mode: either; action1: Create file A; action2: Update file B
locking mode: either; action1: Create file A; action2: Delete file B
locking mode: either; action1: Read file A; action2: Read file A
locking mode: either; action1: Read file A; action2: Read file B
locking mode: either; action1: Read file A; action2: Update file B
locking mode: either; action1: Read file A; action2: Delete file B
locking mode: either; action1: Update file A; action2: Update file B
locking mode: either; action1: Update file A; action2: Delete file B
locking mode: either; action1: Delete file A; action2: Delete file B

Error use-cases:

locking mode: either; action1: Create file A; action2: Create file A
locking mode: either; action1: Create file A; action2: Read file A
locking mode: either; action1: Create file A; action2: Update file A
locking mode: either; action1: Create file A; action2: Delete file A
locking mode: either; action1: Read file A; action2: Delete file A
locking mode: on; action1: Update file A; action2: Update file A
locking mode: either; action1: Update file A; action2: Delete file A

Problem use-cases:

locking mode: either; action1: Read file A; action2: Update file A
locking mode: off; action1: Update file A; action2: Update file A
locking mode: either; action1: Delete file A; action2: Delete file A









share|improve this question











$endgroup$







  • 2




    $begingroup$
    I feel like there will be a 1 byte solution if I can just come up with the right input/output methods (maybe some kind of bit masking)
    $endgroup$
    – Expired Data
    Jul 4 at 9:32






  • 2




    $begingroup$
    @ExpiredData Altered a few parts of the possible outputs, that they have to be consistent, but not necessarily unique. And also that the inputs have to be consistent.
    $endgroup$
    – Kevin Cruijssen
    Jul 4 at 9:35






  • 1




    $begingroup$
    @Arnauld Ah, I excluded all B/B cases in my counting, since I deemed them similar as A/A. That's where the difference is coming from. But I guess that thinking is incorrectly if you have a specific value for the files..
    $endgroup$
    – Kevin Cruijssen
    Jul 4 at 12:52


















10












$begingroup$



Introduction:



Ever used Dropbox with some other people and you both modified the same file? Ever had a multi-user application with a relational database, and two people were modifying (or worse, one was deleting and the other modifying) the same object? Well, let's simulate that with this challenge (sort-of).



For the sake of this challenge, we only have two users and either one or two relevant files. Both users have in general privileges to CRUD (Create, Read, Update, and Delete) all files.



Challenge:



Input:



We'll have a few inputs (input format is flexible, and any reasonable format is allowed):



1) Locking mode (on/off): Kinda the difference between optimistic and pessimistic concurrency locking.

Both users are allowed to CRUD (Create, Read, Update, and Delete) everything, but sometimes errors or problems can occur. Depending on the locking mode a problem when turned off, could be an error when turned on. This is explained below in the Output section.



2 & 3) Two user-actions. These actions always consist of two things: What the user does (Create, Read, Update, or Delete) and for which file.



Output:



We'll have three possible outputs:




  1. Valid: Both actions by both users can be done simultaneously without any issues occurring.


  2. Error: Both actions by both users cannot be done simultaneously and causes an error for one of the users (which user is irrelevant for this challenge). This can occur when:

    • one user Reads or Updates a file, which the other user Deletes;

    • both users Update the same file with locking mode turned on;

    • a user Creates a file, which the other user Reads/Updates/Deletes (this means the file already exists, so it cannot be Created);

    • both users Create the same file.



  3. Problem: Both actions by both users can be done simultaneously, but can cause unexpected problems. This can occur when:

    • both users Update a file when locking mode is turned off;

    • one user Updates a file, which the other user Reads;

    • both users Delete the same file (practically this will causes an error for the second user, but since it will still be deleted like the user wants, it will be a problem instead of an error for the sake of this challenge)


Challenge Rules:



  • All input and output is flexible, and everyone should state which one they've used in their answer!

    Example inputs: 0/1 for locking mode & 31 (third action: Update; file: 1) & 21 (second action: Read; file: 1); true/false for locking mode & ['C','A'] (action: Create; file: A) & ['D','B'] (action: Delete; file: B); etc.

    Example outputs: null/true/false (null = valid; true = error; false = problem); -1/0/1 (-1 = error; 0 = problem; 1 = valid); etc. The three possible outputs have to be unique and distinct for the three output-type, though.

  • What the files are called is irrelevant, which can also be seen with the input-examples above. So feel free to use any type of file name in your answers consisting of a single (ASCII) letter or digit. They do have to be consistent across all your test cases however, so you can't use A/B in one test case and 1/2 in another.

  • The four actions for CRUD have to be unique and consistent values as well. So you cannot use 'D'/'C' in one test case, and then 4/1 in another test case.

  • You can assume that the file chosen by a user always exists when they want to Read, Update, or Delete it.

General rules:



  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.

All possible test cases (where the actions can be in either input-order):



: You should support all (up to four) variations of the test cases below. So if a test case states action1: Create file A; action2: Update file B, that test case should also hold the same results for action1: Create file B; action2: Update file A; action1: Update file B; action2: Create file A; and action1: Update file A; action2: Create file B.



Valid use-cases:

locking mode: either; action1: Create file A; action2: Create file B
locking mode: either; action1: Create file A; action2: Read file B
locking mode: either; action1: Create file A; action2: Update file B
locking mode: either; action1: Create file A; action2: Delete file B
locking mode: either; action1: Read file A; action2: Read file A
locking mode: either; action1: Read file A; action2: Read file B
locking mode: either; action1: Read file A; action2: Update file B
locking mode: either; action1: Read file A; action2: Delete file B
locking mode: either; action1: Update file A; action2: Update file B
locking mode: either; action1: Update file A; action2: Delete file B
locking mode: either; action1: Delete file A; action2: Delete file B

Error use-cases:

locking mode: either; action1: Create file A; action2: Create file A
locking mode: either; action1: Create file A; action2: Read file A
locking mode: either; action1: Create file A; action2: Update file A
locking mode: either; action1: Create file A; action2: Delete file A
locking mode: either; action1: Read file A; action2: Delete file A
locking mode: on; action1: Update file A; action2: Update file A
locking mode: either; action1: Update file A; action2: Delete file A

Problem use-cases:

locking mode: either; action1: Read file A; action2: Update file A
locking mode: off; action1: Update file A; action2: Update file A
locking mode: either; action1: Delete file A; action2: Delete file A









share|improve this question











$endgroup$







  • 2




    $begingroup$
    I feel like there will be a 1 byte solution if I can just come up with the right input/output methods (maybe some kind of bit masking)
    $endgroup$
    – Expired Data
    Jul 4 at 9:32






  • 2




    $begingroup$
    @ExpiredData Altered a few parts of the possible outputs, that they have to be consistent, but not necessarily unique. And also that the inputs have to be consistent.
    $endgroup$
    – Kevin Cruijssen
    Jul 4 at 9:35






  • 1




    $begingroup$
    @Arnauld Ah, I excluded all B/B cases in my counting, since I deemed them similar as A/A. That's where the difference is coming from. But I guess that thinking is incorrectly if you have a specific value for the files..
    $endgroup$
    – Kevin Cruijssen
    Jul 4 at 12:52














10












10








10


1



$begingroup$



Introduction:



Ever used Dropbox with some other people and you both modified the same file? Ever had a multi-user application with a relational database, and two people were modifying (or worse, one was deleting and the other modifying) the same object? Well, let's simulate that with this challenge (sort-of).



For the sake of this challenge, we only have two users and either one or two relevant files. Both users have in general privileges to CRUD (Create, Read, Update, and Delete) all files.



Challenge:



Input:



We'll have a few inputs (input format is flexible, and any reasonable format is allowed):



1) Locking mode (on/off): Kinda the difference between optimistic and pessimistic concurrency locking.

Both users are allowed to CRUD (Create, Read, Update, and Delete) everything, but sometimes errors or problems can occur. Depending on the locking mode a problem when turned off, could be an error when turned on. This is explained below in the Output section.



2 & 3) Two user-actions. These actions always consist of two things: What the user does (Create, Read, Update, or Delete) and for which file.



Output:



We'll have three possible outputs:




  1. Valid: Both actions by both users can be done simultaneously without any issues occurring.


  2. Error: Both actions by both users cannot be done simultaneously and causes an error for one of the users (which user is irrelevant for this challenge). This can occur when:

    • one user Reads or Updates a file, which the other user Deletes;

    • both users Update the same file with locking mode turned on;

    • a user Creates a file, which the other user Reads/Updates/Deletes (this means the file already exists, so it cannot be Created);

    • both users Create the same file.



  3. Problem: Both actions by both users can be done simultaneously, but can cause unexpected problems. This can occur when:

    • both users Update a file when locking mode is turned off;

    • one user Updates a file, which the other user Reads;

    • both users Delete the same file (practically this will causes an error for the second user, but since it will still be deleted like the user wants, it will be a problem instead of an error for the sake of this challenge)


Challenge Rules:



  • All input and output is flexible, and everyone should state which one they've used in their answer!

    Example inputs: 0/1 for locking mode & 31 (third action: Update; file: 1) & 21 (second action: Read; file: 1); true/false for locking mode & ['C','A'] (action: Create; file: A) & ['D','B'] (action: Delete; file: B); etc.

    Example outputs: null/true/false (null = valid; true = error; false = problem); -1/0/1 (-1 = error; 0 = problem; 1 = valid); etc. The three possible outputs have to be unique and distinct for the three output-type, though.

  • What the files are called is irrelevant, which can also be seen with the input-examples above. So feel free to use any type of file name in your answers consisting of a single (ASCII) letter or digit. They do have to be consistent across all your test cases however, so you can't use A/B in one test case and 1/2 in another.

  • The four actions for CRUD have to be unique and consistent values as well. So you cannot use 'D'/'C' in one test case, and then 4/1 in another test case.

  • You can assume that the file chosen by a user always exists when they want to Read, Update, or Delete it.

General rules:



  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.

All possible test cases (where the actions can be in either input-order):



: You should support all (up to four) variations of the test cases below. So if a test case states action1: Create file A; action2: Update file B, that test case should also hold the same results for action1: Create file B; action2: Update file A; action1: Update file B; action2: Create file A; and action1: Update file A; action2: Create file B.



Valid use-cases:

locking mode: either; action1: Create file A; action2: Create file B
locking mode: either; action1: Create file A; action2: Read file B
locking mode: either; action1: Create file A; action2: Update file B
locking mode: either; action1: Create file A; action2: Delete file B
locking mode: either; action1: Read file A; action2: Read file A
locking mode: either; action1: Read file A; action2: Read file B
locking mode: either; action1: Read file A; action2: Update file B
locking mode: either; action1: Read file A; action2: Delete file B
locking mode: either; action1: Update file A; action2: Update file B
locking mode: either; action1: Update file A; action2: Delete file B
locking mode: either; action1: Delete file A; action2: Delete file B

Error use-cases:

locking mode: either; action1: Create file A; action2: Create file A
locking mode: either; action1: Create file A; action2: Read file A
locking mode: either; action1: Create file A; action2: Update file A
locking mode: either; action1: Create file A; action2: Delete file A
locking mode: either; action1: Read file A; action2: Delete file A
locking mode: on; action1: Update file A; action2: Update file A
locking mode: either; action1: Update file A; action2: Delete file A

Problem use-cases:

locking mode: either; action1: Read file A; action2: Update file A
locking mode: off; action1: Update file A; action2: Update file A
locking mode: either; action1: Delete file A; action2: Delete file A









share|improve this question











$endgroup$





Introduction:



Ever used Dropbox with some other people and you both modified the same file? Ever had a multi-user application with a relational database, and two people were modifying (or worse, one was deleting and the other modifying) the same object? Well, let's simulate that with this challenge (sort-of).



For the sake of this challenge, we only have two users and either one or two relevant files. Both users have in general privileges to CRUD (Create, Read, Update, and Delete) all files.



Challenge:



Input:



We'll have a few inputs (input format is flexible, and any reasonable format is allowed):



1) Locking mode (on/off): Kinda the difference between optimistic and pessimistic concurrency locking.

Both users are allowed to CRUD (Create, Read, Update, and Delete) everything, but sometimes errors or problems can occur. Depending on the locking mode a problem when turned off, could be an error when turned on. This is explained below in the Output section.



2 & 3) Two user-actions. These actions always consist of two things: What the user does (Create, Read, Update, or Delete) and for which file.



Output:



We'll have three possible outputs:




  1. Valid: Both actions by both users can be done simultaneously without any issues occurring.


  2. Error: Both actions by both users cannot be done simultaneously and causes an error for one of the users (which user is irrelevant for this challenge). This can occur when:

    • one user Reads or Updates a file, which the other user Deletes;

    • both users Update the same file with locking mode turned on;

    • a user Creates a file, which the other user Reads/Updates/Deletes (this means the file already exists, so it cannot be Created);

    • both users Create the same file.



  3. Problem: Both actions by both users can be done simultaneously, but can cause unexpected problems. This can occur when:

    • both users Update a file when locking mode is turned off;

    • one user Updates a file, which the other user Reads;

    • both users Delete the same file (practically this will causes an error for the second user, but since it will still be deleted like the user wants, it will be a problem instead of an error for the sake of this challenge)


Challenge Rules:



  • All input and output is flexible, and everyone should state which one they've used in their answer!

    Example inputs: 0/1 for locking mode & 31 (third action: Update; file: 1) & 21 (second action: Read; file: 1); true/false for locking mode & ['C','A'] (action: Create; file: A) & ['D','B'] (action: Delete; file: B); etc.

    Example outputs: null/true/false (null = valid; true = error; false = problem); -1/0/1 (-1 = error; 0 = problem; 1 = valid); etc. The three possible outputs have to be unique and distinct for the three output-type, though.

  • What the files are called is irrelevant, which can also be seen with the input-examples above. So feel free to use any type of file name in your answers consisting of a single (ASCII) letter or digit. They do have to be consistent across all your test cases however, so you can't use A/B in one test case and 1/2 in another.

  • The four actions for CRUD have to be unique and consistent values as well. So you cannot use 'D'/'C' in one test case, and then 4/1 in another test case.

  • You can assume that the file chosen by a user always exists when they want to Read, Update, or Delete it.

General rules:



  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.

All possible test cases (where the actions can be in either input-order):



: You should support all (up to four) variations of the test cases below. So if a test case states action1: Create file A; action2: Update file B, that test case should also hold the same results for action1: Create file B; action2: Update file A; action1: Update file B; action2: Create file A; and action1: Update file A; action2: Create file B.



Valid use-cases:

locking mode: either; action1: Create file A; action2: Create file B
locking mode: either; action1: Create file A; action2: Read file B
locking mode: either; action1: Create file A; action2: Update file B
locking mode: either; action1: Create file A; action2: Delete file B
locking mode: either; action1: Read file A; action2: Read file A
locking mode: either; action1: Read file A; action2: Read file B
locking mode: either; action1: Read file A; action2: Update file B
locking mode: either; action1: Read file A; action2: Delete file B
locking mode: either; action1: Update file A; action2: Update file B
locking mode: either; action1: Update file A; action2: Delete file B
locking mode: either; action1: Delete file A; action2: Delete file B

Error use-cases:

locking mode: either; action1: Create file A; action2: Create file A
locking mode: either; action1: Create file A; action2: Read file A
locking mode: either; action1: Create file A; action2: Update file A
locking mode: either; action1: Create file A; action2: Delete file A
locking mode: either; action1: Read file A; action2: Delete file A
locking mode: on; action1: Update file A; action2: Update file A
locking mode: either; action1: Update file A; action2: Delete file A

Problem use-cases:

locking mode: either; action1: Read file A; action2: Update file A
locking mode: off; action1: Update file A; action2: Update file A
locking mode: either; action1: Delete file A; action2: Delete file A






code-golf decision-problem






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 4 at 12:16







Kevin Cruijssen

















asked Jul 4 at 9:01









Kevin CruijssenKevin Cruijssen

47.8k7 gold badges82 silver badges241 bronze badges




47.8k7 gold badges82 silver badges241 bronze badges







  • 2




    $begingroup$
    I feel like there will be a 1 byte solution if I can just come up with the right input/output methods (maybe some kind of bit masking)
    $endgroup$
    – Expired Data
    Jul 4 at 9:32






  • 2




    $begingroup$
    @ExpiredData Altered a few parts of the possible outputs, that they have to be consistent, but not necessarily unique. And also that the inputs have to be consistent.
    $endgroup$
    – Kevin Cruijssen
    Jul 4 at 9:35






  • 1




    $begingroup$
    @Arnauld Ah, I excluded all B/B cases in my counting, since I deemed them similar as A/A. That's where the difference is coming from. But I guess that thinking is incorrectly if you have a specific value for the files..
    $endgroup$
    – Kevin Cruijssen
    Jul 4 at 12:52













  • 2




    $begingroup$
    I feel like there will be a 1 byte solution if I can just come up with the right input/output methods (maybe some kind of bit masking)
    $endgroup$
    – Expired Data
    Jul 4 at 9:32






  • 2




    $begingroup$
    @ExpiredData Altered a few parts of the possible outputs, that they have to be consistent, but not necessarily unique. And also that the inputs have to be consistent.
    $endgroup$
    – Kevin Cruijssen
    Jul 4 at 9:35






  • 1




    $begingroup$
    @Arnauld Ah, I excluded all B/B cases in my counting, since I deemed them similar as A/A. That's where the difference is coming from. But I guess that thinking is incorrectly if you have a specific value for the files..
    $endgroup$
    – Kevin Cruijssen
    Jul 4 at 12:52








2




2




$begingroup$
I feel like there will be a 1 byte solution if I can just come up with the right input/output methods (maybe some kind of bit masking)
$endgroup$
– Expired Data
Jul 4 at 9:32




$begingroup$
I feel like there will be a 1 byte solution if I can just come up with the right input/output methods (maybe some kind of bit masking)
$endgroup$
– Expired Data
Jul 4 at 9:32




2




2




$begingroup$
@ExpiredData Altered a few parts of the possible outputs, that they have to be consistent, but not necessarily unique. And also that the inputs have to be consistent.
$endgroup$
– Kevin Cruijssen
Jul 4 at 9:35




$begingroup$
@ExpiredData Altered a few parts of the possible outputs, that they have to be consistent, but not necessarily unique. And also that the inputs have to be consistent.
$endgroup$
– Kevin Cruijssen
Jul 4 at 9:35




1




1




$begingroup$
@Arnauld Ah, I excluded all B/B cases in my counting, since I deemed them similar as A/A. That's where the difference is coming from. But I guess that thinking is incorrectly if you have a specific value for the files..
$endgroup$
– Kevin Cruijssen
Jul 4 at 12:52





$begingroup$
@Arnauld Ah, I excluded all B/B cases in my counting, since I deemed them similar as A/A. That's where the difference is coming from. But I guess that thinking is incorrectly if you have a specific value for the files..
$endgroup$
– Kevin Cruijssen
Jul 4 at 12:52











3 Answers
3






active

oldest

votes


















8












$begingroup$

JavaScript (ES6), 36 bytes



Without a lookup table





(m,a,f,A,F)=>f-F?2:a^A?a*A&8:a&4?m:a


Try it online!



I/O



  • Locking mode ($m$): $0$ = On, $8$ = Off

  • Actions ($a$ and $A$): $0$ = Create, $2$ = Read, $4$ = Update, $8$ = Delete

  • Files ($f$ and $F$): any integers

  • Output: $0$ = Error, $2$ = Valid, $8$ = Problem

How?



If the files are different, all operations are safe and we just return $2$ (valid).



If the files are identical, we need to return:




  • $2$ (valid) if we have two read operations


  • $8$ (problem) if we have two delete operations, or one update and one read


  • $m$ (either problem or error) if we have two update operations


  • $0$ (error) for everything else

Using a $4times4$ CRUD matrix (which is symmetric by definition), we can see that the above values can be computed with:



$$underbracetexta ^ A_aneq A?text ? colorbluetexta * A & 8text : underbracetexta & 4_textupdate?text ? colorredtextm : colormagentatexta$$



$$beginarraycc
&&textC&textR&textU&textD\
&&0&2&4&8\
hline
textC&0&colormagenta0&colorblue0&colorblue0&colorblue0\
textR&2&colorblue0&colormagenta2&colorblue8&colorblue0\
textU&4&colorblue0&colorblue8&colorredtextm&colorblue0\
textD&8&colorblue0&colorblue0&colorblue0&colormagenta8
endarray$$




JavaScript (ES6),  46 45  40 bytes



With a lookup table





(m,a,f,A,F)=>f-F?0:[m,1,1,0][a*2+A*9&23]


Try it online!



I/O



  • Locking mode: undefined = On, $1$ = Off

  • Actions: $0$ = Update, $1$ = Read, $2$ = Create, $3$ = Delete

  • Files: any integers

  • Output: undefined = Error, $0$ = Valid, $1$ = Problem





share|improve this answer











$endgroup$




















    4












    $begingroup$


    Retina 0.8.2, 53 bytes



    ^(.)(?!1).+|..RR.
    V
    ..DD.
    P
    ..UUL
    E
    .+[CD].+
    E
    ..+
    P


    Try it online! Link includes test suite. Takes input as a string of 5 characters, two characters representing the file names, then two characters from CRUD, then L or U (locked/unlocked), and outputs one of VPE (valid/problem/error). Explanation:



    ^(.)(?!1).+|..RR.
    V


    Different file names are always valid, as are two reads. Annoyingly, this is the only test that forces me to use a header. (It would cost an extra byte to make the header unnecessary.)



    ..DD.
    P


    Two deletes are always a problem.



    ..UUL
    E


    Two locked updates are an error.



    .+[CD].+
    E


    Any other creates or deletes are an error.



    ..+
    P


    Everything else is a problem.






    share|improve this answer









    $endgroup$




















      3












      $begingroup$


      Octave, 96 bytes





      @(a,b,c)[a(1)!=b(1)|a(2)+b(2)==20,mod((m=a+b+c)(2),10010)<1|mod(m(2),1020000)<1|mod(m(2),200)<1]


      Try it online!



      Definitely can be shorter, but I don't have time right now to do that



      File 1 = 0
      File 2 = 1
      Read = 10
      Delete = 100
      Create = 1000
      Update = 10000
      Lock on = 100000
      Lock off = 1000000

      Valid Values:
      [1 0]

      Problem Values:
      [0 1]


      Invalid Values:
      [0 0]


      Input as a = [file, action], b = [file2, action2], c = lock






      share|improve this answer











      $endgroup$















        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "200"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f187658%2fmulti-user-crud-valid-problem-or-error%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        8












        $begingroup$

        JavaScript (ES6), 36 bytes



        Without a lookup table





        (m,a,f,A,F)=>f-F?2:a^A?a*A&8:a&4?m:a


        Try it online!



        I/O



        • Locking mode ($m$): $0$ = On, $8$ = Off

        • Actions ($a$ and $A$): $0$ = Create, $2$ = Read, $4$ = Update, $8$ = Delete

        • Files ($f$ and $F$): any integers

        • Output: $0$ = Error, $2$ = Valid, $8$ = Problem

        How?



        If the files are different, all operations are safe and we just return $2$ (valid).



        If the files are identical, we need to return:




        • $2$ (valid) if we have two read operations


        • $8$ (problem) if we have two delete operations, or one update and one read


        • $m$ (either problem or error) if we have two update operations


        • $0$ (error) for everything else

        Using a $4times4$ CRUD matrix (which is symmetric by definition), we can see that the above values can be computed with:



        $$underbracetexta ^ A_aneq A?text ? colorbluetexta * A & 8text : underbracetexta & 4_textupdate?text ? colorredtextm : colormagentatexta$$



        $$beginarraycc
        &&textC&textR&textU&textD\
        &&0&2&4&8\
        hline
        textC&0&colormagenta0&colorblue0&colorblue0&colorblue0\
        textR&2&colorblue0&colormagenta2&colorblue8&colorblue0\
        textU&4&colorblue0&colorblue8&colorredtextm&colorblue0\
        textD&8&colorblue0&colorblue0&colorblue0&colormagenta8
        endarray$$




        JavaScript (ES6),  46 45  40 bytes



        With a lookup table





        (m,a,f,A,F)=>f-F?0:[m,1,1,0][a*2+A*9&23]


        Try it online!



        I/O



        • Locking mode: undefined = On, $1$ = Off

        • Actions: $0$ = Update, $1$ = Read, $2$ = Create, $3$ = Delete

        • Files: any integers

        • Output: undefined = Error, $0$ = Valid, $1$ = Problem





        share|improve this answer











        $endgroup$

















          8












          $begingroup$

          JavaScript (ES6), 36 bytes



          Without a lookup table





          (m,a,f,A,F)=>f-F?2:a^A?a*A&8:a&4?m:a


          Try it online!



          I/O



          • Locking mode ($m$): $0$ = On, $8$ = Off

          • Actions ($a$ and $A$): $0$ = Create, $2$ = Read, $4$ = Update, $8$ = Delete

          • Files ($f$ and $F$): any integers

          • Output: $0$ = Error, $2$ = Valid, $8$ = Problem

          How?



          If the files are different, all operations are safe and we just return $2$ (valid).



          If the files are identical, we need to return:




          • $2$ (valid) if we have two read operations


          • $8$ (problem) if we have two delete operations, or one update and one read


          • $m$ (either problem or error) if we have two update operations


          • $0$ (error) for everything else

          Using a $4times4$ CRUD matrix (which is symmetric by definition), we can see that the above values can be computed with:



          $$underbracetexta ^ A_aneq A?text ? colorbluetexta * A & 8text : underbracetexta & 4_textupdate?text ? colorredtextm : colormagentatexta$$



          $$beginarraycc
          &&textC&textR&textU&textD\
          &&0&2&4&8\
          hline
          textC&0&colormagenta0&colorblue0&colorblue0&colorblue0\
          textR&2&colorblue0&colormagenta2&colorblue8&colorblue0\
          textU&4&colorblue0&colorblue8&colorredtextm&colorblue0\
          textD&8&colorblue0&colorblue0&colorblue0&colormagenta8
          endarray$$




          JavaScript (ES6),  46 45  40 bytes



          With a lookup table





          (m,a,f,A,F)=>f-F?0:[m,1,1,0][a*2+A*9&23]


          Try it online!



          I/O



          • Locking mode: undefined = On, $1$ = Off

          • Actions: $0$ = Update, $1$ = Read, $2$ = Create, $3$ = Delete

          • Files: any integers

          • Output: undefined = Error, $0$ = Valid, $1$ = Problem





          share|improve this answer











          $endgroup$















            8












            8








            8





            $begingroup$

            JavaScript (ES6), 36 bytes



            Without a lookup table





            (m,a,f,A,F)=>f-F?2:a^A?a*A&8:a&4?m:a


            Try it online!



            I/O



            • Locking mode ($m$): $0$ = On, $8$ = Off

            • Actions ($a$ and $A$): $0$ = Create, $2$ = Read, $4$ = Update, $8$ = Delete

            • Files ($f$ and $F$): any integers

            • Output: $0$ = Error, $2$ = Valid, $8$ = Problem

            How?



            If the files are different, all operations are safe and we just return $2$ (valid).



            If the files are identical, we need to return:




            • $2$ (valid) if we have two read operations


            • $8$ (problem) if we have two delete operations, or one update and one read


            • $m$ (either problem or error) if we have two update operations


            • $0$ (error) for everything else

            Using a $4times4$ CRUD matrix (which is symmetric by definition), we can see that the above values can be computed with:



            $$underbracetexta ^ A_aneq A?text ? colorbluetexta * A & 8text : underbracetexta & 4_textupdate?text ? colorredtextm : colormagentatexta$$



            $$beginarraycc
            &&textC&textR&textU&textD\
            &&0&2&4&8\
            hline
            textC&0&colormagenta0&colorblue0&colorblue0&colorblue0\
            textR&2&colorblue0&colormagenta2&colorblue8&colorblue0\
            textU&4&colorblue0&colorblue8&colorredtextm&colorblue0\
            textD&8&colorblue0&colorblue0&colorblue0&colormagenta8
            endarray$$




            JavaScript (ES6),  46 45  40 bytes



            With a lookup table





            (m,a,f,A,F)=>f-F?0:[m,1,1,0][a*2+A*9&23]


            Try it online!



            I/O



            • Locking mode: undefined = On, $1$ = Off

            • Actions: $0$ = Update, $1$ = Read, $2$ = Create, $3$ = Delete

            • Files: any integers

            • Output: undefined = Error, $0$ = Valid, $1$ = Problem





            share|improve this answer











            $endgroup$



            JavaScript (ES6), 36 bytes



            Without a lookup table





            (m,a,f,A,F)=>f-F?2:a^A?a*A&8:a&4?m:a


            Try it online!



            I/O



            • Locking mode ($m$): $0$ = On, $8$ = Off

            • Actions ($a$ and $A$): $0$ = Create, $2$ = Read, $4$ = Update, $8$ = Delete

            • Files ($f$ and $F$): any integers

            • Output: $0$ = Error, $2$ = Valid, $8$ = Problem

            How?



            If the files are different, all operations are safe and we just return $2$ (valid).



            If the files are identical, we need to return:




            • $2$ (valid) if we have two read operations


            • $8$ (problem) if we have two delete operations, or one update and one read


            • $m$ (either problem or error) if we have two update operations


            • $0$ (error) for everything else

            Using a $4times4$ CRUD matrix (which is symmetric by definition), we can see that the above values can be computed with:



            $$underbracetexta ^ A_aneq A?text ? colorbluetexta * A & 8text : underbracetexta & 4_textupdate?text ? colorredtextm : colormagentatexta$$



            $$beginarraycc
            &&textC&textR&textU&textD\
            &&0&2&4&8\
            hline
            textC&0&colormagenta0&colorblue0&colorblue0&colorblue0\
            textR&2&colorblue0&colormagenta2&colorblue8&colorblue0\
            textU&4&colorblue0&colorblue8&colorredtextm&colorblue0\
            textD&8&colorblue0&colorblue0&colorblue0&colormagenta8
            endarray$$




            JavaScript (ES6),  46 45  40 bytes



            With a lookup table





            (m,a,f,A,F)=>f-F?0:[m,1,1,0][a*2+A*9&23]


            Try it online!



            I/O



            • Locking mode: undefined = On, $1$ = Off

            • Actions: $0$ = Update, $1$ = Read, $2$ = Create, $3$ = Delete

            • Files: any integers

            • Output: undefined = Error, $0$ = Valid, $1$ = Problem






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jul 5 at 6:06

























            answered Jul 4 at 10:16









            ArnauldArnauld

            88.1k7 gold badges103 silver badges360 bronze badges




            88.1k7 gold badges103 silver badges360 bronze badges























                4












                $begingroup$


                Retina 0.8.2, 53 bytes



                ^(.)(?!1).+|..RR.
                V
                ..DD.
                P
                ..UUL
                E
                .+[CD].+
                E
                ..+
                P


                Try it online! Link includes test suite. Takes input as a string of 5 characters, two characters representing the file names, then two characters from CRUD, then L or U (locked/unlocked), and outputs one of VPE (valid/problem/error). Explanation:



                ^(.)(?!1).+|..RR.
                V


                Different file names are always valid, as are two reads. Annoyingly, this is the only test that forces me to use a header. (It would cost an extra byte to make the header unnecessary.)



                ..DD.
                P


                Two deletes are always a problem.



                ..UUL
                E


                Two locked updates are an error.



                .+[CD].+
                E


                Any other creates or deletes are an error.



                ..+
                P


                Everything else is a problem.






                share|improve this answer









                $endgroup$

















                  4












                  $begingroup$


                  Retina 0.8.2, 53 bytes



                  ^(.)(?!1).+|..RR.
                  V
                  ..DD.
                  P
                  ..UUL
                  E
                  .+[CD].+
                  E
                  ..+
                  P


                  Try it online! Link includes test suite. Takes input as a string of 5 characters, two characters representing the file names, then two characters from CRUD, then L or U (locked/unlocked), and outputs one of VPE (valid/problem/error). Explanation:



                  ^(.)(?!1).+|..RR.
                  V


                  Different file names are always valid, as are two reads. Annoyingly, this is the only test that forces me to use a header. (It would cost an extra byte to make the header unnecessary.)



                  ..DD.
                  P


                  Two deletes are always a problem.



                  ..UUL
                  E


                  Two locked updates are an error.



                  .+[CD].+
                  E


                  Any other creates or deletes are an error.



                  ..+
                  P


                  Everything else is a problem.






                  share|improve this answer









                  $endgroup$















                    4












                    4








                    4





                    $begingroup$


                    Retina 0.8.2, 53 bytes



                    ^(.)(?!1).+|..RR.
                    V
                    ..DD.
                    P
                    ..UUL
                    E
                    .+[CD].+
                    E
                    ..+
                    P


                    Try it online! Link includes test suite. Takes input as a string of 5 characters, two characters representing the file names, then two characters from CRUD, then L or U (locked/unlocked), and outputs one of VPE (valid/problem/error). Explanation:



                    ^(.)(?!1).+|..RR.
                    V


                    Different file names are always valid, as are two reads. Annoyingly, this is the only test that forces me to use a header. (It would cost an extra byte to make the header unnecessary.)



                    ..DD.
                    P


                    Two deletes are always a problem.



                    ..UUL
                    E


                    Two locked updates are an error.



                    .+[CD].+
                    E


                    Any other creates or deletes are an error.



                    ..+
                    P


                    Everything else is a problem.






                    share|improve this answer









                    $endgroup$




                    Retina 0.8.2, 53 bytes



                    ^(.)(?!1).+|..RR.
                    V
                    ..DD.
                    P
                    ..UUL
                    E
                    .+[CD].+
                    E
                    ..+
                    P


                    Try it online! Link includes test suite. Takes input as a string of 5 characters, two characters representing the file names, then two characters from CRUD, then L or U (locked/unlocked), and outputs one of VPE (valid/problem/error). Explanation:



                    ^(.)(?!1).+|..RR.
                    V


                    Different file names are always valid, as are two reads. Annoyingly, this is the only test that forces me to use a header. (It would cost an extra byte to make the header unnecessary.)



                    ..DD.
                    P


                    Two deletes are always a problem.



                    ..UUL
                    E


                    Two locked updates are an error.



                    .+[CD].+
                    E


                    Any other creates or deletes are an error.



                    ..+
                    P


                    Everything else is a problem.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 4 at 9:48









                    NeilNeil

                    86.2k8 gold badges46 silver badges183 bronze badges




                    86.2k8 gold badges46 silver badges183 bronze badges





















                        3












                        $begingroup$


                        Octave, 96 bytes





                        @(a,b,c)[a(1)!=b(1)|a(2)+b(2)==20,mod((m=a+b+c)(2),10010)<1|mod(m(2),1020000)<1|mod(m(2),200)<1]


                        Try it online!



                        Definitely can be shorter, but I don't have time right now to do that



                        File 1 = 0
                        File 2 = 1
                        Read = 10
                        Delete = 100
                        Create = 1000
                        Update = 10000
                        Lock on = 100000
                        Lock off = 1000000

                        Valid Values:
                        [1 0]

                        Problem Values:
                        [0 1]


                        Invalid Values:
                        [0 0]


                        Input as a = [file, action], b = [file2, action2], c = lock






                        share|improve this answer











                        $endgroup$

















                          3












                          $begingroup$


                          Octave, 96 bytes





                          @(a,b,c)[a(1)!=b(1)|a(2)+b(2)==20,mod((m=a+b+c)(2),10010)<1|mod(m(2),1020000)<1|mod(m(2),200)<1]


                          Try it online!



                          Definitely can be shorter, but I don't have time right now to do that



                          File 1 = 0
                          File 2 = 1
                          Read = 10
                          Delete = 100
                          Create = 1000
                          Update = 10000
                          Lock on = 100000
                          Lock off = 1000000

                          Valid Values:
                          [1 0]

                          Problem Values:
                          [0 1]


                          Invalid Values:
                          [0 0]


                          Input as a = [file, action], b = [file2, action2], c = lock






                          share|improve this answer











                          $endgroup$















                            3












                            3








                            3





                            $begingroup$


                            Octave, 96 bytes





                            @(a,b,c)[a(1)!=b(1)|a(2)+b(2)==20,mod((m=a+b+c)(2),10010)<1|mod(m(2),1020000)<1|mod(m(2),200)<1]


                            Try it online!



                            Definitely can be shorter, but I don't have time right now to do that



                            File 1 = 0
                            File 2 = 1
                            Read = 10
                            Delete = 100
                            Create = 1000
                            Update = 10000
                            Lock on = 100000
                            Lock off = 1000000

                            Valid Values:
                            [1 0]

                            Problem Values:
                            [0 1]


                            Invalid Values:
                            [0 0]


                            Input as a = [file, action], b = [file2, action2], c = lock






                            share|improve this answer











                            $endgroup$




                            Octave, 96 bytes





                            @(a,b,c)[a(1)!=b(1)|a(2)+b(2)==20,mod((m=a+b+c)(2),10010)<1|mod(m(2),1020000)<1|mod(m(2),200)<1]


                            Try it online!



                            Definitely can be shorter, but I don't have time right now to do that



                            File 1 = 0
                            File 2 = 1
                            Read = 10
                            Delete = 100
                            Create = 1000
                            Update = 10000
                            Lock on = 100000
                            Lock off = 1000000

                            Valid Values:
                            [1 0]

                            Problem Values:
                            [0 1]


                            Invalid Values:
                            [0 0]


                            Input as a = [file, action], b = [file2, action2], c = lock







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jul 4 at 15:51

























                            answered Jul 4 at 10:08









                            Expired DataExpired Data

                            1,8314 silver badges23 bronze badges




                            1,8314 silver badges23 bronze badges



























                                draft saved

                                draft discarded
















































                                If this is an answer to a challenge…



                                • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                  Explanations of your answer make it more interesting to read and are very much encouraged.


                                • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                More generally…



                                • …Please make sure to answer the question and provide sufficient detail.


                                • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f187658%2fmulti-user-crud-valid-problem-or-error%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                                Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                                Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?