Skip to content

Instantly share code, notes, and snippets.

View micedreams's full-sized avatar
💋
.

Akshatha Sathish micedreams

💋
.
View GitHub Profile
@micedreams
micedreams / counter.dart
Created December 7, 2023 18:39
Note: don't use '++'? context: line 69
import 'package:flutter/material.dart';
void main() {
runApp(const Main());
}
class Main extends StatelessWidget {
const Main({super.key});
@override
@micedreams
micedreams / journal.yml
Last active January 22, 2024 05:32
Workflow to turn any repository into a journal that automatically creates a new entry every day and archives the last entry into an archive folder..
name: Journal
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: '0 0 * * *'
jobs:
@micedreams
micedreams / reversewords.rb
Created November 12, 2023 11:26
reversewords.rb
puts"enter string to get reverse words"
line=gets
def reverse string
arr = string.split /\b/
new_arr = arr.collect {|a| a.reverse}
new_arr.join
end
reverse=reverse(line)
@micedreams
micedreams / poll.dart
Created November 12, 2023 11:26
poll
//this is part flutter project (stick this into main file to see the magic ^-^)
import 'package:flutter/material.dart';
void main() {
runApp(Home());
}
class Home extends StatefulWidget {
Home({Key? key}) : super(key: key);
@micedreams
micedreams / palindrome.rb
Created November 12, 2023 11:25
palindrome
output = (0..).reduce([]) do |accumulator, number|
binary = number.to_s(2)
reverse_binary = binary.reverse.sub!(/^0*/, "")
accumulator << number if binary == reverse_binary && number.to_s == number.to_s.reverse
break accumulator if accumulator.count >= 10
accumulator
end
puts output
@micedreams
micedreams / matrix_multiplication.rb
Created November 12, 2023 11:23
matrix_multiplication.rb
x =[[1, 2, 3] ,[4, 5, 7]]
y = [[1,2 ],[4, 5 ],[6 ,8]]
def multiply(x, y)
result = Array.new( x.length ) { Array.new( y[0].length ) {0} }
puts " here array is contsructed #{result} "
# "row is count of all the regular elements of array x [i.e. x.length]"
# "column is count of all the 1st elements of nested arrays of array y [i.e. y[0].length]"
@micedreams
micedreams / hash.rb
Created November 12, 2023 11:21
hash
friendgame_hash = {}
input = ""
friend = ""
game = ""
puts "Enter name of friend, then their favorite game: or Press Enter to quit"
input = gets.chomp
while input != "" do
@micedreams
micedreams / hanoi.rb
Created November 12, 2023 11:21
hanoi
def tower(count,from,to,via)
if count == 1
to.unshift(from.shift)
puts"\n Move disk 1 from A to C\n"
else
tower(count - 1, from, via, to)
to.unshift(from.shift)
puts"\n Move disk #{count} from C to A\n"
@micedreams
micedreams / continuty_wins
Created November 12, 2023 11:20
continuty wins
input = ARGV.first.split("")
input_array = input.map(&:to_i)
output = input_array.reduce({}) do |accumulator, element|
if accumulator[element]
accumulator[element] += 1
else
accumulator[element] = 1
end
accumulator
end
puts"______________________________\n"
puts" BETTING GAME\n"
puts"______________________________\n"
puts" ***** ***** *****\n"
puts" * * * * * *\n"
puts" * j * * Q * * K *\n"
puts" * * * * * *\n"
puts" ***** ***** *****\n"
puts"______________________________\n"
puts"rules : \n"