Author Topic: Code Golf - The Reboot #9  (Read 32373 times)

0 Members and 1 Guest are viewing this topic.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Code Golf - The Reboot #9
« on: July 27, 2015, 03:34:37 am »
I can't believe I've gone about a month without posting another challenge. Time to set things right :P

Hello Omnimaga/CodeWalrus/Cemetech/friends/Romans/countrymen/lend/me/your/ears, and welcome to the ninth installment of...
Code Golf: The Reboot

As you can see, I am @JWinslow23 , the guy who started this idea in the first place. You may recall my weird fifth challenge I devised, and if you do, I'm doing something just as sinister.

Don't know what code golf is? Check out this contest thread OR this really old contest thread for an explanation. Don't know what code is? Then you will not understand this website in general :P

Without further ado...

Challenge 9

Problem

Family Feud is a game show where you try to guess the most popular responses to survey questions, such as "Name something people often steal from the office to use at home", "Name something that gets hard when it gets cold", or "Tell me a famous Dennis". This, of course, has been adapted into many video game ports, including one in 1993 on the Super Nintendo Entertainment System (SNES).

Now, the SNES version has one glitch that makes the game that much more funny: as long as there are the right letters in the right order, the game counts it as correct. This can lead to some rather interesting answers being counted, as seen in this video.

Based on this, here is your challenge: Create a program that, given a string containing a typed-in answer, and another string containing all the accepted answers (encoded in a format explained below), tells the user the answer they matched, and if no answer was matched, tells the user they got a strike.

Let me explain:

The string with the possible answers the game will accept will be encoded and interpreted as follows:
  • Answers will be written in uppercase letters.
  • Backslashes "\" separate multiple valid answers for a given entry.
  • Optional parts of answers are enclosed by a pair of underscores "_", i.e. "_RED_ MEAT" means that "RED MEAT" and "MEAT" are both valid.
  • A caret "^" indicates that the following character is optional, i.e. "PICKLE^S" means that "PICKLES" and "PICKLE" are both valid.
  • Spaces are usually optional (except in special cases). For the purposes of the contest, they are always optional.
  • Any double letters are always optional, e.g. "RACCOON" means that "RACCOON" and "RACON" are both valid.
Input for your program will be in the form of "ANSWER YOU TYPED IN:POSSIBLE ANSWER 1:POSSIBLE ANSWER 2:ETC". Output for your program will be in the form of either the lowest answer on the board that it matches, or "STRIKE!" if it matches no answers. To clarify, here are examples:

Code: [Select]
Input: "CLEANER FLUID:CAR\AUTO:CLOTH_ES_:_KITCHEN_ FLOOR:BODY:TOWEL^S:BATHROOM:DISH_ES_"
Output: "CAR\AUTO"

Input: "FABULOUS DIET WATER:CLOTH_ES_\SHOES:FAT\WEIGHT:BILLS:FOOD:TIME"
Output: "FOOD"

Input: "CODE GOLF CONTEST EIGHT:SOCK^S\HOSE\STOCKINGS\NYLONS:PURSE^S\POCKETBOOK\BAG:POLISH:LACES"
Output: "STRIKE!"

If any more clarification is needed, contact me. I'll try not to give you COMMANDS FOR US INVASION... (whoops, I mean CONFUSION :P )

Scoring

All non-calc languages will be scored with this counter.
Assembly programs will be scored on binary size (minus the header), and TI-BASIC and Axe will be scored on on-calc source size (again, minus the header). For Axe, the entire first line (for example, ".PROGNAME") does not count.

Submission

PM me over on Omnimaga, Cemetech, or CodeWalrus with the code, or make an unlisted YouTube video and PM me the link. (If you take the latter option, then congrats for you :P )

Good luck! I wanna see if Feud come up with clever answers!

SysRPL
RankUserSizeDate
13298220.5 (I swear)Jul 29 2015 05:44:37 pm

Java
RankUserSizeDate
13298371Jul 30 2015 04:47:10 pm

C
RankUserSizeDate
13298334Jul 30 2015 04:47:10 pm

Language Ranking
RankLangUserSizeDate
1SysRPL3298220.5 (I swear)Jul 29 2015 05:44:37 pm
2C3298334Jul 30 2015 04:47:10 pm
3Java3298371Jul 30 2015 04:47:10 pm

Here is the code for the SysRPL, C, and Java entries, respectively. I guess the contest died, even I didn't notice it was already over. But hey, it was fun. :)

Code: [Select]
::
  ' :: OVERSWAP BINT1 POSCHR
    DUP#0=csedrp NULL$SWAP
    2DUP #!+LAST$ UNROT
    1_#1+SUB$ ;
  'NOP 2NULLLAM{}_ BIND
  CHR_: 2GETEVAL 1PUTLAM BEGIN
    CHR_: 2GETEVAL DUP BEGIN
      CHR \5C 2GETEVAL
      ONEONE BEGIN
        3PICKOVER
        OVERLEN$ OVER#< case
        :: 3RDROP 6DROP
          SWAPDROP ABND ;
        SUB$1#
        BINT32 OVER#=case
        :: DROP #1+ AGAIN ;
        BINT94 OVER#=case
        :: DROP #2+ AGAIN ;
        BINT95 OVER#=case
        :: DROP3PICK tokuscore_
          ROT#1+ POS$ #1+ AGAIN ;
        1GETLAM $PICK SUB$1#
        #=ITE #1+ SWAP#1+SWAP
      1GETLAM LEN$ 3PICK #< UNTIL
    3DROP DUPNULL$? UNTIL
  2DROP DUPNULL$? UNTIL
  DROP ABND "STRIKE!"
;

Code: [Select]
#include<stdio.h>
main(int c,char**v){char*i,*a,*s=v[1];while(1){while(*s&&*s!=58&&*s!=92)++s;if(!*s)break;if(*s++==58)a=s;i=v[1];while(*i!=58)switch(*s){case 0:case 58:case 92:while(*a&&*a!=58)printf("%c",*a++);return;case 94:++s;case 32:++s;break;case 95:++s;while(*s++!=95);break;default:if(*i==*s)++s;else++i;}}printf("STRIKE!");}

Code: [Select]
class G{public static void main(String[]c){c=c[0].split(":");for(int n=0;++n<c.length;)for(String s:c[n].split("\\\\"))for(int x=0,y=0;x<c[0].length(){if(y>=s.length()){System.out.print(c[n]);return;}switch(s.charAt(y)){case 94:++y;case 32:++y;break;case 95:y=s.indexOf(95,y+1)+1;break;default:if(c[0].charAt(x)==s.charAt(y))++y;else++x;}}System.out.print("STRIKE!");}}
« Last Edit: August 09, 2015, 12:01:06 am by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Roboman

  • LV3 Member (Next: 100)
  • ***
  • Posts: 96
  • Rating: +10/-2
  • These peanuts taste so good!
    • View Profile
Re: Code Golf - The Reboot #9
« Reply #1 on: July 28, 2015, 06:18:09 pm »
Do we have to backslash?  I don't know how to backslash on TI-OS
:w00t:
UP-UP-DOWN-DOWN-LEFT-RIGHT-LEFT-RIGHT-B-A-ENTER


I always post in good faith!
http://en.wikipedia.org/wiki/Good_faith
If I end up being rude please tell me and understand!
Spoiler For Spoiler:
:-[  I never mean to say things ... negativley...
I am a bit socialy aqward so I often dont pick up on sarcasm or recognize myself being rude...

...

I am sorry for any offence...

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Code Golf - The Reboot #9
« Reply #2 on: July 28, 2015, 08:01:34 pm »
Do we have to backslash?  I don't know how to backslash on TI-OS
You can use a forward slash if a backslash isn't an option.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?