This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""2018 | |
Hackerrank > UWI COMP2211 POTW-08 > Hopsquash | |
Peter Rabbit has found himself in Mr. McGregor's neighbour's garden. | |
This garden is packed with a number of small vegetables patches, but unlike Mr. McGregor's garden, it is not organised in a grid. | |
At least there are multiple patches of butternut squash,which Peter immediately seeks out. | |
Each vegetable patch is numbered from 1 to n . The rabbit hole from which Peter entered the garden is numbered 0. | |
The layout of the garden is specified by providing a sequence of pairs (S.i,T.i ) to indicate that Peter can go | |
from vegetable patch numbered to vegetable patch numbered T.i in a single hop. The type and quantity of vegetable | |
being grown at each patch is provided as a tuple (V.i,Q.i ) to indicate that patch i is growing vegetable V.i and there |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" 2018 | |
Hackerrank > UWI COMP2211 POTW-08 > Palindromic Sort | |
Zoey loves marbles, for her birthday her father has given her n marbles which are comprised of m unique types. | |
Zoey wants to display her marbles in her room but first wants to sort them using what Zoey calls her Palindromic Frequency Sort. | |
The Palindromic Frequency Sort sorts elements based on their frequency. Lower frequencies precede higher frequencies, | |
and in the case of a tie, then the lower numbered marble precedes the higher numbered marble. For example, | |
if there were 3 types of marbles, and there were 10 of type 1, and 5 of types 2 and 3, then in ascending order, | |
they would be arranged as Type 2, Type 3, Type 1. | |
In Zoey's Palindromic Frequency Sort, the element with the largest frequency is placed at the center of the ordering. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
It's March Madness time again, and after watching a game you and a few of your friends decided that you should make your own fantasy league. Being a bit tipsy at the time, you decide to modify the rules a bit. | |
The number of teams, , can now be between and . | |
Each team may play multiple games over the course of the league, and each match earns points for both teams. | |
Standings in the competition are organized based on each team's current overall accumulated points. That is, the team with the largest overall point total will have a rank of 1 and the team with the smallest overall number of points will have rank . | |
When a match is played, both teams are rewarded league points according to the formula: where is the number of points scored during the match for the team and is the number of points awarded for the result of the match. The number of points awarded for each outcome of a match is defined as follows: | |
Condition R | |
Home Win 3000 | |
Away Win 3500 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crypt, getpass, pwd | |
import json,os,sys | |
import random | |
ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
def gen_salt(): | |
chars=[] | |
for i in range(4): | |
chars.append(random.choice(ALPHABET)) | |
return "".join(chars) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import sys | |
import os | |
import timeit | |
#grab the banner | |
def grab_banner(ip_address,port): | |
try: | |
print 'Creating socket and grabbing banner...' | |
s=socket.socket() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Server to implement simplified Diffie-Hellman protocol and demonstrate socket | |
# programming in the process. | |
# Author: fokumdt 2016-10-01 | |
# Version: 0.2 | |
#!/usr/bin/python3 | |
import socket | |
import sys | |
import random |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Client to implement simplified Diffie-Hellman protocol and demonstrate socket | |
# programming in the process | |
# Author: fokumdt 2016-10-01 | |
# Version: 0.2 | |
#!/usr/bin/python3 | |
import socket | |
import sys | |
import math | |
import random |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import java.lang.*; | |
public class Solution { | |
public static void main(String[] args) { | |
Scanner scan = new Scanner(System.in); | |
int in= scan.nextInt(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1. Let us begin by creating a constant. Call it Kand assign the value 6174 to it | |
k=6174 | |
#2. Write a function called gt which accepts two arguments and returns a boolean that indicates | |
# whether the first argument is greater than the second. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int array[100], n, c, d, swap; | |
printf("Enter number of elements\n"); | |
scanf("%d", &n); | |
printf("Enter %d integers\n", n); |
NewerOlder