Post History
C (gcc), 45, 42 bytes t[9999];f(s,a)int*a;{for(;s;)t[a[--s]]++;} Try it online! Assumptions: Passing the array size to a function can be used as a means to deal with empty arrays (not s...
Answer
#2: Post edited
# [C (gcc)], 45 bytes- <!-- language-all: lang-c -->
t[9999];f(s,a)int*a;{s?t[*a++]++,f(s-1,a):0;}[Try it online!][TIO-l50u1psr]- [C (gcc)]: https://gcc.gnu.org/
[TIO-l50u1psr]: https://tio.run/##bU/RasMwDHzPVxyBgl2r4Gxry@aNfUgIIyRx8UOaUrt9WPC3Z3LNRgc1Aks63Z3UbQ5dtyyhfuXXGCs8tdIdw7o1s/8M9bpVqlGKGNhUDL1pE5fr5Hqczjz2FSBSJYu5QG5ZUc4opeHaTmfBHbgPbeDeK50@pSRDgLMi1K6Rf6RVj1UfUZIj3JAkcboEL8qY9cZh9EMQgTR59z1MFoH7RSyK5DK27ni/jRXAnpA2qBs5o6IUT4Rnwpaw40BEdsm3iKSWifqOqBEfT1XVf3mW3P@a7G7B@ZbtXjh7oBKXHw "C (gcc) – Try It Online"- ---
- Assumptions:
- - Passing the array size to a function can be used as a means to deal with empty arrays (not supported in C).
- - A table of integers can be regarded as a hashtable with an integer value as hash key and the value's frequency as data. Or if you will: a key-value pair.
- - Maximum integer value 9999.
- - The global variable `t` may have its contents printed outside the function.
- # [C (gcc)], <del>45</del>, 42 bytes
- <!-- language-all: lang-c -->
- t[9999];f(s,a)int*a;{for(;s;)t[a[--s]]++;}
- [Try it online!][TIO-l50unxgv]
- [C (gcc)]: https://gcc.gnu.org/
- [TIO-l50unxgv]: https://tio.run/##bU/LasMwELz7KwZDQKrXILdNQlH7JUIUY1tFB8chUnuo0be7q4iWFCIGtK@Z2R3aj2HYtmhe@FntRKBe@lN86PXqlovQQctoetO2wdqm0Wn7WvyI84Vn3iNEzmS1ViglJ@oVtdScZzZX4N@Uhn/tVP6aRnIL8E5E4638I@1G7MaEmjzh2skS588YRJ2K3jzNYYoikqLgv6fFIXK9SlWVXeben263cQI4EvIGxsoVHWU8Ep4Ie8KBgYTiUm4RWa0Q1Q1RId2f6rr/8ix5/DU5XMHxnu2eObqjkrYf "C (gcc) – Try It Online"
- ---
- Assumptions:
- - Passing the array size to a function can be used as a means to deal with empty arrays (not supported in C).
- - A table of integers can be regarded as a hashtable with an integer value as hash key and the value's frequency as data. Or if you will: a key-value pair.
- - Maximum integer value 9999.
- - The global variable `t` may have its contents printed outside the function.
#1: Initial revision
# [C (gcc)], 45 bytes <!-- language-all: lang-c --> t[9999];f(s,a)int*a;{s?t[*a++]++,f(s-1,a):0;} [Try it online!][TIO-l50u1psr] [C (gcc)]: https://gcc.gnu.org/ [TIO-l50u1psr]: https://tio.run/##bU/RasMwDHzPVxyBgl2r4Gxry@aNfUgIIyRx8UOaUrt9WPC3Z3LNRgc1Aks63Z3UbQ5dtyyhfuXXGCs8tdIdw7o1s/8M9bpVqlGKGNhUDL1pE5fr5Hqczjz2FSBSJYu5QG5ZUc4opeHaTmfBHbgPbeDeK50@pSRDgLMi1K6Rf6RVj1UfUZIj3JAkcboEL8qY9cZh9EMQgTR59z1MFoH7RSyK5DK27ni/jRXAnpA2qBs5o6IUT4Rnwpaw40BEdsm3iKSWifqOqBEfT1XVf3mW3P@a7G7B@ZbtXjh7oBKXHw "C (gcc) – Try It Online" --- Assumptions: - Passing the array size to a function can be used as a means to deal with empty arrays (not supported in C). - A table of integers can be regarded as a hashtable with an integer value as hash key and the value's frequency as data. Or if you will: a key-value pair. - Maximum integer value 9999. - The global variable `t` may have its contents printed outside the function.