Invitation to Shortest Code Challenge
Difference between en13 and en14, changed 2,946 character(s)
![ ](/predownloaded/1f/9c/1f9ccb8e4dcc84c7dc51a55de5e853730f356c11.jpeg)↵
<br> </br>↵
<br> </br>↵
Hello coders!↵
PICT ACM Student Chapter brings to you the "SHORTEST CODE CHALLENGE", the first of its kind at PICT! <br>↵
This coding contest is free and open to all, so we urge each one of you to participate & compete!  <br>↵
All you need is a knack for competitive coding and you are good to go!  <br> </br>↵

<br> </br>↵
**NOTE: Only C++ is allowed**↵
<br> </br>↵

- Registration link: [Contest link](https://www.hackerrank.com/shortest-code-challenge)↵

- Day & Date: Friday, 19th March 2021<br> </br>↵

- Time: 9:00 pm to 11:00 pm IST<br> </br>↵

- World Clock: [Your timing](https://www.timeanddate.com/worldclock/fixedtime.html?msg=Shortest+Code+Challenge&iso=20210319T21&p1=1038&ah=2)↵

- Platform: HackerRank<br> </br>↵

<spoiler summary="About contest and scoring">↵
   - Scoring is based on the number of characters used in your solution.↵
   - <strong>Spaces and newlines will be ignored</strong> while counting characters.↵
   - You are required to code in <strong>C++ only</strong>.↵
   - Your score is inversely proportional to the number of these characters.↵

</spoiler>↵

We are looking forward to your participation!
<br> </br>↵


<strong>UPDATE:</strong>↵
- Thank you all for your participation <br> </br>↵

- Also, some nonoptimal codes passed for 2nd problem. It wasn't intentional, just they were very close to TL. Sorry for that.↵

<strong> Following are the best submissions from the contest (which can also be improved)</strong>↵

<spoiler summary="Mandatory primer (user: dario2994)">↵

~~~~~↵
#include <iostream> ↵

int main() {↵
    int N, n = 1, d;↵
    std::cin >> N;↵
    while (N) {↵
        n++;↵
        d = 2;↵
        while (n%d > 0) d++;↵
        if (d == n) std::cout << n << " ", N--;↵
    }↵
}↵
~~~~~↵

</spoiler>↵

<spoiler summary="Substring habitat (user: davi_bart)">↵

~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵
int x,y,h,r;↵
string a;↵
int main(){↵
cin>>x>>x>>a;↵
while(cin>>x>>y){↵
h=0;↵
for(r='a';r<='z';r++)if(a.find(r,x-1)<y)h++;↵
cout<<h;↵
}↵
}↵
~~~~~↵

</spoiler>↵

<spoiler summary="Card Sequence(user: cjoa)">↵

~~~~~↵
#include <iostream>↵

using namespace std;↵

int N, l, r, a;↵
string S;↵

int main() {↵
   cin >> N >> S;↵
   for (char c : S) {↵
      if (c != l)↵
         r = 0;↵
      a = max(a, ++r);↵
      l = c;↵
   }↵
   cout << a;↵
}↵
~~~~~↵

</spoiler>↵

<spoiler summary="Hugging Divisors (user : weryy0)">↵

~~~~~↵
#include <bits/stdc++.h>↵

long long x, g, q = 0, o = 0, u, t;↵

int f(long long x) {↵
    for (t = 0; x; x /= 10) t |= 1 << x % 10;↵
    return t;↵
}↵

int main() {↵
    std::cin >> x;↵
    g = sqrt(x), u = f(x);↵
    for (; ++q <= g;) o += x % q ? 0 : ((f(q)&u) > 0) + (q * q < x ? (f(x / q)&u) > 0 : 0);↵
    std::cout << o;↵
}↵
~~~~~↵

</spoiler>↵

<spoiler summary="Palindrome Subtree (user: weryy0)">↵

~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵

deque<int> l[100005];↵
int a, c[100005] = {0}, q = 1, x, y;↵
string t;↵

void d(int v, int p) {↵
    c[v] = 1 << t[v - 1] - 97;↵
    for (int h : l[v]) if (h - p) d(h, v), c[v] ^= c[h];↵
}↵

int main() {↵
    cin >> a >> t;↵
    for (; cin >> x >> y;) l[x].push_back(y), l[y].push_back(x);↵
    d(1, 0);↵
    for (; q <= a; ) cout << (__builtin_popcount(c[q++]) < 2);↵
}↵
~~~~~↵

</spoiler>↵

<spoiler summary="Maze Crawler (user: weryy0)">↵

~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵

int main() {↵
    int a, b, q, X, Y, Z, T, o = -1, i, G[] = { -1, 0, 1, 0}, U[] = {0, 1, 0, -1}, C = 0, K = 1;↵
    cin >> a >> b;↵
    string m[a];↵
    for (q = -1; ++q < a;) cin >> m[q];↵
    cin >> X >> Y >> Z >> T;↵
    Y--, T--;↵
    for (deque<int> d = {X * b + Y}; d.size(); K--) {↵
        if (!K) K = d.size(), C++;↵
        int x = d[0] / b, y = d[0] % b; d.pop_front();↵
        o = x == Z & y == T ? C : o;↵
        for (i = -1; ++i < 4;) {↵
            X = x + G[i], Y = y + U[i];↵
            if (0 < X & X <= a & 0 <= Y & Y < b & m[X - 1][Y] == 46)↵
                m[X - 1][Y] = 47, d.push_back(X * b + Y);↵
        }↵
    }↵
    cout << o;↵
}↵
~~~~~↵

</spoiler>


History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en14 English Nachiket 2021-03-19 21:39:36 2946 Tiny change: 'y for that\n\n<stron' -> 'y for that.\n\n<stron'
en13 English Nachiket 2021-03-18 17:43:59 9 Tiny change: 'rrank.com/contests/shortest-' -> 'rrank.com/shortest-'
en12 English Nachiket 2021-03-18 17:23:08 0 (published)
en11 English Nachiket 2021-03-18 17:22:26 45 Tiny change: 'oiler>\n\n\n\n' -> 'oiler>\n\nWe are looking forward to your participation!\n\n'
en10 English Nachiket 2021-03-18 17:17:39 14
en9 English Nachiket 2021-03-18 17:16:16 878
en8 English Nachiket 2021-03-18 17:01:35 215
en7 English Nachiket 2021-03-18 16:54:12 163 Tiny change: 'o code in C++ only. <br> </' -> 'o code in <strong>C++ only</strong>. <br> </'
en6 English Nachiket 2021-03-18 16:48:53 355
en5 English Nachiket 2021-03-18 16:47:03 5 Tiny change: 'o code in #### C++ only.' -> 'o code in C++ only.'
en4 English Nachiket 2021-03-18 16:46:39 109
en3 English Nachiket 2021-03-18 16:43:40 812
en2 English Nachiket 2021-03-18 16:36:57 76 Tiny change: 'Hello code' -> '![ ](https://codeforces.com/818bb3/poster.jpeg)\n\nHello code'
en1 English Nachiket 2021-03-18 16:35:46 52 Initial revision (saved to drafts)