• [ENDED] Code Golf - The Reboot #1 4 3
Currently:  

Author Topic: [ENDED] Code Golf - The Reboot #1  (Read 18071 times)

0 Members and 1 Guest are viewing this topic.

Offline pimathbrainiac

  • Occasionally I make projects
  • Project Author
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
[ENDED] Code Golf - The Reboot #1
« on: June 01, 2015, 08:27:41 am »
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 Saturday 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 14, 2015, 10:17:30 pm by c4ooo »
I am Bach.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Code Golf - The Reboot #1
« Reply #1 on: June 01, 2015, 08:31:12 am »
How is the input read in? Just declaring a variable? File input?

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline pimathbrainiac

  • Occasionally I make projects
  • Project Author
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: Code Golf - The Reboot #1
« Reply #2 on: June 01, 2015, 08:32:06 am »
The input is the source code of the program, so there is no typed/formatted input this time.
I am Bach.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Code Golf - The Reboot #1
« Reply #3 on: June 01, 2015, 09:02:54 am »
108 bytes in PHP, let's see if i can get that smaller!
EDIT: 106 bytes!
EDIT2: more like 88 bytes :3
« Last Edit: June 01, 2015, 09:34:03 am by Sorunome »

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Ivoah

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +3/-0
    • View Profile
    • Codinghobbit
Re: Code Golf - The Reboot #1
« Reply #4 on: June 01, 2015, 10:15:36 am »
Done in python with 87 bytes
:P Sorunome

EDIT: 81 77 bytes
« Last Edit: June 01, 2015, 10:29:17 am by Ivoah »
http://codinghobbit.no-ip.org
My Calcs:
TI-86 (now broken) $2
TI SR-56 - $0
TI-Nspire CX CAS - $152
TI-84+ Silver Edition - $56
TI-84+ Silver Edition - $0
TI-85 - $0
TI-73 Explorer VS - $10
ViewScreen - $3

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Code Golf - The Reboot #1
« Reply #5 on: June 01, 2015, 10:16:21 am »
well PHP needs a two-byte header "<?" :P
edit: 73 bytes ^.^
« Last Edit: June 01, 2015, 10:26:22 am by Sorunome »

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Code Golf - The Reboot #1
« Reply #6 on: June 01, 2015, 12:33:28 pm »
Sounds fun, I'll check this out.

EDIT: 85 bytes!
« Last Edit: June 01, 2015, 03:07:36 pm by Juju »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline c4ooo

  • Project Author
  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
Re: Code Golf - The Reboot #1
« Reply #7 on: June 01, 2015, 03:36:53 pm »
I was just about to start this  :P but o well we all sorta "restarted" this on irc. Can I do reboot #2?  :3
-German Kuznetsov
The impossible chemical compound.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: Code Golf - The Reboot #1
« Reply #8 on: June 01, 2015, 04:09:12 pm »
62 bytes in Python  :)

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Code Golf - The Reboot #1
« Reply #9 on: June 01, 2015, 04:42:47 pm »
I was just about to start this  :P but o well we all sorta "restarted" this on irc. Can I do reboot #2?  :3
That's an idea, different hosts for each week? Can I do #3?

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

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 #1
« Reply #10 on: June 01, 2015, 06:03:45 pm »
I was just about to start this  :P but o well we all sorta "restarted" this on irc. Can I do reboot #2?  :3
That's an idea, different hosts for each week? Can I do #3?
As the guy where the idea came from in the first, place, go right ahead. That'd certainly reduce the workload between the hosts, making sure they get a break from hosting. ;)
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Code Golf - The Reboot #1
« Reply #11 on: June 01, 2015, 08:08:02 pm »
53 in (ba)sh (using standard commands)

(and a bit less if I want to lose some portability, but oh well)

Edit : heh, Levak improved mine and got 36.
« Last Edit: June 02, 2015, 04:33:41 pm by Adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

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 #1
« Reply #12 on: June 03, 2015, 10:15:07 am »
I have to say, the results are very good so far. All of these but 2 are sub-100. I'm proud of the coders. :)
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Code Golf - The Reboot #1
« Reply #13 on: June 03, 2015, 10:15:57 am »
If you could read a file in brainfuck i'd attempt it :P

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline pimathbrainiac

  • Occasionally I make projects
  • Project Author
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: Code Golf - The Reboot #1
« Reply #14 on: June 03, 2015, 10:20:11 am »
Just a heads-up. I will not be the only one posting Code Golf topics on Omni. When you submit in the future, please submit to whoever posted the code golf or myself (if they don't have an account on the site you have an account on)
I am Bach.