* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: Code Golf - The Reboot #1  (Read 3438 times)

0 Members and 1 Guest are viewing this topic.

Offline pimathbrainiac

  • Full User
  • Original 5
  • Join Date: Nov 2014
  • Location:
  • Posts: 420
  • Post Rating Ratio: +2/-1
  • Formerly Banned CW Co-Founder Turned News Editor
    • pimathbrainiac
    • View Profile
  • Gender: Other
Code Golf - The Reboot #1
« on: June 01, 2015, 12:46:43 pm »
Hello ladies and gents, welcome to Code Golf! As you probably noticed, I am not JWinslow23 because my name is pimathbrainiac. For those of you who don't know what Code Golf is, I'll tell you. You must write a program in any programming language and make the source as few bytes as possible. There are some rules that you must follow each week.

All programs and source files must be submitted to me via PM by midnight Sunday. Winners will be announced Sunday afternoon, and new challenges appear on Monday.
The program outputs must follow the proper formatting as stated in the week's challenge.
All of your source must be in a single source file. Using certain command-line options to compile code not in your source file is cheating.
Esolangs are okay, but the source must be text.
No drag-and-drop languages, since those can't be counted the same way.

Without further ado: This weeks challenge! (inspired by this challenge, but with a critical twist).

Challenge #1: Counting Code
Write a program that counts the number of occurrences of each unique character in your code and outputs a list of the number of occurrences of each unique character.
No extra white space, with the exception of an optional newline at the end of the program.
The characters listed must be in one of two orders. Either the order of character values in the character encoding used by your language (probably ASCII), or the order the characters appear in your source.
Your program must read its source file.

The hypothetical program
Code: [Select]
{omnimaga}; should produce one of the following outputs:
Code: [Select]
; 1
a 2
g 1
i 1
m 2
n 1
o 1
{ 1
} 1
or
Code: [Select]
{ 1
o 1
m 2
n 1
i 1
a 2
g 1
} 1
; 1

Good luck, and make each character count.

Ranking
1) Levak- 36 Bytes (Bash)
2) Juju - 44 Bytes (Bash)
3) Adriweb - 53 Bytes (Bash)
4) Cumred_Snektron - 62 Bytes (Python)
4) Ikj - 62 Bytes (Python)
6) Sorunome - 73 Bytes (PHP)
7) Ivoah - 77 Bytes (Python)
8 ) DarkestEx/muessigb - 78 Bytes (PHP)
9) Juju - 84 Bytes (Ruby)
10) Juju - 86 Bytes (Python2)
11) DarkestEx/muessigb - 126 Bytes (html/JavaScript)
12) Scipi - 157 Bytes (C++)

Language Ranking
1) Bash - 36 Bytes
2) Python - 62 Bytes
3) PHP - 73 Bytes
4) Ruby - 84 Bytes
5) html/JS - 126 Bytes
6) C++ - 157 Bytes

Here we go, top three entries and top entry in the top three languages:

Levak/Bash
Code: [Select]
history 1|grep -o .|sort|uniq -c|rev
Juju/Bash
Code: [Select]
grep -o . a|sort|uniq -c|awk '{print $2,$1}'
Adriweb/Bash
Code: [Select]
sed 's/\(.\)/\1\'$'\n/g' $0|sort|uniq -c|rev|sed '1d'
Tie for Python:
Cumred_Snektron/Python
Code: [Select]
d=open("c").read()
for c in list(set(d)): print c, d.count(c)
Ikj/Python
Code: [Select]
f=open('a').read()
for i in sorted(set(f)):print(i,f.count(i))

Sorunome/PHP
Code: [Select]
<?foreach(count_chars(@file(b)[0])as$i=>$n)if($n>0)echo chr($i)." $n\n";
Congrats guys!

Now, we had someone among us who requested not to be listed as a competitor, but his code was the smallest. At 15 Bytes in Pyth, Runer112 had the smallest valid solution, but is not in the competitive group, so the standings above are it.
Code: [Select]
FNS{Ks'Gs[Nd/KN
That's it! I'll post another one later today!
« Last Edit: June 08, 2015, 11:13:48 am by pimathbrainiac »


Well, I'm bach here too!

Offline Snektron

  • Lvl 69 Russian Snake
  • CodeWalrus Staff
  • Super User
  • Topic Management
  • Join Date: Dec 2014
  • Location: Netherlands
  • Posts: 3155
  • Post Rating Ratio: +31/-0
  • SSSssssss.....
    • RobinDeWalvis
    • Kzyrox
    • RobinDeWalvis
    • View Profile
    • quantuminfinity
  • Gender: Male
Re: Code Golf - The Reboot #1
« Reply #1 on: June 01, 2015, 01:47:25 pm »
Awesome! This is such a cool thing! I will be participating for sure! :D
Also how about code from system libraries?
Also what about making a custom programming language? :trollface:

also: i'm at 91 bytes already :P
EDIT: 62 now.
« Last Edit: June 01, 2015, 03:16:19 pm by Cumred_Snektron »
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


Offline Unicorn

  • ??? ??? ??? ??? ???
  • Super User
  • CW Contest II - 2nd place
  • *
  • Join Date: Jan 2015
  • Location: ??? ??? ??? ??? ???
  • Posts: 2760
  • Post Rating Ratio: +5/-2
  • make :PICKACHUP: a thing!
    • Unicorn808
    • 114/11432
    • View Profile
    • ??? ??? ??? ??? ???
  • Gender: Male
Re: Code Golf - The Reboot #1
« Reply #2 on: June 01, 2015, 04:17:01 pm »
Wait wat? No scratch? But But so much...


:trollface:
  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
  • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



??? ??? ??? ??? ???

Offline JWinslow23

  • Pi is the coolest number in the history of math. :\
  • Super User
  • CW 4x3 challenge - 2nd place
  • *
  • Join Date: May 2015
  • Location: Somewhere between 13 and Graham's Number
  • Posts: 726
  • Post Rating Ratio: +10/-1
  • Use pi! Pi is the absolute greatest! :(
    • @UCu_9qD95nADzc-W6RN-3Z8A
    • 113/11328
    • View Profile
  • Gender: Male
Re: Code Golf - The Reboot #1
« Reply #3 on: June 01, 2015, 05:00:55 pm »
Ha ha! Excellent job with the challenge idea, it's sure to be interesting. This is exactly how I imagined a reincarnation of the contest. :)

And nice job with the pun, by the way. I was worried you were trying to byte off more than you could chew. At first I didn't notice the pun, I think my brain's getting number by the minute...but brilliant wordsmithing nonetheless. :P

Offline Scipi

  • Full User
  • Domain Name Owner
  • CW 4x3 challenge - 3rd place
  • *
  • Join Date: Nov 2014
  • Location: Lost Town
  • Posts: 164
  • Post Rating Ratio: +1/-0
  • CodeKitten ^w^
    • s1ay3r44
    • Scipii
    • _Scipi
    • Scipi
    • View Profile
    • ScipiSoftware
  • Gender: Male
Re: Code Golf - The Reboot #1
« Reply #4 on: June 01, 2015, 06:38:56 pm »
I've got it down to 168 bytes in C++. Don't think there's much the language will let me do to reduce it further, though. :/ Damn strict typing.
  • Calculators owned: TI-83+, Nspire, Nspire CX, Casio Prizm




Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1318
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • View Profile
    • My homepage
  • Gender: Male
Re: Code Golf - The Reboot #1
« Reply #5 on: June 01, 2015, 06:39:50 pm »
I am at 79 bytes right now.
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5

Online Juju

  • aka Yuki Kagayaki aka J̵̭͕͇ù̞̭̝̯̦j̴̭̙̗͖͡ù͏͓̲̕
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Moderator
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Inside a walrus
  • Posts: 2825
  • Post Rating Ratio: +18/-1
  • Couch potato
    • jul.savard
    • juju2143
    • @juju2143
    • juju2143
    • @julosoft
    • juju-kun
    • /u/juju2143
    • juju2143
    • View Profile
    • Juju's shed
  • Gender: Female
  • WalriiPoints: 99999
Re: Code Golf - The Reboot #1
« Reply #6 on: June 01, 2015, 06:42:40 pm »
I'm down to 116 85 bytes in Ruby now.
« Last Edit: June 01, 2015, 07:08:07 pm by Juju »
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron

????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????:trollface:???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

Offline pimathbrainiac

  • Full User
  • Original 5
  • Join Date: Nov 2014
  • Location:
  • Posts: 420
  • Post Rating Ratio: +2/-1
  • Formerly Banned CW Co-Founder Turned News Editor
    • pimathbrainiac
    • View Profile
  • Gender: Other
Re: Code Golf - The Reboot #1
« Reply #7 on: June 01, 2015, 07:11:14 pm »
Also, please remember to PM me with your source to be added to the list. Otherwise, you don't get counted.
Well, I'm bach here too!

Online DJ Omnimaga

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Topic Management
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18190
  • Post Rating Ratio: +91/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • View Profile
    • DJ Omnimaga music store
  • Gender: Male
Re: Code Golf - The Reboot #1
« Reply #8 on: June 01, 2015, 07:21:32 pm »
Question, since the next Code Golf contests will be Omni-exclusive, will members of other forums be required to create an Omni account and be disallowed to post about their entry elsewhere? Because in 2011 United-TI did a joint contest with Revsoft and MaxCoderz where contestants were not allowed to cross-post their work on any forum other than United-TI, and this backfired with zero entry.
  • Calculators owned: TI-73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)
??? ??? ??? ???

Offline pimathbrainiac

  • Full User
  • Original 5
  • Join Date: Nov 2014
  • Location:
  • Posts: 420
  • Post Rating Ratio: +2/-1
  • Formerly Banned CW Co-Founder Turned News Editor
    • pimathbrainiac
    • View Profile
  • Gender: Other
Re: Code Golf - The Reboot #1
« Reply #9 on: June 01, 2015, 07:25:38 pm »
People will be allowed to post about their entry elsewhere and can PM me from any site for entry, but the topics for each week and the official discussion/q&a will only be on Omni so contestants at least have to check the omni subforum where I'm posting the topics on Monday at least.
Well, I'm bach here too!

Online DJ Omnimaga

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Topic Management
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18190
  • Post Rating Ratio: +91/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • View Profile
    • DJ Omnimaga music store
  • Gender: Male
Re: Code Golf - The Reboot #1
« Reply #10 on: June 01, 2015, 07:40:28 pm »
Aah nice to see there's a community contest sub-forum :D. I hope that since you will be busy this Summer that you will still have time to create new contests every week, though, especially considering you can usually barely even find time to do project periodical anymore >.<

Good luck! And good luck to participants too. Code Golf was one of the longest running TI community contest actually.
  • Calculators owned: TI-73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)
??? ??? ??? ???

Offline alexgt

  • Just your friendly neighborhood Ninja Stach Fancy Iron Man
  • Super User
  • Join Date: Dec 2014
  • Location: Behind you
  • Posts: 2611
  • Post Rating Ratio: +6/-1
  • Something should go here...
    • /u/alexgt9123
    • View Profile
  • Gender: Male
Re: Code Golf - The Reboot #1
« Reply #11 on: June 01, 2015, 08:39:10 pm »
What about the name? In Ti-Basic and HP PPL the name counts towards the total bytes used :-\
  • Calculators owned: Ti-84+, Ti-Nspire, Hp Prime, Broken HP Prime, HP 48SX

Offline DarkestEx

  • Super User
  • Join Date: Jan 2015
  • Location: Germany
  • Posts: 1318
  • Post Rating Ratio: +10/-2
    • @0xbmuessig
    • @muessigb
    • View Profile
    • My homepage
  • Gender: Male
Re: Code Golf - The Reboot #1
« Reply #12 on: June 01, 2015, 08:41:36 pm »
I got it to 126 chars in JS
  • Calculators owned: TI-84+, Casio 101-S, RPN-Calc
  • Consoles, mobile devices and vintage computers owned: Hewlett-Packard 100LX, Original Commodore 64C, Tektronix AWG2021, IBM X60s, IBM X60t, Nintendo DS Lite, Nintendo GameBoy Color, Nintendo GameCube, Xbox 360, Palm m5

Offline Scipi

  • Full User
  • Domain Name Owner
  • CW 4x3 challenge - 3rd place
  • *
  • Join Date: Nov 2014
  • Location: Lost Town
  • Posts: 164
  • Post Rating Ratio: +1/-0
  • CodeKitten ^w^
    • s1ay3r44
    • Scipii
    • _Scipi
    • Scipi
    • View Profile
    • ScipiSoftware
  • Gender: Male
Re: Code Golf - The Reboot #1
« Reply #13 on: June 01, 2015, 08:46:07 pm »
I've brought it down to 157 bytes in C/C++
  • Calculators owned: TI-83+, Nspire, Nspire CX, Casio Prizm




Online DJ Omnimaga

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Topic Management
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18190
  • Post Rating Ratio: +91/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • View Profile
    • DJ Omnimaga music store
  • Gender: Male
Re: Code Golf - The Reboot #1
« Reply #14 on: June 01, 2015, 09:07:56 pm »
Another issue is that on-calc TI-Z80 BASIC uses tokens, so Output( is actually 1 byte instead of 7.
  • Calculators owned: TI-73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)
??? ??? ??? ???

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games