Author Topic: [CHALLENGE]Logic and Optimization  (Read 32136 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
[CHALLENGE]Logic and Optimization
« on: November 20, 2010, 06:20:03 am »
Hey, I have a small tricky challenge, make a program that allows the user to input the number of Eyes and Noses they have.

The program shall return

"NRML" to 2 eyes 1 nose
"ALMST NRML" to 1 nose 3 eyes or 2 eyes 3 noses (so, only one of them correct) AND
"WEIRD" to none of the correct

I have done it, in a program that takes 80bytes.

You have to make it 80 bytes too or even less!


GOOD LUCK! First successful reply wins, if the winner wants a prize I can make a special image for him :)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #1 on: November 20, 2010, 06:26:51 am »
Does it need to ask specifically for eyes and noses? Or can it just be something like Prompt I,N?
53 bytes of code
Code: [Select]
Prompt I,N
sum({I,N}={2,1→I
"NRML
If not(I
"WEIRD
If I=1
"ALMST "+Ans
Ans

Edit: Removed Pause

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #2 on: November 20, 2010, 06:35:24 am »
Does it need to ask specifically for eyes and noses? Or can it just be something like Prompt I,N?
54 bytes
Code: [Select]
Prompt I,N
sum({I,N}={2,1→I
"NRML
If not(I
"WEIRD
If I=1
"ALMST "+Ans
Pause Ans
You can change Pause Ans to Ans.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #3 on: November 20, 2010, 06:36:20 am »
Yeah, yeah, yeah. I know, I just copied my program from my calc...

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #4 on: November 20, 2010, 07:35:24 am »
I've tried a couple of things by now, none of it worked... it's pretty tricky. The only way to better Xeda's program is to make "NRML the Normal token which you can find under [MODE] and "ALMST NRML to "not(Normal

not really what you were asking for but optimizations nevertheless
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline coolsnake

  • LV2 Member (Next: 40)
  • **
  • Posts: 36
  • Rating: +2/-0
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #5 on: November 20, 2010, 07:43:09 am »
Why does it take 63 bytes when I enter it into my calculator?
Unpretty Integrals
This program gives you a graphical representation of the "fnint(" function, which allows you to calculate definite integrals. It is extremely similar to the functionality MathPrint provides, minus the extreme bloat that slows your calculator down to a crawl.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [CHALLENGE]Logic and Optimization
« Reply #6 on: November 20, 2010, 09:55:01 am »
63 bytes for the entire program including name and header, not just the code.

Offline kindermoumoute

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 836
  • Rating: +54/-3
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #7 on: November 20, 2010, 10:36:01 am »
New challenge : make a base converter from most base possible to most base possible less than 300 bytes (my program got 200 bytes for 36 bases).
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #8 on: November 20, 2010, 11:13:24 am »
Code: [Select]
:Prompt I,N
:sum({I,N}={2,1→I
:"NRML
:If not(I
:"WEIRD
:If I=1
:"ALMST "+Ans
:Ans

WOW! That is just wow... man, wow.

Winner:Xeda112358

Want a prize? xD

I'll post my 80 bytes code (which I thought was great) here later lol
New challenge : make a base converter from most base possible to most base possible less than 300 bytes (my program got 200 bytes for 36 bases).

Yay, a new challenge! Even though I don't understand completely what to do :s
TI Basic?

Offline kindermoumoute

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 836
  • Rating: +54/-3
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #9 on: November 20, 2010, 11:27:45 am »
TI-Basic sure, gtranslate say : you must make a base converter (eg binary to hex ,...) with a maximum of base compatibility (less 300 bytes).

EDIT : need minimum 10 bases compatibility.
« Last Edit: November 20, 2010, 11:35:10 am by kindermoumoute »
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #10 on: November 20, 2010, 12:03:43 pm »
TI-Basic sure, gtranslate say : you must make a base converter (eg binary to hex ,...) with a maximum of base compatibility (less 300 bytes).

EDIT : need minimum 10 bases compatibility.
This explanation is more confusing.

Offline kindermoumoute

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 836
  • Rating: +54/-3
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #11 on: November 20, 2010, 12:09:50 pm »
OK, the challenge is to make the best base converter (NB: decimal, binary, octal, hexadecimal are examples of bases). The program size is 300 bytes maximum. And the converter needs to convert at least 10 bases.

The program requires a number to the user. He then asked the base of this number (basic input), then the base in which we will convert the number (base release). Don't forget display result.
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #12 on: November 20, 2010, 12:29:51 pm »
Okay, here is what I have, weighing in at 208 bytes of code:
Code: [Select]
ClrHome
Input "BASE1:",B
Input "BASE2:",C
Input "NUMBER:",Str1
DelVar D"0123456789ABCDEFGHIJKLMNOPQRSTUV→Str2
length(Str1→E
For(A,1,E
D+B^(E-A)(-1+inString(Str2,sub(Str1,A,1→D
End
iPart(log(D)/log(C
Ans-not(not(fPart(Ans→B
For(A,0,B
D/C^(B-A→D
Str1+sub(Str2,iPart(Ans+1),1→Str1
C^(B-A)fPart(D→D
End
sub(Str1,E+1,B+1

Offline kindermoumoute

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 836
  • Rating: +54/-3
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #13 on: November 20, 2010, 12:50:49 pm »
Where do you find this code ?
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: [CHALLENGE]Logic and Optimization
« Reply #14 on: November 20, 2010, 12:52:11 pm »
Code: [Select]
:Prompt E,N
:If E=2 and N=1
:Disp "NRML
:If E != 2 or N!=1
:Then
:If E=2 or N=1
:Then
:Disp "ALMST NRML
:Else
:Disp "WEIRD
80bytes, for the first challenge