Save my secrets!Implement Shamir's Secret Sharing reconstructionProgram to match the requirements in “The World's Worst Passwords Requirements List”Random passwords vs Common passwordsOn the Subject of Passwords3… 2… 1… Crash off!Can you find the villain's password?The bunker of the math lecturerMake a ;# interpreterXKCD Password GeneratorCrack the bank account's password!

what's the equivalent of helper in LWC?

Is the world in Game of Thrones spherical or flat?

Can you use a concentration spell while using Mantle of Majesty?

Is there a rule that prohibits us from using 2 possessives in a row?

Are grass strips more dangerous than tarmac?

Is there a way to save this session?

If Sweden was to magically float away, at what altitude would it be visible from the southern hemisphere?

Different PCB color ( is it different material? )

Why does the UK have more political parties than the US?

What people are called "кабан" and why?

What does the behaviour of water on the skin of an aircraft in flight tell us?

Is there any Biblical Basis for 400 years of silence between Old and New Testament?

The qvolume of an integer

Why don't I have ground wiring on any of my outlets?

How to write a vulnerable moment without it seeming cliche or mushy?

Can a helicopter mask itself from Radar?

How can I grammatically understand "Wir über uns"?

Could a guilty Boris Johnson be used to cancel Brexit?

Can you keep a readied action even through incapacitation?

If a problem only occurs randomly once in every N times on average, how many tests do I have to perform to be certain that it's now fixed?

Is it possible to kill all life on Earth?

Solving symbolic equation for fraction of variables

What does War Machine's "Canopy! Canopy!" line mean in "Avengers: Endgame"?

California: "For quality assurance, this phone call is being recorded"



Save my secrets!


Implement Shamir's Secret Sharing reconstructionProgram to match the requirements in “The World's Worst Passwords Requirements List”Random passwords vs Common passwordsOn the Subject of Passwords3… 2… 1… Crash off!Can you find the villain's password?The bunker of the math lecturerMake a ;# interpreterXKCD Password GeneratorCrack the bank account's password!













14












$begingroup$


I have so many secrets and nowhere to keep them!



The goal is simple: write a program that lets you save a string and have it be protected by a password.



The program will take an alias, password and (optional) secret as parameters.



If this is the first time the program is called with a given alias, then it will store/remember the secret, and output whatever you want.



If the program is called with an alias that has been used before, then it will output the secret for that alias iff the password is the same as the first time the program was run with that alias.



Other cases



  • If its the first time being called with a certain alias and no secret is given - store nothing.


  • If the program is called with an alias that has been used, and the password is incorrect - return any kind of error or nothing at all.


  • If the program is called with an alias that has been used, the password is correct and a new secret is supplied - output the old secret and replace it with the new one so that next time only the new secret is output.


  • If the program is called with an alias that has been used, the password is correct and no new secret is supplied - output the old secret and make sure it doesn't get replaced.


Note: These secrets/passwords do not need to be stored securely



Also note: any alphanumeric input for aliases passwords and secrets should be accepted



Standard rules apply, good luck!










share|improve this question











$endgroup$







  • 1




    $begingroup$
    Yes, use anything to store it - as for aliases I think it should accept any alphanumeric input
    $endgroup$
    – Quinn
    May 16 at 21:05






  • 1




    $begingroup$
    May we use a function rather than a full program?
    $endgroup$
    – Arnauld
    May 16 at 21:16






  • 1




    $begingroup$
    @Arnauld I'll allow it
    $endgroup$
    – Quinn
    May 16 at 21:19






  • 1




    $begingroup$
    May we assume the password and secret are not the empty string?
    $endgroup$
    – xnor
    May 17 at 2:14






  • 1




    $begingroup$
    May we output a null answer (like 0 or None) in any situation where we don't output the secret?
    $endgroup$
    – xnor
    May 17 at 2:37















14












$begingroup$


I have so many secrets and nowhere to keep them!



The goal is simple: write a program that lets you save a string and have it be protected by a password.



The program will take an alias, password and (optional) secret as parameters.



If this is the first time the program is called with a given alias, then it will store/remember the secret, and output whatever you want.



If the program is called with an alias that has been used before, then it will output the secret for that alias iff the password is the same as the first time the program was run with that alias.



Other cases



  • If its the first time being called with a certain alias and no secret is given - store nothing.


  • If the program is called with an alias that has been used, and the password is incorrect - return any kind of error or nothing at all.


  • If the program is called with an alias that has been used, the password is correct and a new secret is supplied - output the old secret and replace it with the new one so that next time only the new secret is output.


  • If the program is called with an alias that has been used, the password is correct and no new secret is supplied - output the old secret and make sure it doesn't get replaced.


Note: These secrets/passwords do not need to be stored securely



Also note: any alphanumeric input for aliases passwords and secrets should be accepted



Standard rules apply, good luck!










share|improve this question











$endgroup$







  • 1




    $begingroup$
    Yes, use anything to store it - as for aliases I think it should accept any alphanumeric input
    $endgroup$
    – Quinn
    May 16 at 21:05






  • 1




    $begingroup$
    May we use a function rather than a full program?
    $endgroup$
    – Arnauld
    May 16 at 21:16






  • 1




    $begingroup$
    @Arnauld I'll allow it
    $endgroup$
    – Quinn
    May 16 at 21:19






  • 1




    $begingroup$
    May we assume the password and secret are not the empty string?
    $endgroup$
    – xnor
    May 17 at 2:14






  • 1




    $begingroup$
    May we output a null answer (like 0 or None) in any situation where we don't output the secret?
    $endgroup$
    – xnor
    May 17 at 2:37













14












14








14


1



$begingroup$


I have so many secrets and nowhere to keep them!



The goal is simple: write a program that lets you save a string and have it be protected by a password.



The program will take an alias, password and (optional) secret as parameters.



If this is the first time the program is called with a given alias, then it will store/remember the secret, and output whatever you want.



If the program is called with an alias that has been used before, then it will output the secret for that alias iff the password is the same as the first time the program was run with that alias.



Other cases



  • If its the first time being called with a certain alias and no secret is given - store nothing.


  • If the program is called with an alias that has been used, and the password is incorrect - return any kind of error or nothing at all.


  • If the program is called with an alias that has been used, the password is correct and a new secret is supplied - output the old secret and replace it with the new one so that next time only the new secret is output.


  • If the program is called with an alias that has been used, the password is correct and no new secret is supplied - output the old secret and make sure it doesn't get replaced.


Note: These secrets/passwords do not need to be stored securely



Also note: any alphanumeric input for aliases passwords and secrets should be accepted



Standard rules apply, good luck!










share|improve this question











$endgroup$




I have so many secrets and nowhere to keep them!



The goal is simple: write a program that lets you save a string and have it be protected by a password.



The program will take an alias, password and (optional) secret as parameters.



If this is the first time the program is called with a given alias, then it will store/remember the secret, and output whatever you want.



If the program is called with an alias that has been used before, then it will output the secret for that alias iff the password is the same as the first time the program was run with that alias.



Other cases



  • If its the first time being called with a certain alias and no secret is given - store nothing.


  • If the program is called with an alias that has been used, and the password is incorrect - return any kind of error or nothing at all.


  • If the program is called with an alias that has been used, the password is correct and a new secret is supplied - output the old secret and replace it with the new one so that next time only the new secret is output.


  • If the program is called with an alias that has been used, the password is correct and no new secret is supplied - output the old secret and make sure it doesn't get replaced.


Note: These secrets/passwords do not need to be stored securely



Also note: any alphanumeric input for aliases passwords and secrets should be accepted



Standard rules apply, good luck!







code-golf stateful






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 16 at 23:44









Unrelated String

2,200313




2,200313










asked May 16 at 20:54









QuinnQuinn

2246




2246







  • 1




    $begingroup$
    Yes, use anything to store it - as for aliases I think it should accept any alphanumeric input
    $endgroup$
    – Quinn
    May 16 at 21:05






  • 1




    $begingroup$
    May we use a function rather than a full program?
    $endgroup$
    – Arnauld
    May 16 at 21:16






  • 1




    $begingroup$
    @Arnauld I'll allow it
    $endgroup$
    – Quinn
    May 16 at 21:19






  • 1




    $begingroup$
    May we assume the password and secret are not the empty string?
    $endgroup$
    – xnor
    May 17 at 2:14






  • 1




    $begingroup$
    May we output a null answer (like 0 or None) in any situation where we don't output the secret?
    $endgroup$
    – xnor
    May 17 at 2:37












  • 1




    $begingroup$
    Yes, use anything to store it - as for aliases I think it should accept any alphanumeric input
    $endgroup$
    – Quinn
    May 16 at 21:05






  • 1




    $begingroup$
    May we use a function rather than a full program?
    $endgroup$
    – Arnauld
    May 16 at 21:16






  • 1




    $begingroup$
    @Arnauld I'll allow it
    $endgroup$
    – Quinn
    May 16 at 21:19






  • 1




    $begingroup$
    May we assume the password and secret are not the empty string?
    $endgroup$
    – xnor
    May 17 at 2:14






  • 1




    $begingroup$
    May we output a null answer (like 0 or None) in any situation where we don't output the secret?
    $endgroup$
    – xnor
    May 17 at 2:37







1




1




$begingroup$
Yes, use anything to store it - as for aliases I think it should accept any alphanumeric input
$endgroup$
– Quinn
May 16 at 21:05




$begingroup$
Yes, use anything to store it - as for aliases I think it should accept any alphanumeric input
$endgroup$
– Quinn
May 16 at 21:05




1




1




$begingroup$
May we use a function rather than a full program?
$endgroup$
– Arnauld
May 16 at 21:16




$begingroup$
May we use a function rather than a full program?
$endgroup$
– Arnauld
May 16 at 21:16




1




1




$begingroup$
@Arnauld I'll allow it
$endgroup$
– Quinn
May 16 at 21:19




$begingroup$
@Arnauld I'll allow it
$endgroup$
– Quinn
May 16 at 21:19




1




1




$begingroup$
May we assume the password and secret are not the empty string?
$endgroup$
– xnor
May 17 at 2:14




$begingroup$
May we assume the password and secret are not the empty string?
$endgroup$
– xnor
May 17 at 2:14




1




1




$begingroup$
May we output a null answer (like 0 or None) in any situation where we don't output the secret?
$endgroup$
– xnor
May 17 at 2:37




$begingroup$
May we output a null answer (like 0 or None) in any situation where we don't output the secret?
$endgroup$
– xnor
May 17 at 2:37










6 Answers
6






active

oldest

votes


















10












$begingroup$

JavaScript (ES6),  60  50 bytes



Saved 10 bytes thanks to @JonasWilms!



Takes input as either (alias,password,secret) or (alias,password). Returns undefined the first time a secret is stored, or false if the password is incorrect.





f=(a,p,s,[P,v]=f[a]||[p])=>p==P&&(f[a]=[P,s||v],v)


Try a 1st test case online!



Try a 2nd test case online!



How?



We define a named function $f$ whose underlying object is also used to store the passwords and the secrets.



Commented



f = ( // f = named function whose underlying object is used for storage
a, // a = alias
p, // p = password
s, // s = optional secret
[P, v] = f[a] // if f[a] is defined, retrieve the password P and the secret v
|| [p] // otherwise, copy p in P
) => //
p == P && ( // if p is not equal to P, yield false; else:
f[a] = [ // update f[a]:
P, // save the new password (or leave it unchanged)
s || v // save the new secret if it's defined, or keep the previous one
], //
v // return the previous secret
) //





share|improve this answer











$endgroup$












  • $begingroup$
    Took me a second to spot how you were storing things!
    $endgroup$
    – Shaggy
    May 16 at 21:53










  • $begingroup$
    hmm, is this correct?
    $endgroup$
    – ngn
    May 17 at 5:35






  • 1




    $begingroup$
    @ngn It's most likely incorrect indeed. Thanks for reporting this. Should be fixed now.
    $endgroup$
    – Arnauld
    May 17 at 7:16










  • $begingroup$
    -7 bytes through storing a [password, value] array inside of the object.
    $endgroup$
    – Jonas Wilms
    May 20 at 20:52










  • $begingroup$
    @JonasWilms Nicely done! I can't think of any situation where p&& is required. So, that's another -3 bytes.
    $endgroup$
    – Arnauld
    May 20 at 21:42


















6












$begingroup$


Python 2, 94 93 bytes





def f(a,p,s=0,d=):
q,t=d.get(a,(0,0))
if q==p:d[a]=p,s or t;return t
elif q<1<s:d[a]=p,s


Try it online!



For once, Python's weird default dict parameter works in my favor...






share|improve this answer











$endgroup$












  • $begingroup$
    Wait, using a default argument makes it just one object instead of a new one on function call? Hmmm... This explains a lot of debugging I've had to do previously lol.
    $endgroup$
    – HyperNeutrino
    May 23 at 1:46


















3












$begingroup$


Ruby, 64 bytes



Builds a hash for aliases to a single key-pair of password => secret. Probably could be more elegant.





->a,w,s=p@q


Try it online!






share|improve this answer









$endgroup$




















    2












    $begingroup$


    Wolfram Language (Mathematica), 34 bytes



    (c=#~g~#2;#3!=##3||(#~g~#2=#3);c)&


    Try it online!






    share|improve this answer









    $endgroup$




















      1












      $begingroup$


      C# (Visual C# Interactive Compiler), 140 138 134 bytes



      -2 bytes thanks to @Expired Data



      a=>p=>s=>(a=P.ContainsKey(a)?P[a]:P[a]=new[]p,s,o:p==a[0]?a[1]:p,s==""?s:p==a[0]?a[1]=s:s).o;var P=new Dictionary<string,string[]>()


      Try it online!






      share|improve this answer











      $endgroup$








      • 1




        $begingroup$
        138 bytes
        $endgroup$
        – Expired Data
        May 17 at 15:35






      • 1




        $begingroup$
        @ExpiredData 134, as P doesn't have to be dynamic now
        $endgroup$
        – someone
        May 17 at 15:50










      • $begingroup$
        130 bytes using the same trick again
        $endgroup$
        – Expired Data
        May 17 at 15:59


















      0












      $begingroup$


      Python 2, 77 bytes





      def f(a,p,s=0,d=):
      P,S=d.get(a,(p,0))
      if p==P:
      if s>0:d[a]=p,s
      return S


      Try it online!



      Similar to Chas Brown's method.






      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%2f185688%2fsave-my-secrets%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        6 Answers
        6






        active

        oldest

        votes








        6 Answers
        6






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        10












        $begingroup$

        JavaScript (ES6),  60  50 bytes



        Saved 10 bytes thanks to @JonasWilms!



        Takes input as either (alias,password,secret) or (alias,password). Returns undefined the first time a secret is stored, or false if the password is incorrect.





        f=(a,p,s,[P,v]=f[a]||[p])=>p==P&&(f[a]=[P,s||v],v)


        Try a 1st test case online!



        Try a 2nd test case online!



        How?



        We define a named function $f$ whose underlying object is also used to store the passwords and the secrets.



        Commented



        f = ( // f = named function whose underlying object is used for storage
        a, // a = alias
        p, // p = password
        s, // s = optional secret
        [P, v] = f[a] // if f[a] is defined, retrieve the password P and the secret v
        || [p] // otherwise, copy p in P
        ) => //
        p == P && ( // if p is not equal to P, yield false; else:
        f[a] = [ // update f[a]:
        P, // save the new password (or leave it unchanged)
        s || v // save the new secret if it's defined, or keep the previous one
        ], //
        v // return the previous secret
        ) //





        share|improve this answer











        $endgroup$












        • $begingroup$
          Took me a second to spot how you were storing things!
          $endgroup$
          – Shaggy
          May 16 at 21:53










        • $begingroup$
          hmm, is this correct?
          $endgroup$
          – ngn
          May 17 at 5:35






        • 1




          $begingroup$
          @ngn It's most likely incorrect indeed. Thanks for reporting this. Should be fixed now.
          $endgroup$
          – Arnauld
          May 17 at 7:16










        • $begingroup$
          -7 bytes through storing a [password, value] array inside of the object.
          $endgroup$
          – Jonas Wilms
          May 20 at 20:52










        • $begingroup$
          @JonasWilms Nicely done! I can't think of any situation where p&& is required. So, that's another -3 bytes.
          $endgroup$
          – Arnauld
          May 20 at 21:42















        10












        $begingroup$

        JavaScript (ES6),  60  50 bytes



        Saved 10 bytes thanks to @JonasWilms!



        Takes input as either (alias,password,secret) or (alias,password). Returns undefined the first time a secret is stored, or false if the password is incorrect.





        f=(a,p,s,[P,v]=f[a]||[p])=>p==P&&(f[a]=[P,s||v],v)


        Try a 1st test case online!



        Try a 2nd test case online!



        How?



        We define a named function $f$ whose underlying object is also used to store the passwords and the secrets.



        Commented



        f = ( // f = named function whose underlying object is used for storage
        a, // a = alias
        p, // p = password
        s, // s = optional secret
        [P, v] = f[a] // if f[a] is defined, retrieve the password P and the secret v
        || [p] // otherwise, copy p in P
        ) => //
        p == P && ( // if p is not equal to P, yield false; else:
        f[a] = [ // update f[a]:
        P, // save the new password (or leave it unchanged)
        s || v // save the new secret if it's defined, or keep the previous one
        ], //
        v // return the previous secret
        ) //





        share|improve this answer











        $endgroup$












        • $begingroup$
          Took me a second to spot how you were storing things!
          $endgroup$
          – Shaggy
          May 16 at 21:53










        • $begingroup$
          hmm, is this correct?
          $endgroup$
          – ngn
          May 17 at 5:35






        • 1




          $begingroup$
          @ngn It's most likely incorrect indeed. Thanks for reporting this. Should be fixed now.
          $endgroup$
          – Arnauld
          May 17 at 7:16










        • $begingroup$
          -7 bytes through storing a [password, value] array inside of the object.
          $endgroup$
          – Jonas Wilms
          May 20 at 20:52










        • $begingroup$
          @JonasWilms Nicely done! I can't think of any situation where p&& is required. So, that's another -3 bytes.
          $endgroup$
          – Arnauld
          May 20 at 21:42













        10












        10








        10





        $begingroup$

        JavaScript (ES6),  60  50 bytes



        Saved 10 bytes thanks to @JonasWilms!



        Takes input as either (alias,password,secret) or (alias,password). Returns undefined the first time a secret is stored, or false if the password is incorrect.





        f=(a,p,s,[P,v]=f[a]||[p])=>p==P&&(f[a]=[P,s||v],v)


        Try a 1st test case online!



        Try a 2nd test case online!



        How?



        We define a named function $f$ whose underlying object is also used to store the passwords and the secrets.



        Commented



        f = ( // f = named function whose underlying object is used for storage
        a, // a = alias
        p, // p = password
        s, // s = optional secret
        [P, v] = f[a] // if f[a] is defined, retrieve the password P and the secret v
        || [p] // otherwise, copy p in P
        ) => //
        p == P && ( // if p is not equal to P, yield false; else:
        f[a] = [ // update f[a]:
        P, // save the new password (or leave it unchanged)
        s || v // save the new secret if it's defined, or keep the previous one
        ], //
        v // return the previous secret
        ) //





        share|improve this answer











        $endgroup$



        JavaScript (ES6),  60  50 bytes



        Saved 10 bytes thanks to @JonasWilms!



        Takes input as either (alias,password,secret) or (alias,password). Returns undefined the first time a secret is stored, or false if the password is incorrect.





        f=(a,p,s,[P,v]=f[a]||[p])=>p==P&&(f[a]=[P,s||v],v)


        Try a 1st test case online!



        Try a 2nd test case online!



        How?



        We define a named function $f$ whose underlying object is also used to store the passwords and the secrets.



        Commented



        f = ( // f = named function whose underlying object is used for storage
        a, // a = alias
        p, // p = password
        s, // s = optional secret
        [P, v] = f[a] // if f[a] is defined, retrieve the password P and the secret v
        || [p] // otherwise, copy p in P
        ) => //
        p == P && ( // if p is not equal to P, yield false; else:
        f[a] = [ // update f[a]:
        P, // save the new password (or leave it unchanged)
        s || v // save the new secret if it's defined, or keep the previous one
        ], //
        v // return the previous secret
        ) //






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 20 at 21:40

























        answered May 16 at 21:23









        ArnauldArnauld

        85.1k7100349




        85.1k7100349











        • $begingroup$
          Took me a second to spot how you were storing things!
          $endgroup$
          – Shaggy
          May 16 at 21:53










        • $begingroup$
          hmm, is this correct?
          $endgroup$
          – ngn
          May 17 at 5:35






        • 1




          $begingroup$
          @ngn It's most likely incorrect indeed. Thanks for reporting this. Should be fixed now.
          $endgroup$
          – Arnauld
          May 17 at 7:16










        • $begingroup$
          -7 bytes through storing a [password, value] array inside of the object.
          $endgroup$
          – Jonas Wilms
          May 20 at 20:52










        • $begingroup$
          @JonasWilms Nicely done! I can't think of any situation where p&& is required. So, that's another -3 bytes.
          $endgroup$
          – Arnauld
          May 20 at 21:42
















        • $begingroup$
          Took me a second to spot how you were storing things!
          $endgroup$
          – Shaggy
          May 16 at 21:53










        • $begingroup$
          hmm, is this correct?
          $endgroup$
          – ngn
          May 17 at 5:35






        • 1




          $begingroup$
          @ngn It's most likely incorrect indeed. Thanks for reporting this. Should be fixed now.
          $endgroup$
          – Arnauld
          May 17 at 7:16










        • $begingroup$
          -7 bytes through storing a [password, value] array inside of the object.
          $endgroup$
          – Jonas Wilms
          May 20 at 20:52










        • $begingroup$
          @JonasWilms Nicely done! I can't think of any situation where p&& is required. So, that's another -3 bytes.
          $endgroup$
          – Arnauld
          May 20 at 21:42















        $begingroup$
        Took me a second to spot how you were storing things!
        $endgroup$
        – Shaggy
        May 16 at 21:53




        $begingroup$
        Took me a second to spot how you were storing things!
        $endgroup$
        – Shaggy
        May 16 at 21:53












        $begingroup$
        hmm, is this correct?
        $endgroup$
        – ngn
        May 17 at 5:35




        $begingroup$
        hmm, is this correct?
        $endgroup$
        – ngn
        May 17 at 5:35




        1




        1




        $begingroup$
        @ngn It's most likely incorrect indeed. Thanks for reporting this. Should be fixed now.
        $endgroup$
        – Arnauld
        May 17 at 7:16




        $begingroup$
        @ngn It's most likely incorrect indeed. Thanks for reporting this. Should be fixed now.
        $endgroup$
        – Arnauld
        May 17 at 7:16












        $begingroup$
        -7 bytes through storing a [password, value] array inside of the object.
        $endgroup$
        – Jonas Wilms
        May 20 at 20:52




        $begingroup$
        -7 bytes through storing a [password, value] array inside of the object.
        $endgroup$
        – Jonas Wilms
        May 20 at 20:52












        $begingroup$
        @JonasWilms Nicely done! I can't think of any situation where p&& is required. So, that's another -3 bytes.
        $endgroup$
        – Arnauld
        May 20 at 21:42




        $begingroup$
        @JonasWilms Nicely done! I can't think of any situation where p&& is required. So, that's another -3 bytes.
        $endgroup$
        – Arnauld
        May 20 at 21:42











        6












        $begingroup$


        Python 2, 94 93 bytes





        def f(a,p,s=0,d=):
        q,t=d.get(a,(0,0))
        if q==p:d[a]=p,s or t;return t
        elif q<1<s:d[a]=p,s


        Try it online!



        For once, Python's weird default dict parameter works in my favor...






        share|improve this answer











        $endgroup$












        • $begingroup$
          Wait, using a default argument makes it just one object instead of a new one on function call? Hmmm... This explains a lot of debugging I've had to do previously lol.
          $endgroup$
          – HyperNeutrino
          May 23 at 1:46















        6












        $begingroup$


        Python 2, 94 93 bytes





        def f(a,p,s=0,d=):
        q,t=d.get(a,(0,0))
        if q==p:d[a]=p,s or t;return t
        elif q<1<s:d[a]=p,s


        Try it online!



        For once, Python's weird default dict parameter works in my favor...






        share|improve this answer











        $endgroup$












        • $begingroup$
          Wait, using a default argument makes it just one object instead of a new one on function call? Hmmm... This explains a lot of debugging I've had to do previously lol.
          $endgroup$
          – HyperNeutrino
          May 23 at 1:46













        6












        6








        6





        $begingroup$


        Python 2, 94 93 bytes





        def f(a,p,s=0,d=):
        q,t=d.get(a,(0,0))
        if q==p:d[a]=p,s or t;return t
        elif q<1<s:d[a]=p,s


        Try it online!



        For once, Python's weird default dict parameter works in my favor...






        share|improve this answer











        $endgroup$




        Python 2, 94 93 bytes





        def f(a,p,s=0,d=):
        q,t=d.get(a,(0,0))
        if q==p:d[a]=p,s or t;return t
        elif q<1<s:d[a]=p,s


        Try it online!



        For once, Python's weird default dict parameter works in my favor...







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 17 at 1:44

























        answered May 17 at 1:35









        Chas BrownChas Brown

        5,5491623




        5,5491623











        • $begingroup$
          Wait, using a default argument makes it just one object instead of a new one on function call? Hmmm... This explains a lot of debugging I've had to do previously lol.
          $endgroup$
          – HyperNeutrino
          May 23 at 1:46
















        • $begingroup$
          Wait, using a default argument makes it just one object instead of a new one on function call? Hmmm... This explains a lot of debugging I've had to do previously lol.
          $endgroup$
          – HyperNeutrino
          May 23 at 1:46















        $begingroup$
        Wait, using a default argument makes it just one object instead of a new one on function call? Hmmm... This explains a lot of debugging I've had to do previously lol.
        $endgroup$
        – HyperNeutrino
        May 23 at 1:46




        $begingroup$
        Wait, using a default argument makes it just one object instead of a new one on function call? Hmmm... This explains a lot of debugging I've had to do previously lol.
        $endgroup$
        – HyperNeutrino
        May 23 at 1:46











        3












        $begingroup$


        Ruby, 64 bytes



        Builds a hash for aliases to a single key-pair of password => secret. Probably could be more elegant.





        ->a,w,s=p@q


        Try it online!






        share|improve this answer









        $endgroup$

















          3












          $begingroup$


          Ruby, 64 bytes



          Builds a hash for aliases to a single key-pair of password => secret. Probably could be more elegant.





          ->a,w,s=p@q


          Try it online!






          share|improve this answer









          $endgroup$















            3












            3








            3





            $begingroup$


            Ruby, 64 bytes



            Builds a hash for aliases to a single key-pair of password => secret. Probably could be more elegant.





            ->a,w,s=p@q


            Try it online!






            share|improve this answer









            $endgroup$




            Ruby, 64 bytes



            Builds a hash for aliases to a single key-pair of password => secret. Probably could be more elegant.





            ->a,w,s=p@q


            Try it online!







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered May 16 at 21:42









            Value InkValue Ink

            8,205731




            8,205731





















                2












                $begingroup$


                Wolfram Language (Mathematica), 34 bytes



                (c=#~g~#2;#3!=##3||(#~g~#2=#3);c)&


                Try it online!






                share|improve this answer









                $endgroup$

















                  2












                  $begingroup$


                  Wolfram Language (Mathematica), 34 bytes



                  (c=#~g~#2;#3!=##3||(#~g~#2=#3);c)&


                  Try it online!






                  share|improve this answer









                  $endgroup$















                    2












                    2








                    2





                    $begingroup$


                    Wolfram Language (Mathematica), 34 bytes



                    (c=#~g~#2;#3!=##3||(#~g~#2=#3);c)&


                    Try it online!






                    share|improve this answer









                    $endgroup$




                    Wolfram Language (Mathematica), 34 bytes



                    (c=#~g~#2;#3!=##3||(#~g~#2=#3);c)&


                    Try it online!







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered May 17 at 7:04









                    attinatattinat

                    1,05717




                    1,05717





















                        1












                        $begingroup$


                        C# (Visual C# Interactive Compiler), 140 138 134 bytes



                        -2 bytes thanks to @Expired Data



                        a=>p=>s=>(a=P.ContainsKey(a)?P[a]:P[a]=new[]p,s,o:p==a[0]?a[1]:p,s==""?s:p==a[0]?a[1]=s:s).o;var P=new Dictionary<string,string[]>()


                        Try it online!






                        share|improve this answer











                        $endgroup$








                        • 1




                          $begingroup$
                          138 bytes
                          $endgroup$
                          – Expired Data
                          May 17 at 15:35






                        • 1




                          $begingroup$
                          @ExpiredData 134, as P doesn't have to be dynamic now
                          $endgroup$
                          – someone
                          May 17 at 15:50










                        • $begingroup$
                          130 bytes using the same trick again
                          $endgroup$
                          – Expired Data
                          May 17 at 15:59















                        1












                        $begingroup$


                        C# (Visual C# Interactive Compiler), 140 138 134 bytes



                        -2 bytes thanks to @Expired Data



                        a=>p=>s=>(a=P.ContainsKey(a)?P[a]:P[a]=new[]p,s,o:p==a[0]?a[1]:p,s==""?s:p==a[0]?a[1]=s:s).o;var P=new Dictionary<string,string[]>()


                        Try it online!






                        share|improve this answer











                        $endgroup$








                        • 1




                          $begingroup$
                          138 bytes
                          $endgroup$
                          – Expired Data
                          May 17 at 15:35






                        • 1




                          $begingroup$
                          @ExpiredData 134, as P doesn't have to be dynamic now
                          $endgroup$
                          – someone
                          May 17 at 15:50










                        • $begingroup$
                          130 bytes using the same trick again
                          $endgroup$
                          – Expired Data
                          May 17 at 15:59













                        1












                        1








                        1





                        $begingroup$


                        C# (Visual C# Interactive Compiler), 140 138 134 bytes



                        -2 bytes thanks to @Expired Data



                        a=>p=>s=>(a=P.ContainsKey(a)?P[a]:P[a]=new[]p,s,o:p==a[0]?a[1]:p,s==""?s:p==a[0]?a[1]=s:s).o;var P=new Dictionary<string,string[]>()


                        Try it online!






                        share|improve this answer











                        $endgroup$




                        C# (Visual C# Interactive Compiler), 140 138 134 bytes



                        -2 bytes thanks to @Expired Data



                        a=>p=>s=>(a=P.ContainsKey(a)?P[a]:P[a]=new[]p,s,o:p==a[0]?a[1]:p,s==""?s:p==a[0]?a[1]=s:s).o;var P=new Dictionary<string,string[]>()


                        Try it online!







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited May 17 at 15:46

























                        answered May 17 at 15:31









                        someonesomeone

                        9091023




                        9091023







                        • 1




                          $begingroup$
                          138 bytes
                          $endgroup$
                          – Expired Data
                          May 17 at 15:35






                        • 1




                          $begingroup$
                          @ExpiredData 134, as P doesn't have to be dynamic now
                          $endgroup$
                          – someone
                          May 17 at 15:50










                        • $begingroup$
                          130 bytes using the same trick again
                          $endgroup$
                          – Expired Data
                          May 17 at 15:59












                        • 1




                          $begingroup$
                          138 bytes
                          $endgroup$
                          – Expired Data
                          May 17 at 15:35






                        • 1




                          $begingroup$
                          @ExpiredData 134, as P doesn't have to be dynamic now
                          $endgroup$
                          – someone
                          May 17 at 15:50










                        • $begingroup$
                          130 bytes using the same trick again
                          $endgroup$
                          – Expired Data
                          May 17 at 15:59







                        1




                        1




                        $begingroup$
                        138 bytes
                        $endgroup$
                        – Expired Data
                        May 17 at 15:35




                        $begingroup$
                        138 bytes
                        $endgroup$
                        – Expired Data
                        May 17 at 15:35




                        1




                        1




                        $begingroup$
                        @ExpiredData 134, as P doesn't have to be dynamic now
                        $endgroup$
                        – someone
                        May 17 at 15:50




                        $begingroup$
                        @ExpiredData 134, as P doesn't have to be dynamic now
                        $endgroup$
                        – someone
                        May 17 at 15:50












                        $begingroup$
                        130 bytes using the same trick again
                        $endgroup$
                        – Expired Data
                        May 17 at 15:59




                        $begingroup$
                        130 bytes using the same trick again
                        $endgroup$
                        – Expired Data
                        May 17 at 15:59











                        0












                        $begingroup$


                        Python 2, 77 bytes





                        def f(a,p,s=0,d=):
                        P,S=d.get(a,(p,0))
                        if p==P:
                        if s>0:d[a]=p,s
                        return S


                        Try it online!



                        Similar to Chas Brown's method.






                        share|improve this answer









                        $endgroup$

















                          0












                          $begingroup$


                          Python 2, 77 bytes





                          def f(a,p,s=0,d=):
                          P,S=d.get(a,(p,0))
                          if p==P:
                          if s>0:d[a]=p,s
                          return S


                          Try it online!



                          Similar to Chas Brown's method.






                          share|improve this answer









                          $endgroup$















                            0












                            0








                            0





                            $begingroup$


                            Python 2, 77 bytes





                            def f(a,p,s=0,d=):
                            P,S=d.get(a,(p,0))
                            if p==P:
                            if s>0:d[a]=p,s
                            return S


                            Try it online!



                            Similar to Chas Brown's method.






                            share|improve this answer









                            $endgroup$




                            Python 2, 77 bytes





                            def f(a,p,s=0,d=):
                            P,S=d.get(a,(p,0))
                            if p==P:
                            if s>0:d[a]=p,s
                            return S


                            Try it online!



                            Similar to Chas Brown's method.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered May 22 at 0:19









                            xnorxnor

                            95.9k18197458




                            95.9k18197458



























                                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%2f185688%2fsave-my-secrets%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

                                Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

                                Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

                                Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020