Skip to content

Instantly share code, notes, and snippets.

T = gets.to_i

def prime(input)
    flag = 0
    return puts "Not prime" if input == 1

    for n in 2..(Math.sqrt(input))        
        if input%n == 0            
 flag = 1
@Aravin
Aravin / Spiral Matrix
Last active March 26, 2017 16:28
Java program for printing the matrix elements in Spiral Order
public static void main(String[] args) {
String[][] spiral = new String[3][3];
spiral[0][0] = "1";
spiral[0][1] = "2";
spiral[0][2] = "3";
spiral[1][0] = "4";
spiral[1][1] = "5";
spiral[1][2] = "6";
spiral[2][0] = "7";
@Aravin
Aravin / Happy or Sad Number.cs
Last active September 15, 2017 19:20
A C# program to find whether given number is Happy or Sad
using System;
using System.Collections.Generic;
namespace HappyAndSadNumbers
{
class Program
{
static void Main(string[] args)
{
string input;
@Aravin
Aravin / Happy or Sad Number.rb
Last active September 15, 2017 19:46
A ruby program to find Happy and Sad Numbers
# method for finding happy or sad number
def happy_or_sad(input)
result = 0
repeated_number = Hash.new();
while(!repeated_number.has_key?(input))
temp = 0
repeated_number[input] = 0
input.each do |i|
temp = temp + (i.to_i * i.to_i)
@Aravin
Aravin / Combine Sequence Number.cs
Created September 17, 2017 02:54
C# Program to group the sequence of number
using System;
using System.Collections.Generic;
namespace CombineSequenceNumbers
{
class Program
{
static void Main(string[] args)
{
string input;
@Aravin
Aravin / _flash_messages.html.erb
Created December 10, 2017 17:51 — forked from roberto/_flash_messages.html.erb
Rails flash messages using Twitter Bootstrap
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
@Aravin
Aravin / FileMovement.cs
Created March 18, 2018 18:04
Copying file from one destination to another destination in C# using System.IO.File Class
using System;
using System.IO;
namespace FileMovement
{
class Program
{
static void Main(string[] args)
{
string sourcePath = @"G:\Learning\CSharp\FileMovement\FileMovement\";
@Aravin
Aravin / FileMovement.cs
Created March 18, 2018 18:07
Moving file from one destination to another destination in C# using System.IO.File Class
using System;
using System.IO;
namespace FileMovement
{
class Program
{
static void Main(string[] args)
{
string sourcePath = @"G:\Learning\CSharp\FileMovement\FileMovement\";
@Aravin
Aravin / PrivateProtectedAccessModifiedInCSharp.cs
Last active April 12, 2018 18:44
Private Protected Access Modifier in CSharp C#
// Code from Project 1
namespace FirstAssembly
{
public class FirstClass
{
private protected static void FirstMethod()
{
Console.WriteLine("Private protected method called...");
}
}
@Aravin
Aravin / ProtectedInternalAccessModifiedInCSharp.cs
Created April 12, 2018 18:44
Protected Internal Access Modified in C#
// Code from Project 1
namespace FirstAssembly
{
public class FirstClass
{
protected internal static void FirstMethod()
{
Console.WriteLine("Private protected method called...");
}
}