3
\$\begingroup\$

Write a function or program that awards you SE badges. If an input "Q" is given it means you have asked a question. If no input is given it means you have only visited the site.*

Badges it must support:

  • Run script 30 days in a row: "Enthusiast"
  • Run script 100 days in a row: "Fanatic"
  • Input "Q" first time: "Student"
  • Input "Q" on 5 separate days: "Curious"
  • Input "Q" on 30 separate days: "Inquisitive"
  • Input "Q" on 100 separate days: "Socratic"

Input:

  • You may choose an arbitrary input value for the times you ask questions (I've used "Q" as an example).
  • You may choose an arbitrary input value, or have none at all, for the times you only visit the site.
  • If a third type of input is given, say "R", then the counters and list of badges shall be reset. This is to ensure that the program can be reused.

Note, you may visit the site many times each day, and ask several questions on the same day. As with the real badges, days are counted in UTC.

You can only have one of each of the badges.

The source code can be altered, but remember the reset functionality. The score will be the size of the script before it's executed the first time.

Output:

Every time you run the script it should output/print a list of badges you have. The output format is optional, but it must use the proper badge names, i.e. you can't enumerate the badges.

The output should be an empty string, 0, false or something similar if you don't have any badges. The program can't crash, enter an infinite loop or something similar.


This is code golf, so the shortest code before running the script the first time. As always, the score is counted in bytes.

You may use an external file to store information, but both the name of the file, and the size of the file before the code is executed the first time will count toward the score.

\$\endgroup\$
  • 1
    \$\begingroup\$ Just opinion; boring. Did you use the sandbox? \$\endgroup\$ – Erik the Outgolfer Sep 7 '16 at 10:59
  • 2
    \$\begingroup\$ Normally, questions stay for at least 48 hours in the sandbox. If you think questions drown, try making small (or invisible) modifications from time to time to make it stay on top (sorted by 'active'). \$\endgroup\$ – Erik the Outgolfer Sep 7 '16 at 11:05
4
\$\begingroup\$

I guess I'll start.

JAVA: 572 bytes

public class a {static Map<Integer,String>o=new HashMap<Integer,String>();static Map<Integer,String>p=new HashMap<Integer,String>();public static void main(String[] args){Scanner d= new Scanner(System.in);b();int e=0,v=0;while(true){char y=d.nextLine().toCharArray()[0];if(y=='Q'){e++;v++;}else if(y == 'R'){e=0;v=0;b();}else{v++;}System.out.println(o.get(v)+p.get(e));o.remove(v);p.remove(e);}}public static void b(){o.clear();p.clear();o.put(30,"Enthusiast");o.put(100, "fanatic");p.put(1, "student");p.put(5, "Curious");p.put(30,"Inquisitive");p.put(100, "Socratic");}}

Input:
"R" to reset
"Q" if you asked a question
" " if you visited.
[Enter] to log your day.

Output: The badges that you earned that day.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.